Print Century

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

5/30/2021 https://www.skillrack.com/faces/candidate/codeprogram.

xhtml

C - Logical Operators, Switch and Nested If Else - PART003

Solved Challenges 3/10

Back To Challenges List



Print Century

ID:6647 Solved By 2073 Users

The program must accept two integers X and Y as the input. The program must print the output based on the below conditions,

- If both X and Y are greater than or equal to 100 print XYCENTURY


- If X is greater than or equal to 100 and Y is more than 50 print XCENTURY
- If Y is greater than or equal to 100 and X is more than 50 print YCENTURY
- If X is greater than or equal to 100 and Y is less than 50 print XCENTURYSMALLY
- If Y is greater than or equal to 100 and X is less than 50 print YCENTURYSMALLX
- If X is greater than or equal to 100 and Y is equal to 50 print YHALFCENTURY
- If Y is greater than or equal to 100 and X is equal to 50 print XHALFCENTURY

Example Input/Output 1:
Input:
120 50

Output:
YHALFCENTURY

Example Input/Output 2:
Input:
90 100

Output:
YCENTURY

Max Execution Time Limit: 2000 millisecs

https://www.skillrack.com/faces/candidate/codeprogram.xhtml 1/4
5/30/2021 https://www.skillrack.com/faces/candidate/codeprogram.xhtml

Ambiance

C ( gcc 8.x) 

Reset

https://www.skillrack.com/faces/candidate/codeprogram.xhtml 2/4
5/30/2021 https://www.skillrack.com/faces/candidate/codeprogram.xhtml

1 #include<stdio.h>
2 #include<stdlib.h>
3
4 int main()
5 {
6 int x,y;
7 scanf("%d %d",&x,&y);
8 if (x>=100 && y>=100)
9 {
10 printf("XYCENTURY");
11 }
12 else if (x>=100 && y>50)
13 {
14 printf("XCENTURY");
15 }
16 else if (y>=100 && x>50)
17 {
18 printf("YCENTURY");
19 }
20 else if (x>=100 && y<50)
21 {
22 printf("XCENTURYSMALLY");
23 }
24 else if (y>=100 && x<50)
25 {
26 printf("YCENTURYSMALLX");
27 }
28 else if (x>=100 && y==50)
29 {
30 printf("YHALFCENTURY");
31 }
32 else
33 {
34 printf("XHALFCENTURY");
35 }
36 return 0;
37 }

https://www.skillrack.com/faces/candidate/codeprogram.xhtml 3/4
5/30/2021 https://www.skillrack.com/faces/candidate/codeprogram.xhtml

Save Run

Run with a custom test case (Input/Output)

https://www.skillrack.com/faces/candidate/codeprogram.xhtml 4/4

You might also like