

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


/In the very first step of program,the library will be included which will contain necessary information of commands i used in the program./
#include<stdio.h>
/second step is the declaration ,that main function of the program is integer type function/
int main()
/the program is written in the middle brackets{}/
{
/it is the declaration that variables are of which type/
char a,b,c,d,e; int add,f,g,h,i,j,rev;
/topic of program/
printf("TO REVERSE THE 5 DIGIT NO. AND TO FIND THE SUM OF ITS DIGITS\n\n\n ");
/by this printf command user will be able to know that he has to enter input here/
printf ("please input a 5 digit number\n"); scanf("%c%c%c%c%c",&a,&b,&c,&d,&e);
/in the following 5 steps the integers f,g,h,i,j will store the digits of 5digit number separately/
f=a-48; g=b-48; h=c-48; i=d-48; j=e-48;
rev=(j10000)+(i1000)+(h100)+(g10)+(f);
/here the reverse of input will be displayed/
printf("Reverse number is= %d\n",rev);
/following step will add up all the digits included in input/
add=f+g+h+i+j;
/here the sum of digits will be displayed as output/
printf("sum of digits of given number=%d\n",add);
return 0;
/the following bracket will indicate the termination of program and it is paired with the first bracket/
}