47 C Program to Extract Last two Digits of a given Year
Posted by Superadmin on December 24 2015 02:13:03
This C Program extracts last two digits of a given year. Here usully year will be a 4 digit number where it has to display only last 2 digits from the given year.
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;
}

Output:
$ cc pgm34.c
$ a.out
Enter the year 2012
Last two digits of year is: 12