Write a c-programe that input one number of four digits and find digits sum?

Answers were Sorted based on User's Feedback



Write a c-programe that input one number of four digits and find digits sum?..

Answer / erdem

{
int num, sum ;
printf("Enter digit 1\n");
scanf("%d",num);
sum=sum+num;
for(i=1;i<4;i++)
{
printf("Enter digit %d\n",i);
scanf("%d",num);
sum=sum+num;
}
printf("the sum of digits is %d",sum);
getche();

Is This Answer Correct ?    6 Yes 1 No

Write a c-programe that input one number of four digits and find digits sum?..

Answer / greeshmaanair

{
int sum,digit1,digit2,digit3,digit4;
printf("enter the four digit number\n");
scanf("%d",digit1,digit2,digit3,digit4);
digit1=(digit1%1000)/10;
digit2=(digit2%1000)/10;
digit3=(digit3%1000)/10;
digit4=(digit4%1000)/10;
sum=digit1+digit2+digit3+digit4;
printf("the sum of digits is %d",sum);
return(0);
}

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More C C++ Errors Interview Questions

char* f() return "hello:"; void main() {char *str=f(); }

1 Answers  


which typw of errors ? & how to solve it ?

0 Answers  


Display this kind of output on screen. 1 0 1 1 0 1 3. Display this kind of output on screen. 1 1 0 1 0 1 4. Display this kind of output on screen. 1 1 0 1 0 1 5.Display this kind of output on screen. 1 2 3 4 5 6 7 8 9 10

1 Answers  


what is meant for variable not found?

3 Answers  


write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;

0 Answers  






Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,


Write a c-programe that input one number of four digits and find digits sum?

2 Answers  


errors are known as?

3 Answers   EX, State Bank Of India SBI,


#include<>stdio.h> #include<>conio.h> { printf("hello"); void main() getch(); } what the out put of this program and why ......plz clear my answer

10 Answers   Wipro,


main() { char c; for(c='A';c<='Z';c++) getch(); }

9 Answers  


void main() { int i=7; printf("N= %*d",i,i); }

6 Answers   HCL,


difference between c/c++ programing language? what is necessesity of c++ when existing c programing language?

2 Answers   TCS,


Categories