0% found this document useful (0 votes)
9 views12 pages

Week 2 01

The document outlines a programming quiz for a course on C programming, detailing various questions that require writing programs to perform specific tasks such as converting height from feet and inches to centimeters, performing arithmetic operations on two integers, and calculating discounts on bakery items. Each question includes input and output formats, sample inputs and outputs, and the corresponding C code solutions. The quiz is structured to assess students' understanding of programming concepts and their ability to implement solutions in C.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views12 pages

Week 2 01

The document outlines a programming quiz for a course on C programming, detailing various questions that require writing programs to perform specific tasks such as converting height from feet and inches to centimeters, performing arithmetic operations on two integers, and calculating discounts on bakery items. Each question includes input and output formats, sample inputs and outputs, and the corresponding C code solutions. The quiz is structured to assess students' understanding of programming concepts and their ability to implement solutions in C.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

REC-CIS

GE23131-Programming Using C-2024


Quiz navigation
Status Finished
1 2 3
Started Monday, 23 December 2024, 5:33 PM
Completed Saturday, 26 October 2024, 2:25 PM
Show one page at a time
Duration 58 days 3 hours
Finish review
Question 1 Many people think about their height in feet and inches, even in some countries that
Correct primarily use the metric system. Write a program that reads a number of feet from the
Marked out of user, followed by a number of inches. Once these values are read, your program should
3.00 compute and display the equivalent number of centimeters.
Flag question
Hint:
One foot is 12 inches.

One inch is 2.54 centimeters.

Input Format

First line,read the number of feet.

Second line, read the number of inches.


Output Format
In one line print the height in centimeters.
Note: All of the values should be displayed using two decimal places.
Sample Input 1
56
Sample Output 1
167.64
REC-CIS

Answer: (penalty regime: 0 %)


1 #include<stdio.h>
2 int main()
3 ▼ {
4 int a,b;
5 float c,d;
6 scanf("%d",&a);
7 scanf("%d",&b);
8 c=a*2.54*12;
9 d=b*2.54;
10 printf( "%.2f",c+d);
11 return 0;
12 }

Input Expected Got

 5 167.64 167.64 
6

Passed all tests! 

Question 2
Create a program that reads two integers, a and b, from the user. Your program should
Correct compute and display: • The sum of a and b • The difference when b is subtracted from
Marked out of a • The product of a and b • The quotient when a is divided by b • The remainder when
REC-CIS 5.00
a is divided by b
Flag question
Input Format

First line, read the first number.

Second line, read the second number.

Output Format

First line, print the sum of a and b

Second line, print the difference when b is subtracted from a

Third line, print the product of a and b

Fourth line, print the quotient when a is divided by b

Fifth line, print the remainder when a is divided by b

Sample

Input 1 100 6

Sample Output
106 94 600 16 4

Answer: (penalty regime: 0 %)


1 #include<stdio.h>
2 int main()
3 ▼ {
4 int a,b,c,d,e,f,g;
5 scanf("%d",&a);
6 scanf("%d",&b);
7 c=a+b;
8 d=a-b;
9 e=a*b;
10 f=a/b;
11 g=a%b;
12 printf("%d \n%d \n%d \n%d \n%d",c,d,e,f,g);
13 return 0;
14
15 }
REC-CIS

Input Expected Got

 100 106 106 


6 94 94
600 600
16 16
4 4

Passed all tests! 

Question 3
A bakery sells loaves of bread for $3.49 each. Day old bread is discounted by 60
Correct percent. Write a program that begins by reading the number of loaves of day old
Marked out of bread being purchased from the user. Then your program should display the regular
7.00 price for the bread, the discount because it is a day old, and the total price. Each of
Flag question these amounts should be displayed on its own line with an appropriate label. All of the
values should be displayed using two decimal places.

Input Format

Read the number of day old loaves.

Output Format

First line, print Regular price: price

Second line, print Discount: discount


Third line, print Total: total

Note: All of the values should be displayed using two decimal places.

Sample Input 1
10
REC-CIS
Sample Output 1

Regular price: 34.90

Discount: 20.94

Total: 13.96

Answer: (penalty regime: 0 %)


1 #include<stdio.h>
2 int main()
3 ▼ {
4 int a;
5 float b,c,d;
6 scanf("%d",&a);
7 b=3.49*a;
8 c=60*3.49*a/100;
9 d=b-c;
10 printf("Regular price: %.2f",b);
11 printf("\nDiscount: %.2f",c);
12 printf("\nTotal: %.2f",d);
13 return 0;
14
15 }

Input Expected Got

 10 Regular price: 34.90 Regular price: 34.90 


Discount: 20.94 Discount: 20.94
Total: 13.96 Total: 13.96
Passed all tests! 
REC-CIS

Finish review
REC-CIS

GE23131-Programming Using C-2024


Quiz navigation
Status Finished
1 2 3
Started Monday, 23 December 2024, 5:33 PM
Completed Saturday, 26 October 2024, 2:53 PM
Show one page at a time
Duration 58 days 2 hours
Finish review
Question 1 Goki recently had a breakup, so he wants to have some more friends in his life. Goki
Correct has N people who he can be friends with, so he decides to choose among them
Marked out of according to their skills set Yi(1<=i<=n). He wants atleast X skills in his friends. Help
3.00 Goki find his friends. ________________________________________
Flag question
INPUT
First line contains a single integer X - denoting the minimum skill required to be Goki's
friend. Next line contains one integer Y - denoting the skill of the person

. ________________________________________

OUTPUT

Print if he can be friend with Goki. 'YES' (without quotes) if he can be friends with Goki
else 'NO' (without quotes).

________________________________________

CONSTRAINTS

1<=N<=1000000

1<=X,Y<=1000000

SAMPLE INPUT 1

100 110
SAMPLE OUTPUT 1
REC-CIS
YES

SAMPLE INPUT 2

100 90

SAMPLE OUTPUT 2

NO

Answer: (penalty regime: 0 %)


1 #include<stdio.h>
2 int main()
3 ▼ {
4 int X,Y;
5 scanf("%d %d",&X,&Y);
6 if(X<=Y)
7 ▼ {
8 printf("YES");
9
10 }
11 else
12 ▼ {
13 printf("NO");
14 }
15 return 0;
16 }

Input Expected Got

 100 YES YES 


110
 100 NO NO 
REC-CIS
90

Passed all tests! 

Question 2
Before the outbreak of corona virus to the world, a meeting happened in a room in
Correct Wuhan. A person who attended that meeting had COVID-19 and no one in the room
Marked out of knew about it! So everyone started shaking hands with everyone else in the room as a
5.00 gesture of respect and after meeting unfortunately everyone got infected! Given the
Flag question fact that any two persons shake hand exactly once, Can you tell the total count of
handshakes happened in that meeting? Say no to shakehands. Regularly wash your
hands. Stay Safe.

Input Format

Read an integer N,the total number of people attended that meeting.

Output Format
Print the number of handshakes.
Constraints

0 < N < 106

SAMPLE INPUT 1

SAMPLE OUTPUT

SAMPLE INPUT 2

SAMPLE OUTPUT 2

Explanation Case 1: The lonely board member shakes no hands, hence 0. Case 2: There
are 2 board members, 1 handshake takes place.
Answer: (penalty regime: 0 %)
REC-CIS
1 #include<stdio.h>
2 int main()
3 ▼ {
4 int n;
5 scanf("%d",&n);
6 n-=1;
7 printf("%d",n*(n+1)/2);
8 return 0;
9 }

Input Expected Got

 1 0 0 

 2 1 1 

Passed all tests! 

Question 3 In our school days, all of us have enjoyed the Games period. Raghav loves to play
Correct cricket and is Captain of his team. He always wanted to win all cricket matches. But only
Marked out of one last Games period is left in school now. After that he will pass out from school. So,
7.00
Flag question this match is very important to him. He does not want to lose it. So he has done a lot
REC-CIS
of planning to make sure his teams wins. He is worried about only one opponent -
Jatin, who is very good batsman. Raghav has figured out 3 types of bowling
techniques, that could be most beneficial for dismissing Jatin. He has given points to
each of the 3 techniques. You need to tell him which is the maximum point value, so
that Raghav can select best technique. 3 numbers are given in input. Output the
maximum of these numbers.

Input:

Three space separated integers.


Output:

Maximum integer value

SAMPLE INPUT

861

SAMPLE OUTPUT

Explanation Out of given numbers, 8 is maximum.

Answer: (penalty regime: 0 %)


1 #include<stdio.h>
2 int main()
3 ▼ {
4 int a,b,c;
5 scanf("%d %d %d",&a,&b,&c);
6 if(a>b && a>c)
7 ▼ {
8 printf("%d",a);
9 }
10 else if(b>c)
11 ▼ {
12 printf("%d",b);
13 }
14 else
15 ▼ {
16 printf("%d",c);
17 }
18 return 0;
19 }
REC-CIS

Input Expected Got

 81 26 15 81 81 

Passed all tests! 

Finish review

You might also like