How to write a C Program to Sum of First and Last Digits of a Four-Digit number in C Programming Language ?
Solution:
This program is based on the "sum of digits" program discussed previously.
This program also has some usage of the Modulus Operator.
This program also has some usage of the Modulus Operator.
If a four-digit number is input through the keyboard,
write a program to obtain the sum of the first and the last digit of this number.
write a program to obtain the sum of the first and the last digit of this number.
/*HINT: If a number is divided using % , then the number to the right side of the decimal point is the result. (This applies only to integers.) */
#include<stdio.h> main () { int number, last_digit, first_digit, total; printf (" Enter the number which is to be operated on: "); scanf ("%d", &number); last_digit = number % 10; total = last_digit; first_digit = (number / 1000) % 10; total = total + first_digit; printf ("The total of the first and the last digit of the entered number is: %d", total); }
Learn More :
Digit
- C Program To Find Reverse Of Any Digit Number
- C Program To Print Sum Of n Digit Number
- C Program To Add Digits Of Entered Number
- C Program Anagrams
- C Program to Sum of The First and Last Digit Of 'n' Digit Number
- C Program to Sum of digits of a Five Digit Number
- C Program to Reversing a Five Digit Integer Number
- C Program to Sum Up Digits Of A Number
- Input Number and Calculate Sum of it's Digits C Program
First
Last
Sum
- Write the procedure , which is one of a sum , a product and a geometric average in the panel for the NxM elements are located on opposite diagonal and main diagonal . Remind ! Counting only odd elements !
- C Program To Find Sum and Difference Of Two Matrices
- C Program To Print Sum Of n Digit Number
- C Program Finding the sum of Squares using Recursion
- Give me an integer and I will sum it with the previous natural numbers
- C Program to Sum of The First and Last Digit Of 'n' Digit Number
- C Program to Sum of digits of a Five Digit Number
- C Program to Sum Up Digits Of A Number
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of non-diagonal element in m*n matrix C Program
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation
- Menu Driven Program to Read Two Integers Find Sum, Difference and Product C Program
- Input Number and Calculate Sum of it's Digits C Program
Number
- Find out the perfect number using c program
- Write a c program to find out H.C.F. of two numbers.
- Check the given number is armstrong number or not using c program.
- Write a c program to find largest among three numbers using conditional operator
- FIND OUT GENERIC ROOT OF A NUMBER - C PROGRAM.
- FIND PRIME FACTORS OF A NUMBER USING C PROGRAM
- How To Write a C program that generates two random numbers ?
- Write a C program to find maximum or equal between two numbers ?
- How to Write a C program to find maximum between two numbers ?
- Write a C program to perform math operations on two input whole numbers. The operations are:
- Write a C program to find maximum between three numbers ?
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program to Enter an ODD number between 1 and 49.
- C program acquires keyboard 10 numbers for each of these numbers to determine if it is a first issue, by printing immediately message should at the end, if none of the numbers you entered was a first issue, print an appropriate message.
- C program generates a random number and uses an algorithm to generate 9 other numbers.
- C Program to Find Random Number
- C Program To Find LCM and HCF Of Two Number Using Function - 2
- C Program to find LCM and HCF Of Two Number Using Recursion - 3
- C Program To Find LCM and HCF Of Two Number -1
- C Program To Find Reverse Of Any Digit Number
- C Program To Find The Frequency Of A Number
- C Program To Print Prime Numbers Upto The Number You Want
- C Program To Print Sum Of n Digit Number
- C Program To Reverse A Number
- C Program To Search A Number Inside The Array