GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming

 Print  |  
Question:  Write a program to read a four digit integer and print the sum of its digits.

Write a program that reads a floating point number and then displays the right-most digit of the integral part of the number.




November 11, 2007 12:28:10 #1
 sarathi trichy   Member Since: October 2007    Total Comments: 14 

RE: Write a program to read a four digit integer and print the sum of its digits.Write a program that reads a floating point number and then displays the right-most digit of the integral part of the number.
 

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,z,k=0;
clrscr();
printf("enter the number");
scanf("%d",&x);
while(x>0)
{
y=x%10;
k=k+y;
x=x/10;
}
printf("%d",k);

getch();
}
 

     

 

Back To Question