The Program in C++ to Convert a Given Year to Century is given below:
#include <iostream>
using namespace std;
int main() {
int year;
cout << "Enter a year: ";
cin >> year;
int century = (year - 1) / 100 + 1;
cout << "Century: " << century << endl;
return 0;
}
Output:
Hello Codeauri Family,Enter a year here to know the century: 3040
Hmm, the Century : 31
Pro-Tips💡
This program takes a year as input and calculates the century by dividing the year by 100 and adding 1 to the result.
The result is then displayed using the cout
statement.
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.