W Q-1
Coding Type Question
Ram wants to keep a profile picture on Gmail Gmail has some restriction over the
dimension of the picture that we can upload. The minimum dimension of the picture can
be Lx L, where L is the length of the side of the square.
Dimension of a photo is denoted as W x H, where W - width of the photo and H - Height of
the photo
When any photo is uploaded following events may occur:
1. If any of the width or height is less than L, the user is prompted to upload another one.
Print "CHANGE" in this case.
2. If width and height, both are large enough and
(a) if the photo is already square and size is L x L then it is accepted. Print "ACCEPTED"
in this case
(b) else user is prompted to crop it Print "CROP" in this case.
Input format
The input contains L and followed by two space-separated integers W and H in next line
Output format
Print appropriate text for each photo in a new line.
The output should be in Uppercase.
Code constraints
Answers
Answered by
15
Answer:
#include<stdio.h>
int main()
{
int l,w,h;
scanf("%d %d %d",&l,&w,&h);
if((w<l)||(h<l))
{
printf("CHANGE");
}
else if(w==h)
printf("ACCEPTED");
else
printf("CROP");
return 0;
}
Answered by
0
The code to execute the given task in C++ is as follows:
#include <iostream>
using namespace std;
int main()
{
int L;
cin >> L;
int W; int H;
cin >> W;
cin >> H;
if((W < L) || (H < L))
cout << "CHANGE";
else {
if((W == L) && (H == L))
cout << "ACCEPTED";
else
cout << "CROP";
}
return 0;
}
- First, we declare the variables L, W and H.
- Next, we take input from the user in these variables L, W and H.
- Next, we use the concept of if-else and nested if-else for checking W and H with L and print the output accordingly.
#SPJ3
Similar questions