You are on page 1of 45

Question 1: Maximum Number

Problem Statement:
You are provided with three numbers n1,n2 and n3 and you have to find the
maximum out of these three numbers?

Input Format:
The first line contains three numbers n1,n2 and n3.

Output Format:
Print the maximum number.

Constraints:
1 <=n1,n2,n3 <= 1000

Example
Sample Input
10 20 15

Sample Output
20

Sample Test Case Explanation


In a sample test case, the maximum number is 20 out of 10,20 and 15.

Default Code
#include <stdio.h>
int main()
{

return 0;
}

SOLUTION:

#include <stdio.h>
int main()
{
int num1, num2, num3, max;
scanf("%d%d%d", &num1, &num2, &num3);

if(num1 > num2)


{
if(num1 > num3)
{
max = num1;
}
else
{
max = num3;
}
}
else
{
if(num2 > num3)
{
max = num2;
}
else
{
max = num3;
}
}

printf("%d", max);

return 0;
}

Test case 1 Test case 2 Test case Test case 4


3
Input Input Input Input
72 45 67 899 388 432 456 123 53 999 56 78
Output Output Output Output
72 899 456 999

Question 2: Play with Square

Problem Statement:
You are provided with a side of the square and you have to calculate the area and
perimeter of the square.

Input Format:
The first line of the input contains the side of the square.

Output Format:
Print the area and perimeter of the square.

Constraints:
1 <= s <= 1000

Example
Sample Input
50

Sample Output
2500
200

Sample Test Case Explanation


In a sample test case, the area is 2500 and the perimeter is 200.

Default Code
#include <stdio.h>
int main()
{

return 0;
}

SOLUTION:
#include <stdio.h>
int main()
{
int side;
scanf("%d%d",&side);

int area = side*side;


printf("%d\n",area);

int perimeter = 4*side;


printf("%d\n", perimeter);

return 0;
}

Test case 1 Test case 2 Test case 3 Test case 4


Input Input Input Input
72 899 456 999

Output Output Output Output


5184 808201 207936 998001
288 3596 1824 3996

CODING QUESTION (10 MARK QUESTION)


Question 3: Number Puzzle

Problem Statement:
You are provided with a 4-digit number and you have to add 8 to the number and
then divide it by 3. Now, the modulus of that number is taken with 5 and then multiply
the resultant value by 5 and have to print the final result.

Input Format:
The first line of the input contains the four-digit number.

Output Format:
Print the final result.

Constraints:
1000 <= four-digit number <= 10000

Example
Sample Input
2345

Sample Output
20

Default Code
#include <stdio.h>
int main()
{

return 0;
}

SOLUTION:

#include <stdio.h>
int main()
{
int num;
scanf("%d",&num);

int ans= (((8+num)/3)%5)*5;


printf("%d",ans);

return 0;
}
Test case 1 Test case 2 Test case 3 Test case 4
Input Input Input Input
7245 2993 4561 9995

Output Output Output Output


10 0 15 20

Question 1: Number Checking

Problem Statement:
You are provided with two numbers and you have to check that if the number is equal,
greater or smaller. If numbers are equal print ”Numbers are equal” else print ”Number 1 is
greater than Number 2”else ”Number 2 is greater than Number 1” .

Input Format:
The first line contains two numbers n1 and n2.

Output Format:
Print the result.

Constraints:
1 <= n1,n2 <= 1000
Example
Sample Input
10 20

Sample Output
Number 2 is greater than Number 1

Sample Test Case Explanation


In a sample test case, 20 is greater than 10. so Number 2 is greater than Number 1.

Default Code
#include <stdio.h>
int main()
{

return 0;
}

SOLUTION:

#include <stdio.h>
int main()
{
int n1,n2;
scanf("%d%d",&n1,&n2);

if(n1==n2){
printf("Numbers are equal");
}
else if(n1>n2){
printf("Number 1 is greater than Number 2");
}
else{
printf("Number 2 is greater than Number 1");
}

return 0;
}

Test case 1 Test case 2 Test case 3 Test case 4


Input Input Input Input
72 45 899 388 456 896 999 999

Output Output Output Output


Number 1 is greater than Number 1 is greater than Number 2 is greater than Numbers are
Number 2 Number 2 Number 1 equal

Question 2: Character Puzzle


Problem Statement:
You are provided with a character ch and you have to check whether the given character is
an alphabet or not. If a given character is an alphabet then print ”Character is an
Alphabet” else print ”Character is not an Alphabet”.

Input Format:
The first line of the input contains a single character ch.

Output Format:
Print the required result accordingly.

Constraints:
A <= ch<= Z
a <= ch<= z

Example
Sample Input
a

Sample Output
Character is an Alphabet

Default Code
#include <stdio.h>
int main()
{
return 0;
}

SOLUTION:

#include <stdio.h>
int main()
{
char ch;
scanf("%c", &ch);

if((ch>= 'a' &&ch<= 'z') || (ch>= 'A' &&ch<= 'Z'))


{
printf("Character is an Alphabet");
}
else
{
printf("Character is not an Alphabet");
}

return 0;
}

Test case 1 Test case 2 Test case 3 Test case 4


Input Input Input Input
Z a A 7
Output Output Output Output
Character is an Character is an Character is an Character is not an
Alphabet Alphabet Alphabet Alphabet

CODING QUESTION (10 MARK QUESTION)

Question 3: Check Triangle

Problem Statement:
You are provided with three sides of the triangle s1,s2 and s3 and you have to check
whether the triangle is equilateral scalene, or isosceles?

Input Format:
The first line of the input contains three sides of the triangle s1,s2 and s3.

Output Format:
Print an “Equilateral triangle” if the triangle is equilateral and if it's isosceles print
”an Isosceles triangle” else print a ”Scalene triangle” if the triangle is scalene.

Constraints:
1 <= s1,s2,s3 <= 100

Example
Sample Input
444

Sample Output
Equilateral triangle

Default Code
#include <stdio.h>
int main()
{

return 0;
}
SOLUTION:

#include <stdio.h>
int main()
{
int s1,s2,s3;
scanf("%d%d%d", &s1,&s2,&s3);
if((s1==s2) && (s2==s3))
{
printf("\n Equilateral triangle\n");
}
else if((s1==s2) || (s1==s3) || (s2==s3))
{
printf("\n Isosceles triangle\n");
}
else
{
printf("\n Scalene triangle\n");
}
return 0;
}

Test case 1 Test case 2 Test case 3 Test case 4


Input Input Input Input
234 464 567 999
Output Output Output Output
Scalene Isosceles triangle Scalene triangle Equilateral triangle
triangle

Question 1: Maximum Between Two

Problem Statement:
You are provided with two numbers and you have to check to find out the maximum among
two.

Input Format:
The first line contains two numbers n1 and n2.

Output Format:
Print the maximum number.

Constraints:
1 <= n1,n2 <= 1000
Note: Maximum Number always exists.

Example
Sample Input
10 20

Sample Output
20

Sample Test Case Explanation


In a sample test case, 20 is greater than 10, so 20 is the maximum.

Default Code
#include <stdio.h>
int main()
{

return 0;
}
SOLUTION:

#include <stdio.h>
int main()
{
int n1,n2;
scanf("%d%d", &n1,&n2);

if(n1 > n2)


{
printf("%d", n1);
}
else
{
printf("%d", n2);
}
return 0;
}

Test case Test case Test case Test case


1 2 3 4
Input Input Input Input
72 45 899 388 456 896 999 399

Output Output Output Output


72 899 896 999

Question 2: Character Puzzle


Problem Statement:
You are provided with two numbers a,b and you have to first add the first number with 2
and then multiply with b and have to print the result.

Input Format:
The first line of the input contains two integers a and b.

Output Format:
Print the required result accordingly.

Constraints:
1 <= a,b<=1000

Example
Sample Input
72 45

Sample Output
3330

Default Code
#include <stdio.h>
int main()
{

return 0;
}

SOLUTION:

#include <stdio.h>
int main()
{
int a,b;
scanf("%d%d", &a,&b);

int ans = (a+2)*b;


printf("%d",ans);

return 0;
}
Test case Test case Test case Test case
1 2 3 4
Input Input Input Input
322 101 10 98 76 73 12

Output Output Output Output


322 1030 7600 900

CODING QUESTION (10 MARK QUESTION)

Question 3: Notes

Problem Statement:
You are provided with a particular amount and you have to print the minimum number of
notes (Rs 500,100,50,20,10,5,2,1) required for the amount.

Input Format:
The first line of the input contains a single integer amount amt.

Output Format:
Print the total number of notes required for the amount.

Constraints:
1 <= amt <= 100

Example
Sample Input
575

Sample Output
500 = 1
100 = 0
50 = 1
20 = 1
10 = 0
5=1
2=0
1=0

Sample Test Case Explanation


For 575, one 500 note, one 50 note, one 20 note, one 5 note is used.

Default Code
#include <stdio.h>
int main()
{

return 0;
}

SOLUTION:

#include <stdio.h>
int main()
{
int amount;
int note500, note100, note50, note20, note10, note5, note2, note1;

note500 = note100 = note50 = note20 = note10 = note5 = note2 = note1 = 0;

scanf("%d", &amount);

if(amount >= 500)


{
note500 = amount/500;
amount -= note500 * 500;
}
if(amount >= 100)
{
note100 = amount/100;
amount -= note100 * 100;
}
if(amount >= 50)
{
note50 = amount/50;
amount -= note50 * 50;
}
if(amount >= 20)
{
note20 = amount/20;
amount -= note20 * 20;
}
if(amount >= 10)
{
note10 = amount/10;
amount -= note10 * 10;
}
if(amount >= 5)
{
note5 = amount/5;
amount -= note5 * 5;
}
if(amount >= 2)
{
note2 = amount /2;
amount -= note2 * 2;
}
if(amount >= 1)
{
note1 = amount;
}

printf("500 = %d\n", note500);


printf("100 = %d\n", note100);
printf("50 = %d\n", note50);
printf("20 = %d\n", note20);
printf("10 = %d\n", note10);
printf("5 = %d\n", note5);
printf("2 = %d\n", note2);
printf("1 = %d\n", note1);

return 0;
}

Test case Test case Test case Test case


1 2 3 4
Input Input Input Input
234 464 567 999

Output Output Output Output


500 = 0 500 = 0 500 = 1 500 = 1
100 = 2 100 = 4 100 = 0 100 = 4
50 = 0 50 = 1 50 = 1 50 = 1
20 = 1 20 = 0 20 = 0 20 = 2
10 = 1 10 = 1 10 = 1 10 = 0
5=0 5=0 5=1 5=1
2=2 2=2 2=1 2=2
1=0 1=0 1=0 1=0

Q16 Write a C Program to print the greatest of 3 numbers.


Take three numbers from the user and print the greatest of 3 numbers.

Input Format
• The test cases follow Each test case contains of a single line of input, three integers n1,n2, and n3.
•Output Format
For each test case, output in a single line answer, the greatest number.

Sample Input 1:
10 30 -100
Sample Output 1:
30

Solution
#include <stdio.h>
int main()
{
int n1, n2, n3;

scanf("%d %d %d",&n1,&n2,&n3);

if (n1 >= n2 && n1 >= n3)


printf("%d", n1);
else if (n2 >= n1 && n2 >= n3)
printf("%d", n2);
else
printf("%d", n3);

return 0;
}

Test Cases

Test Case 1 Test Case 2 Test Case 3

Input 20 30 70 -4 -100 12 20 6

Output
70 0 20

Solution:

#include <stdio.h>

int main() {

int n,x,k;
scanf("%d %d %d",&n,&x,&k);
if(n>=(k/x))
printf("%d \n",k/x);
else
printf("%d\n",n);
return 0;
}

Q17 Write a C Program to check a given number is even or odd.


If N is Odd: Print "N is a odd No"
and N is Even: Print "N is an even No"

Input:
Take a number N from user
Constraints:
-100<=N<=100

Output:
Print “N is a odd No” or “N is an even No” depending on the input N.

Sample test Cases

Input Output

STC1 5 5 is an odd No

Solution 16:

#include<stdio.h>
int main()
{
int num;
scanf("%d",&num);
if(num%2==0){
printf("%d is an even No",num);
}else{
printf("%d is an odd No ",num);
}
return 0;
}

Test Cases
Input Output

TC1 53 53 is an
odd No

TC2 34 34 is an
even No

TC3 32 32 is an
even No

SECTION-D (Coding Question)(1x10 mark=10 mark)


Q18, Aditya has N empty bottles where each bottle has a capacity of X litres.
There is a water tank in Chitkara University having K litres of water. Aditya wants to fill the empty
bottles using the water in the tank.
Assuming that Aditya does not spill any water while filling the bottles, find out the maximum number of
bottles he can fill completely.

Input Format
• The test cases follow Each test case contains of a single line of input, three integers N,X, and K.
•Output Format
For each test case, output in a single line answer, the maximum number of bottles
Aditya can fill completely.

Sample Input 1:
528
Sample Output 1:
4
Sample Input 2:
10 5 4
Sample Output: 2
0

Sample Input 3:
314
Sample Output 3:
3

Explanation:
Test Case 1
The amount of water in the tank is 8 litres. The capacity of each bottle is 2 litres.
Hence, 4 water bottles can be filled completely.
Test Case 2: The amount of water in the tank is 4 litres. The capacity of each
bottle is 5 litres. Hence, no water bottle can be filled completely.
Test Case 3: The amount of water in the tank is 4 litres. The capacity of each
bottle is 1 litre. Aditya has 3 bottles available. He can fill all these bottles
completely using 3 litres of water.

Test Case 1 Test Case 2 Test Case 3

Input 237 478 286

Output
2 1 0

Solution:

#include <stdio.h>

int main() {

int n,x,k;
scanf("%d %d %d",&n,&x,&k);
if(n>=(k/x))
printf("%d \n",k/x);
else
printf("%d\n",n);
return 0;
}

Q16 Write a program to calculate simple interest by taking principle, rate per year and time (in years),
which is given by the user? Print the output in the given format, please don't print any additional text
apart from output.

To calculate the SI for a certain amount of money (P), rate of interest (R) and time (T), the formula is:
SI = (PTR)/100
Here,
SI = Simple interest
P = Principal (sum of money borrowed)
R = Rate of interest p.a
T = Time (in years)

Input :
float input value P,R,T

Output:
float output value of SI

Sample Input 1:
110 10 5
Sample Output 1:
55.00000

Sample Test Case:

Input Output
STC1

34 9 11 33.660000

STC2 400 4 16 256.00000

Solution 16:
#include <stdio.h>
int main()
{

float P , R , T;
scanf("%f %f %f",&P,&R,&T);
float SI = (P * T * R) / 100;
printf("%f\n", SI);

return 0;
}

Q17. Do you know Table?


Help Rahul recite tables of an input number x to the limit x*y.

Input Format: Take two inputs, x and y

Output Format : each line contains the table of the number x

Constraints: x<=10,000

y<=10,000

Sample Input1:
24

Sample Output1:

Sample Test Case:

Input Output

3
STC1 3 7
6

12

15

18

21

1
STC2 1 7
2

6
7

345
STC3 345 7
690

1035

1380

1725

2070

2415

Solution 17:
#include <stdio.h>
int main()
{
int x,y;
scanf("%d""%d",&x,&y);
for(int i=1; i<=y; i++){
int a = x*i;
printf("%d\n",a);
}
}
SECTION-D (Coding Question)(1x10 mark=10 mark)

Q18Coding Blocks team has 3 bags that they want to take on a vacation. The bags weigh A, B, and C
kgs respectively. They want to check-in exactly two of these bags into the hotel and carry the
remaining one bag with them. The hotel management restrictions says that the total sum of the
weights of the bags that are checked-in cannot exceed D kgs and the weight of the bag which is
carried by the CB Team cannot exceed E kgs. Find if CB team can take all the three bags on the
flight.

Sample Input 1:

1 1 1 15 5

Sample Output 1:

YES

Sample Input 2:

8 7 6 15 5

Sample Output 2:

NO

Sample Input 3:

8 5 7 15 6

Sample Output 3:

YES

Explanation:

Test case 1: CB team can check-in the first and second bag (since 1+1=2≤15) and carry the third bag
with them (since 1≤5).

Test case 2: None of the three bags can be carried in hand without violating the hotel restrictions.

Test case 3: CB team can check-in the first and the third bag (since 8+7≤15) and carry the second
bag with them (since 5≤6).
Input Format •

Each testcase contains a single line of input, five space separated integers A,B,C,D,E.

Output Format

For each testcase, output in a single line answer "YES" if CB team can take all the three bags with
them or "NO" if they cannot. Please note that you have to print YES or NO in uppercase only.

Sample Test Case:

Input Output

3 5 7 10 14
STC1 YES

3 5 17 13 14
STC2 NO

30 115 17 131 140


STC3 YES

Solution 18:

#include <stdio.h>

int main() {

int a, b, c, d, e;
scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);

if ((a + b) <= d && c <= e)

printf("YES\n");

else if ((a + c) <= d && b <= e)

printf("YES\n");

else if ((b + c) <= d && a <= e)

printf("YES\n");

else

printf("NO\n");

return 0;

Q11 Magu is a Newspaper vendor. She was unable to calculate her profits day by day. So you create a
C program to calculate her profits with the help of buying price and selling price of the Newspapers.
Read your inputs in form of TP as Total Papers, BP as buying price, SP as selling price in your
program.

Input:
First input giving the total newspapers bought.
Second input corresponds to the buying price of the newspapers.

Third input corresponds to the selling price of the newspapers.

Output:
Statement with floating point value which is giving the profit in RS.

Sample test Cases

Input Output

STC1 Rs.150.00
150

3
STC2 Rs.150.00
100

3.50

Solution 11:
#include<stdio.h>

int main()

float tp,bp,sp,profit;

printf("Enter total number of newspapers");

scanf("%f",&tp);

printf("Enter the buying price ");

scanf("%f",&bp);

printf("Enter the selling price");

scanf("%f",&sp);

float tsp=tp*sp;

float tbp=tp*bp;

profit=tsp-tbp;

printf("profit =Rs.%.2f",profit);

return 0;}

Test Cases

Input Output

TC1 Rs.150.00
150

3
TC2 Rs.60.00
120

2.50

TC3 Rs.100.00
100

2.50

3.50

TC4 Rs.225.00
150

2.50

TC5 Rs.150.00
100

3.50

Q12 Write a program to check whether a person is eligible for voting or not?
Solution:
#include<stdio.h>
int main()
{
int a ;
printf("Enter the age of the person: ");
scanf("%d",&a);
if (a>=18)
{
printf("Eigibal for voting");
}
else
{
printf("Not eligibal for voting\n");
}
return 0;
}

Test Cases
Test case 1 Test case 2

Input:- Input:-

Enter the age of the person: 19 Enter the age of the person: 17

Output:- Output:-

Eligible for voting Not Eligible for voting

SECTION-D (Coding Question)(1x10 mark=10 mark)


Q12 Write a C program to check the characters and give the output as what type of characters they are
using as user inputs.

Sample Input:
u \\ Enter any character.
Sample Output:
u is a Lower case alphabet.

Test Case 1 Test Case 2 Test Case 3 Test Case 4 Test Case 5
Input
u 6 # L c

Output
u is a Lower 6 is a numerical # is a symbol L is a Upper c is a Lower case
case value case alphabet alphabet
alphabet

Solution 12:
#include<stdio.h>

int main()

char a;

printf("Enter the character");

scanf("%c",&a);

if((a>=65)&&(a<=90))

printf("%c is a Upper case alphabet",a);

else if((a>=97)&&(a<=122))

printf("%c is a Lower case alphabet",a);

else if((a>=48)&&(a<=57))

printf("%c is a numerical value",a);

else

{
printf("%c is a symbol",a);

return 0;

Q11 Three friends are residing in a colony. One of their friend newly shifted to their colony, the
fourth friend’s house is equidistance to the other three friend’s houses, which locates like a shape of
triangle. Write a program to determine the point which is equidistance from all the three locations.

Input:

Location of First friend’s house.

Location of Second friend’s house.

Location of Third friend’s house.

Output:
Location of Fourth friend’s house.

Sample test Cases

Input Output

STC1 (5.67,9)
(2,4)

(10,15)

(5,8)

STC2 (3.33,4.00)
(2,2)

(3,4)

(5,6)

Solution 11:
#include<stdio.h>

int main()
{

float a1,a2,a3,b1,b2,b3,eqa,eqb;

printf("Location of first friend");

scanf("%f%f",&a1,&b1);

printf("Location of second friend");

scanf("%f%f",&a2,&b2);

printf("Location of third friend");

scanf("%f%f",&a3,&b3);

eqa=(a1+a2+a3)/3;

eqb=(b1+b2+b3)/3;

printf("Location of fourth friend(%.2f,%.2f)",eqa,eqb);

return 0;

Test Cases

Input Output

TC1 (12.67,5.67)
(4,3)

(33,12)

(1,2)

TC2 (1.33,-3.00)
(-2,-3)

(-1,0)

(7,-6)
TC3 (5.67,9)
(2,4)

(10,15)

(5,8)

TC4 (3.33,4.00)
(2,2)

(3,4)

(5,6)

TC5 (3.00,-2.33)
(5,1)

(-3,-7)

(7,-1)

Q12 Write a program to calculate Simple Interest.


Solution 12:
#include <stdio.h>
int main()
{
float amount,rate,time,si;
printf("Enter principal (Amount) :");
scanf("%f",&amount);
printf("Enter rate :");
scanf("%f",&rate);
printf("Enter time (in years) :");
scanf("%f",&time);
si=(amount*rate*time)/100;
printf("\nSimple Interest is = %f",si);
return 0;
}

Test Cases
Test case 1 Test case 2

Input:- Input:-
Enter principal (Amount) :15000 Enter principal (Amount) :10000
Enter rate :2.8 Enter rate :1.5
Enter time (in years) :2 Enter time (in years) :1

Output:- Output:-
Simple Interest is = 840.000000 Simple Interest is = 150.000000

SECTION-D (Coding Question)(1x10 mark=10 mark)


Q13 Using Switch case fall through method , take numbers from (1 to 12) as inputs in sense of
months with years and print either the user input month is containing of 30 days or 31 days or
February month and it is a leap year or not.

Sample Input:
3 \\ Enter the Month
2004 \\ Enter the Year

Sample Output:
this is a month of 31 days and it is a leap year

Test Case 1 Test Case 2 Test Case 3 Test Case 4 Test Case 5
Input
3 7 2 11 2

2020 2006 2004 2016 2018

Output
this is a this is a month of this is a this is a this is a February
month of 31 30days and it is a February month of 30 month of non-leap
days and it non-leap year month of days and it is year.
is a leap leap year a leap year
year

Solution 13:
#include<stdio.h>

int main()

int month,year;

printf("enter the number of a month");

scanf("%d",&month);

printf("enter the year");

scanf("%d",&year);

switch(month)

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12:
if((year%4==0)&&((year%400==0)||(year%100!=0)))

printf("this is a month of 31 days and it is a leap year",year);

else

printf("this is a month of 31 days and it is a non leap year",year);

break;

case 4:

case 6:

case 9:

case 11:

if((year%4==0)&&((year%400==0)||(year%100!=0)))

printf("this is a month of 30 days and it is a leap year",year);

else

printf("this is a month of 30 days and it is a non leap year",year);

break;

case 2:

if((year%4==0)&&((year%400==0)||(year%100!=0)))

printf("%d is a feb month of leap year",year);

else
{

printf("%d is a feb month of non leap year",year);

break;

default:

printf("Invalid month");

return 0;

1. Q11 Get the details of your vehicle’s mileage, petrol available and with that compare you can
cover the distance of your destination?

Input: mileage,petrol available , distance to be covered.

Output: can reach the destination or not

Sample test Cases

Input Output

STC1 Can reach


12

47

STC2 Cannot reach


17

156
Solution 11:
#include<stdio.h>

int main()

int mileage,petrol,distance;

printf("Enter the distance to be covered");

scanf("%d",&distance);

printf("Enter the petrol available");

scanf("%d",&petrol);

printf("Enter the mileage of your vehicle");

scanf("%d",&mileage);

if(distance<=(petrol*mileage))

printf("can reach");

else{

printf("cannot reach");

return 0;}

Test Cases

Input Output

TC1 Can reach


12

47
TC2 Cannot reach
17

156

TC3 Can reach


9

30

250

TC4 Can reach


20

90

TC5 Cannot reach


11

67

Q2 Write a Program to Check Whether a Given Year is Leap Year or Not.

Solution :
#include<stdio.h>
void main()
{
int y;
printf("Enter year: ");
scanf("%d", &y);
if( (y%400 == 0) || (y%4 == 0 && y%100 != 0) )
{
printf("%d is a leap year.", y);
}
else
{
printf("%d is not a leap year.", y);
}
}

Test Cases
Test case 1 Test case 2

Input: 2004 Input: 2005

Output: Output:

2004 is leap year 2005 is not a leap year

SECTION-D (Coding Question)(1x10 mark=10 mark)


Q12 From user inputs get two values then add the two values. After adding take the added value and
subtract the added value with 2,then take the subtracted value and multiply it with value of a and
divide the multiplied value with b. print all the operations.

Sample Input:
2 \\ Enter the two user inputs.
3 \\ \\

Sample Output:

Add=5.0
Sub=3.0

Mul=6.0
Div=2.0

Test Case 1 Test Case 2 Test Case 3 Test Case 4 Test Case 5

Input
2 3 4 7 3

3 5 6 5 8

Output
Add=5.0 Add=8.0 Add=10.0 Add=12.0 Add=11.0

Sub=3.0 Sub=6.0 Sub=8.0 Sub=10.0 Sub=9.0

Mul=6.0 Mul=18.0 Mul=32.0 Mul=70.0 Mul=27.0

Div=2.0 Div=3.6 Div=5.3 Div=14.0 Div=3.4

Solution 12:
#include<stdio.h>

int main()

float a,b,add,sub,mul,div;

printf("Enter the value of a");

scanf("%f",&a);

printf("Enter the value of b");

scanf("%f",&b);

add=a+b;
sub=add-2;

mul=sub*a;

div=mul/b;

printf("add=%.1f\nsub=%.1f\nmul=%.1f\ndiv=%.1f",add,sub,mul,div);

return 0;

You might also like