Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future (without quotes). Else, if givenYear is 2001 or greater (2001-2100), print "21st century". Else, if givenYear is 1901 or greater (1901-2000), print 20th century". Else (1900 or earlier), print Long ago'. Do NOT end with newline. 1 #include 3 int main(void) {4 int givenYear; 6 givenYea r = 1776; 8 Your solution goes here return 0;}

Respuesta :

Answer:

//Program was implemented using C++ Programming Language

// Comments are used for explanatory purpose

#include<iostream>

using namespace std;

int main()

{

int givenYear; // Declare givenYear as integer

cout<<"Enter a Given Year: "; // Prompt telling the user to enter any year

cin>>givenYear; // This line accepts input for variable givenYear

// Check if givenYear is greater than or equal to 2101

if(givenYear >= 2101)

{

cout<<"Distant Future";

}

// Check if givenYear is greater than or equal to 2001 but less than 2101

else if(givenYear >= 2001)

{

cout<<"21st Century";

}

// Check if givenYear is greater than or equal to 1901 but less than 2001

else if(givenYear >= 1901)

{

cout<<"20th Century";

}

// Check if givenYear is less than 1901

else

{

cout<<"Long ago";

}

return 0;

}

Explanation: