PROCEDURE:-
1.enter integer value n
2.repeat step 3 to 5 until n is greater than 0
3. find the modulo 10 for n and store result in r
4.print r
5. find new value of n by dividing it by 10
CODE:-
#include<stdio.h>
void main()
{
int n,r;
printf(“enter value for n”);
scanf(“%d”,&n);
while(n>0)
{
r=n%10;
printf(“%d”,r);
n=n/10;
}
}
Input:- enter value for n 124
Output:- 421
1.enter integer value n
2.repeat step 3 to 5 until n is greater than 0
3. find the modulo 10 for n and store result in r
4.print r
5. find new value of n by dividing it by 10
CODE:-
#include<stdio.h>
void main()
{
int n,r;
printf(“enter value for n”);
scanf(“%d”,&n);
while(n>0)
{
r=n%10;
printf(“%d”,r);
n=n/10;
}
}
Input:- enter value for n 124
Output:- 421
Comments
Post a Comment