Sunday, July 12, 2009

C programming?

Write a function called PrintToZero that takes in a reference parameter num. The function prints out the content of num up to zero. For example, if *num = 10, then PrintToZero(num) prints 10 9 8 7 .... 0.

C programming?
I'll include code for CheckTotalASCII in this one...I had to cancel the response in the other post you made and now I can't post another answer.





#include %26lt;stdio.h%26gt;





void PrintToZero(int num)


{


printf("%i ", num);


if (num)


PrintToZero(num-1);


}





char CheckTotalASCII(char * pString)


{


int result = 0;


while (*pString)


result += *pString++;


return (result %26amp; 1) ? 'O' : 'E';


//return "EO"[result %26amp; 1]; %26lt;- slightly more effiecient


}
Reply:printtozero(int n)


{


for(;n%26gt;=0;n--)


{


cout%26lt;%26lt;n;


}


}
Reply:#include%26lt;stdio.h%26gt;


void PrintToZero(int *num)


{


int val = *num;


for(val %26gt;= 0; val--)


printf("\t%d",val);


}

sage

No comments:

Post a Comment