Subscribe

RSS Feed (xml)

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;
}

2 comments:

  1. hello ..i'm just a beginner of this.. can u help me in my assignment.Write a C program to calculate the average of a set of grades and counting the number of failing test grades, the output are shown as following:-
    How many grades will you be entering? 7
    Enter grade #1 : 93
    Enter grade #2 : 63
    Enter grade #3 : 87
    Enter grade #4 : 65
    Enter grade #5 : 62
    Enter grade #6 : 88
    Enter grade #7 : 76
    Grade average = 76.29
    Number of failures = 2

    i hope u will help me.. thank u :)

    ReplyDelete
  2. did above program works ...........if a choose 1234 when at first step 1234/1000 will give and after that no will be 1 so1%10=1 after that 1+1 will be 2 but sum of 1234 is 5 so can u tell me how its program works...

    ReplyDelete