Program:
#include<stdio.h>
//#include<conio.h>
void main()
{
int r=0,n,sum=0,d;
printf("Enter the number:");
scanf("%d",&n);
while(n>0)
{
d=n%10;
sum=sum+d;
r=(r*10)+d;
n=n/10;
}
printf("\n sum of digits= %d",sum);
printf("\n Reverse=%d",r);
printf("\n");
//getch();
}
Output:
nn@linuxmint ~ $ gcc c24.c
nn@linuxmint ~ $ ./a.out
Enter the number:15
sum of digits= 6
Reverse=51
nn@linuxmint ~ $
#include<stdio.h>
//#include<conio.h>
void main()
{
int r=0,n,sum=0,d;
printf("Enter the number:");
scanf("%d",&n);
while(n>0)
{
d=n%10;
sum=sum+d;
r=(r*10)+d;
n=n/10;
}
printf("\n sum of digits= %d",sum);
printf("\n Reverse=%d",r);
printf("\n");
//getch();
}
Output:
nn@linuxmint ~ $ gcc c24.c
nn@linuxmint ~ $ ./a.out
Enter the number:15
sum of digits= 6
Reverse=51
nn@linuxmint ~ $
C++ Program to Reverse a Number
ReplyDeleteReverse of number means reverse the position of all digits of any number. For example reverse of 536 is 635
Reverse Number Program in C
ReplyDeleteThanks sir
thk you so much
ReplyDeleteEnrich your knowledge in web development with our Best Mern Stack Course In South Delhi , where we provide a comprehensive understanding of the MERN technology, empowering you for success.
ReplyDelete