Some Basic C program frequently asked in Interview.
/* Program to find sum of digit of a number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,s=0;
clrscr();
printf("Enter a number:\t");
scanf("%d",&a);
while(a>0)
{
b=a%10;
s=s+b;
a=a/10;
}
printf("Sum of digit is %d",s);
getch();
}
No comments:
Post a Comment