C program to get last two digits of year





C program to extract last two digits of a given year and print it

#include<stdio.h>
int main(){
  int yyyy,yy;

  printf("Enter a year in for digits: ");
  scanf("%d",&yyyy);

  yy = yyyy % 100;
  printf("Last two digits of year is: %02d",yy);

  return 0;
}


Sample Output:
Enter a year in for digits: 1985
Last two digits of year is: 85



Alogrithm:







1. Write a c program to convert decimal number to hexadecimal number.
3. Write a c program to convert octal number to decimal number.
4. Write a c program to convert octal number to hexadecimal number.
5. Write a c program to convert hexadecimal number to decimal number.
6. Write a c program to convert hexadecimal number to octal number.
8. Write a c program to convert binary number to hexadecimal number.
9. Write a c program to convert binary number to octal number.
11. Write a c program to convert hexadecimal number to binary number.
12. Write a c program to convert octal number to binary number.
14. Write a c program to convert centigrade to fahrenheit.

1 comment:

Unknown said...

it doesnt work for years like 1901