Answer Posted / rakesh ranjan
#include<conio.h>
#include<stdio.h>
main()
{
int x=0,n,i;
printf("entre the number");
scanf("%d",&n);
for(;n>0;n/=10)
x=x+n%10;
printf("sum = %d",x);
getch();
}
Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
How to draw the flowchart for structure programs?
What are c header files?
What does sizeof return c?
What are local static variables?
What are the benefits of c language?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
What is bss in c?
how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12
What is static memory allocation? Explain
Explain how can you restore a redirected standard stream?
What does 3 periods mean in texting?
What is a char in c?
Why pointers are used in c?