Answer Posted / vani
//sum of digits in c//
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,sum=0;
clrscr();
printf("\n enter the number:");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("sum=%d");
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can you please explain the difference between malloc() and calloc() function?
Why should I prototype a function?
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
What is a c token and types of c tokens?
What is the significance of c program algorithms?
Explain what is the general form of a c program?
What are dangling pointers? How are dangling pointers different from memory leaks?
How arrays can be passed to a user defined function
Explain the difference between null pointer and void pointer.
In a header file whether functions are declared or defined?
What is an array in c?
What is cohesion in c?
What are the different file extensions involved when programming in C?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
What is the purpose of & in scanf?