if a five digit number is input through the keyboard, write
a program to calculate the sum of its digits.
(hint:-use the modulus operator.'%')

Answers were Sorted based on User's Feedback



if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / pavan kumar

#include<stdio.h>
int main()
{
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,sum;
printf("Enter the five digit number:");
scanf("%d",&sum);
a=sum%10;
b=sum/10;
c=b%10;
d=b/10;
e=d%10;
f=d/10;
g=f%10;
h=f/10;
printf("sum of the digits:%d",a+c+e+g+h);
}

Is This Answer Correct ?    7 Yes 4 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / amit amar mahesh bhava

#include<sthio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,g,h,i,j,k,l;
printf("enter a five digit number");
scanf("%d",&a);
b=a%10;
c=a/10;
d=c%10;
e=c/10;
f=e%10;
g=e/10;
h=g%10;
i=g/10;
j=i%10;
k=i/10;
l=b+d+f+h+j;
printf("sum of the digit=%d",l);
getch();
}

Is This Answer Correct ?    7 Yes 5 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / nishant rai

#include<stdio.h>
#include<conio.h>
void main()
{
int num=0,sum=0,k=0;
pirntf("enter the number\n");
scanf("%d",num);
while(num!=0);
{
k=num%10;
sum=sum+k;
num=num/10;
}
printf("%d",sum);
getch();
}

Is This Answer Correct ?    13 Yes 14 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / thamizharasan

#include"stdio.h"
main ()
{
int number, last_digit, next_digit, total;
printf ("Enter the number whose sum of digits is to be calculated: ");
scanf ("%d", &number);
last_digit = number%10;
total = last_digit;
next_digit = (number/10) % 10;
total = total + next_digit;
next_digit = (number/100) % 10;
total = total + next_digit;
next_digit = (number/1000) %10;
total = total + next_digit;
next_digit = (number/10000) %10;
total = total + next_digit;
printf ("The sum of the digits of the entered number is: %d", total);
}

Is This Answer Correct ?    3 Yes 4 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / aryan garg

#include<stdio.h>
int main()
{
int n,d1,d2,d3,d4,d5,s;
printf("enter a five digit no");
scanf("%d",&n);
d5=n%10;n=n/10;
d4=n%10;n=n/10;
d3=n%10;n=n/10;
d2=n%10;n=n/10;
d1=n%10;
s=d1+d2+d3+d4+d5;
printf("sum of the digits of number is : %d",s);
return 0;
}

Is This Answer Correct ?    0 Yes 2 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / jegadeesh

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
scanf("%d",&i);
if((i%9)==0)
printf("The sum of digit is 9");
else
{
j=i%9;
printf("%d",j);
}
}

Is This Answer Correct ?    29 Yes 33 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,m1,s=0,d,sum;
printf("\nEnter the number ");
scanf("%d",&n);
m=n%10;
d=n/10;
while(d>=10)
{
m1=d%10;
d=d/10;
s =s+m1;
}
sum=s+m+d;
printf("\nSum is %d",sum);
getch();
}

Is This Answer Correct ?    13 Yes 17 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / revanth kumar.p

include<stdio.h>
#include<conio.h>
int main()
{
int num,len = 1,a,b;
printf("Enter a number");
scanf("%d",&num);
while(num >= 10)
{
num = num/10;
len++;
}
printf("%d",len);
a=len;
a=len*(len+1)%2;
printf("\n%d",a);
b=len;
b=len*(len+1)/2;
printf("\n%d",b);
a=a+b;
printf("\n%d",a);


getch();

}

Is This Answer Correct ?    4 Yes 9 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / saurabh vyas

main()
{
int num=0,sum=0,k=0;
pirntf("enter the number\n");
scanf("%d",&num);
while(num!=0);
{
k=num%10;
sum=sum+k;
num=num/10;
}
printf("%d",sum);
}

Is This Answer Correct ?    4 Yes 9 No

if a five digit number is input through the keyboard, write a program to calculate the sum of its d..

Answer / rajrartan singh

#include<stdio.h>
#include<conio.h>
void main();
{
int n,d1,d2,d3,d4,d5,sum;
ptintf("enter the five digit no.");
scanf("d",&n);
s=d1+d2+d3+d4+d5;
getch();
}

Is This Answer Correct ?    4 Yes 10 No

Post New Answer

More C Interview Questions

write a programming in c to find the sum of all elements in an array through function.

0 Answers  


how to construct a simulator keeping the logical boolean gates in c

0 Answers  


What is c method?

0 Answers  


What is difference between union and structure in c?

0 Answers  


Write a program to give following output..... ********* **** **** *** *** ** ** * * ** ** *** *** **** **** *********

4 Answers  






what are bps & baud rates? differentiate these two?

2 Answers   TCS,


Tell me the use of bit field in c language?

0 Answers  


what is pointer?

13 Answers   HCL, TCS,


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

0 Answers  


What is your stream meaning?

0 Answers  


What is bss in c?

0 Answers  


how can we use static and extern?and where can we use this?

3 Answers   Excel,


Categories