#include%26lt;stdio.h%26gt;
int PrintToZero(int *num)
{
int val = *num;
for(val %26gt;= 0; val--)
printf(';\t%d';,val);
}
main()
{
int *n;
printf(';enter num: ';);
scanf(';%d';,%26amp;n);
PrintToZero(int *n);
getch();
}
it doesn't work.
if a enter no 10
it will show: 10 9 8 7 6 5 4 3 2 1 0
but i cant do it. pls help me.....Whats's wrong with my coding?
Your for loop looks suspect:
for ( int val = *num; val %26gt;= 0; val-- )Whats's wrong with my coding?
use for loop as :
for(;val%26gt;=0;val--)
I'm not too good at C, but it looks like you should be declaring
int n;
and not
int *n;
but otherwise it looks good to me.
One more more error; your for loop should be
for(;val%26gt;=0;val--)
(Notice the ; at the start)
I don't see why you are using pointers, while you can easily programm it without it; I'll sum some faults you've made ;-)
* your for-loop should have 3 parameters, when you leef the first one blank, you should set a ';'
*In the main-function, you shouldn't declare n as a pointer to int. just declare it as a int
*when you call for the function PrintToZero, you should give 'n' as parameter, not int *n, because its allready declared ;-)
I'll show you the code now, without pointers.; If you need more help, mail me
#include%26lt;stdio.h%26gt;
int PrintToZero(int val)
{
for(;val%26gt;=0;val--)
{
printf(';\t%d';,val);
}
}
int main(void)
{
int n;
printf(';Enter Number :';);
scanf(';%d';,%26amp;n);
PrintToZero(n);
return 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment