In: Computer Science
Write a program that reads in a single integer.
Display a message depending on what is given:
One example shown below with the user input highlighted:
Give a number: 2020 2020 is the current year. |
|
C CODE:
#include <stdio.h>
int main() {
int num;
printf("Give a number: ");
scanf("%d", &num);
if(num == 42)
printf("%d is the Ultimate Question of Life, the Universe, and Everything.", num);
else if(num == 2020)
printf("%d is the current year.", num);
else if(num> 1000 && num<3000)
printf("%d could be a year.", num);
else
printf("no idea.");
return 0;
}
Screenshots: