Computing.Net > Forums > Programming > Can anyone help me For C!!

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Can anyone help me For C!!

Reply to Message Icon

Original Message
Name: Jones
Date: July 23, 2002 at 11:00:46 Pacific
Subject: Can anyone help me For C!!
Comment:

hello everybody

please i shall be very obliged to those who shall help me solving these problems
please,,help me


i want to make a function SumDiagonal that take in a 2 dimensional array (of 2rows and 2 coloumn) called dimtwoarray containing integers.your function should total up the integers in the diagonal (that is row=coloumn cells).

please help me writing a funtion addsubarrray that take in a 3 dimensional array(of eg 1 row,2 coloumn and 3 widths) containing integers.the function should add 1 to even numbers and subtract 1 from odd numbers in the array.please i want to coding to be done appropriately,i am confused in its coding part, though a bit of logic is known.

please get me the code of function countvowel that take in a string parameter and return the number of non vowels (vowels are a,e,I,o,u) in it.string library is not to be used.

i want to make a function removespaces that would take in a string parameter and return the string without the blank spaces. but string library is not allowed to be used.


Report Offensive Message For Removal


Response Number 1
Name: gpp
Date: July 23, 2002 at 11:36:50 Pacific
Reply:

Thats not too hard..
Create an array called temp equal to the size of the array of characters your removing white spaces from. copy one letter at a time from array1 to temp ommittin all tabs, spaces, carriage return/newlines...

I cant remember exactly, \r or \c might not be anything in c.

ex. \t, \n, \r, \c


Report Offensive Follow Up For Removal

Response Number 2
Name: Jim
Date: July 23, 2002 at 12:17:33 Pacific
Reply:


int SumDiagnol(int dimtwoarray[2][2])
{
    return(dimtwoarray[0][0] + dimtwoarray[1][1]);
}


Report Offensive Follow Up For Removal

Response Number 3
Name: hmm
Date: July 23, 2002 at 20:43:18 Pacific
Reply:

I did this off the top of my head...it hasn't been tested, but it gives the general idea

void modifyarray(int a)
{
for (int x=0;x<1;x++)
for (int y=0;y<2;y++)
for (int z=0;z<3;z++)
{
if (a[x][y][z] % 2 == 0)
a[x][y][z] = a[x][y][z] + 1;
else
a[x][y][z] = a[x][y][z] - 1;
}
}

void main()
{
int a[1][2][3];
for (int x=0;x<1;x++)
for (int y=0;y<2;y++)
for (int z=0;z<3;z++)
a[x][y][z]=0;
modifyarray(a);
}


Report Offensive Follow Up For Removal

Response Number 4
Name: Jim
Date: July 24, 2002 at 08:33:34 Pacific
Reply:

int countvowel(char *p)
{
        char ch;
       int i;

       for (i = 0; *p; ++p)
        {
                ch = *p & 0xDF;
                if (ch < 'B' || ch > 'Z')
                        continue;
               if (ch != 'E' && ch != 'I' && ch != 'O' && ch != 'U')
                       ++i;
       }
       return(i);
}


Report Offensive Follow Up For Removal

Response Number 5
Name: Jim
Date: July 25, 2002 at 20:38:31 Pacific
Reply:

char *removespaces(char *str)
{
        char *p1;
       char *p2;

        for (p1 = p2 = str; *p1; ++p1)
                if (*p1 != ' ')
                        *(p2++) = *p1;
        return(str);
}


Report Offensive Follow Up For Removal


Response Number 6
Name: Jim
Date: July 25, 2002 at 20:41:24 Pacific
Reply:

Oops. Forgot the null terminator.

char *removespaces(char *str)
{
    char *p1;
    char *p2;
    for (p1 = p2 = str; *p1; ++p1)
        if (*p1 != ' ')
            *(p2++) = *p1;
    *p2 = 0;
    return(str);
}



Report Offensive Follow Up For Removal






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home



Results for: Can anyone help me For C!!

Can anyone help me w/ C++?
    Summary: I am trying to learn C++, I was given this program to write out. Can anyone write this? I will type this exactly what was given to me: "Write a program to read a student's school id number, his old G...
www.computing.net/answers/programming/can-anyone-help-me-w-c/3472.html

C assignment-can anyone help??
    Summary: can anyone help me on this?? urgent !! below is the question and the sample output to it.. Use a double-subscripted array to solve the following problem. A company has four salespeople (1 to 4) who se...
www.computing.net/answers/programming/c-assignmentcan-anyone-help/13449.html

can anyone help with java
    Summary: can anyone help me with my java homewok. This is the task.Design and code a class called Deductions, to calculate gross and net wage based on the following: A person is paid a gross weekly wage based ...
www.computing.net/answers/programming/can-anyone-help-with-java/4173.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History






Data Recovery Software