google407ec42f1ae5ff0e.html
top of page

Program to print the sum of digits of any number

Writer's picture: Yatendra AwanaYatendra Awana

Program to print the sum of digits of any number

#include<stdio.h>

void main()

{

int a,sum=0,rem;

printf("Enter a number : ");

scanf("%d",&a);

while(a>0)

{

rem = a%10; /*taking last digit of n*/

sum+=rem;

a/=10; /*skipping last digit of n*/

}

printf("Sum of digits=%d\n",sum);

getch();

}



5 views0 comments

Recent Posts

See All

留言


Facilities-:
One to one  online  / Offline Class
Individual training 
Corporate Training
E-Certificate for each course
Life time video accessible
E-Books

About us-:
Fin Computer Class
Sector 107, Noida  U.P.
M-: 9871715299
E: fincomputerclass@gmail.com
W-: www.computerclass.co.in
W-: www.it402.com
Y-:www.youtube.com/yka39

All Rights Reserved @ fin computer class     Design & Developed by Yatendra Kumar Awana

bottom of page