Problem Statement
Read a decimal integer from the keyboard (It may be negative or positive). Print it in reverse order including its sign
Read a decimal integer from the keyboard (It may be negative or positive). Print it in reverse order including its sign
#include<stdio.h>
int main()
{
int n;
printf("enter the number \n");
scanf("%d",&n);
if(n<0)
{
printf("-");
n=(-n);
}
while(n>=1)
{
printf("%d",n%10);
n=n/10;
}
printf("\n");
return 0;
}
No comments:
Post a Comment