-
March 9th, 2013, 01:16 AM
#1
Reversing the digits
//PROGRAM TO REVERSE THE 5 DIGIT NUMBER
#include <stdio.h>
void main()
{
int num, i = 0;
char rev[5];
printf("Enter any 5 digit number\n");
scanf("%d", &num);
i = 0;
while(num)
{
rev[i] = num % 10;// IS THIS RIGHT WAY TO ASSIGN CHARACTER ARRAY?????
i++;
num = num/10;
}
printf("%s", rev);
}
What's wrong in the above program.
WHILE DISPLAYING i am not getting correct output. whats wrong in rev[] array.
PLEASE HELP!!!
TANUSHREE-AGRAWAL...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|