Users Online
· Guests Online: 127
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
47 C Program to Extract Last two Digits of a given Year
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
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
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.