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
*/
#include <stdio.h>
int main()
{
int year, yr;
printf("Enter the year ");
scanf("%d", &year);
yr = year % 100;
printf("Last two digits of year is: %02d", yr);
return 0;
}
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.
Here’s the list of Best Books in C Programming, Data-Structures and Algorithms
- Watch Advanced C Programming Videos
- Check C Books
- Practice BCA MCQs
- Apply for C Internship
- Check Computer Science Books