Wednesday, August 17, 2011

QUES 10 REVERSE NO AND PRINT ITS SUM


C LANGUAGE BOOK





 WAP  TO PROGRAM TO REVERSE THE NUMBER AND TO CALCULATE THE SUM

#include<stdio.h>
#include<conio.h>
void main()
{
int num,x;
float sum=0;
clrscr(); //CLEARS THE OUTPUT SCREEN
printf("enter a number");
scanf("%d",&num);
while(num!=0)
    {
        x=num%10;   //CALCULATES THE REVERSE OF NUMBER
        num=num/10;
        printf("%d",x);
        sum=sum+x;  //CALCULATES THE SUM
    }
printf("sum=%f",sum);
getch();












C LANGUAGE BOOK

No comments:

Post a Comment