Tuesday, July 21, 2009

Write a c program to obtain the Sum of the first and last digit of the number, if a four digit number is inputted through the keyboard

/* Program to obtain the Sum of first and last digit of the number without using loops*/
#include(stdio.h)
#include(conio.h)
int main( )
{
int no, sum, first, last;
clrscr( );
printf("Enter the required four digit number");
scanf("%d", &no);
first = no/1000;
last= no%10;
sum= first + last;
printf("\n Sum of first and last digit : %d", sum);
getch( );
return 0;
}

No comments:

Post a Comment