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 |
Is struct oop?
How is a two dimensional array passed to function when the order of matrix is not known at complie time?
Why c is called procedure oriented language?
Tell about strtok & strstr functions
2 Answers HCL, iFlex, Motorola,
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
write a progam to compare the string using switch case?
what will be the output for the following program? main() { char ch = 'k'; char c; printf("%c",c); }
What is #line in c?
Explain #pragma statements.
What is binary tree in c?
What is the purpose of clrscr () printf () and getch ()?
size maximum allocated by calloc()