write a program to gat the digt sum of a number (et. 15=
>1+5=6)
Answers were Sorted based on User's Feedback
Answer / sagarsp2010
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,sum=0,no;
clrscr();
printf("ENTER THE NO. OF TERMS:");
scanf("%d",&n);
for (i=1;i<=5;i++)
{
no=n%10;
sum=sum+no;
n=n/10;
}
printf("sum=%d",sum);
getch();
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / santhosh kumar
#include<stdio.h>
#include<string.h>
int main ()
{
char no[100];
char num[2];
int i;
int length = 0;
int sum = 0;
memset(num, 0, 2);
printf("Enter the number: ");
gets(no);
length = strlen(no);
for(i=0; i<length; i++)
{
num[0] = no[i];
sum += atoi(num);
}
printf("Sum = %d", sum);
return 0;
}
| Is This Answer Correct ? | 2 Yes | 1 No |
For what purpose null pointer used?
How does #define work?
write a program to reverse the words in the sentence.NOTE:not reverse the entire string but just the occurance of each word
What is hashing in c language?
Is exit(status) truly equivalent to returning the same status from main?
write program on arrays
in iso what are the common technological language?
WRITE A C PROGRAM FOR PRINT "RHOMBUS" STRUCTURE . Example: Enter the numbers :3 * * * * * * * *
How do you view the path?
can any one tel me wt is the question pattern for NIC exam
which is the best site or book for learning C...and i need the content for C..how to get the good programming skills....? can plz suggest me....
How can you avoid including a header more than once?