Thursday 9 January 2014

HOW TO GET SUM OF DIGIT FOR GIVEN VALUE IN C

#include<stdio.h>
void main()
{
int no,m,sum;
clrscr();
sum=0;
printf("\tenter your value for get sum of digit");
scanf("%d",&no);
while(no>0)
{
m=no%10;
sum=sum+m;
no=no/10;
}
printf("\tsum of your value%d",sum);
getch();
}

No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...