This is C Program to extract last two digits of a given year.
This program takes any year as input and prints its last two digits.
1. Take any year as input.
2. Divide the input by 100 and obtain its remainder.
3. The remainder got is the output.
Here is source code of the C Program to extract last two digits of a given year. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Extract Last two Digits of a given Year
int year, yr;
printf("Enter the year ");
yr = year % 100;
printf("Last two digits of year is: %02d", yr);
1. Take any year as input and store it in the variable year.
2. Divide the variable year by 100 and obtain its remainder. Store the remainder in the variable yr.
3. Print the variable yr as output.
Output: Enter the year 2012 Last two digits of year is: 12
Sanfoundry Global Education & Learning Series – 1000 C Programs.