Program to find sum of a digit

/* Program sum of digit */

#include<stdio.h>

#include<conio.h>

void main()

{

int n,digit, n1,sum=0;

clrscr();

printf(“Enter the Any Integer No: “);

scanf(“%d”,&n);

n1=n;

while(n!=0)

{

digit = n%10;

sum+= digit;

n/=10;

}

printf(“number is    = %d :\n”,n1);

printf(“Sum of digit = %d :”,sum);

getch();

}

 

resume

Mohit Arora
Follow me