0% found this document useful (0 votes)
8 views4 pages

Introduc) On To C Programming Lab Assignments 5 (Batch B) : Input Format

Lab question for C lang

Uploaded by

itssahilhere31
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)
8 views4 pages

Introduc) On To C Programming Lab Assignments 5 (Batch B) : Input Format

Lab question for C lang

Uploaded by

itssahilhere31
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/ 4

Introduc)on to C programming

Lab Assignments 5 (Batch B)


1. Transpose of a matrix can be performed by exchanging the elements of a row by
column and the elements of a column by row. Write a C program to create a 4*4
matrix and show it. Also show the transpose of this matrix.

2. Chef and Chefina are playing with dice. In one turn, both of them roll their dice at
once. They consider a turn to be good if the sum of the numbers on their dice is
greater than 6. Given that in a particular turn Chef and Chefina got X and Y on their
respective dice, find whether the turn was good.

Input Format

• The first line of input will contain a single integer T, denoting the number of test
cases.
• Each test case contains two space-separated integers X and Y — the numbers Chef
and Chefina got on their respective dice.

Output Format

For each test case, output on a new line, YES, if the turn was good and NO otherwise.

Each character of the output may be printed in either uppercase or lowercase. That is, the
strings NO, no, nO, and No will be treated as equivalent.

Constraints

• 1≤T≤100
• 1≤X,Y≤6

Sample 1:

Input Output
4
1 4 No
3 4 YES
4 2 NO
2 6 YES

Explanation:

Test case 1: The sum of numbers on the dice is 1+4=5 which is smaller than 6. Thus, the turn
is not good.
3. You're a bit all over the place as a college student. You used to eat out at expensive
restaurants almost every day until your parents gave you a talking-to about being
irresponsible. Now, you've got to control your eating and spending habits.

So, here's the plan: you'll stick to the college mess for your meals every day, except Sundays.
On Sundays, you're treating yourself to those fancy restaurant meals.
The cost is Rs. X for the mess food each day, and Rs. Y for the restaurant splurges.

Now, what's the cost of food per week? Note that you don't have to pay for the mess on
Sundays.
A week has seven days, as usual.

Input Format

• The first and only line of input contains 2 space-separated integers, X and Y.

Output Format

Output a single integer: the weekly cost of food.

Constraints

• 1≤X<Y≤1000

Sample 1:

Input
100 500
Output
1100

4. Write a C program without using if-else construct that does the following.
It accepts a sequence of posiBve integers between 1 and 9 both inclusive from the key-
board. The program will stop accepBng input once an integer outside the range is entered.
The program will finish by prinBng the total number mulBples of 3 and total number of
even integers entered.

Test data and expected output:


Enter integers between 1 & 9 both inclusive, outside range to stop
Enter integer :0
Total no of even integer entered is 0
Total no of mulBples of 3 entered is 0

Enter integers between 1 & 9 both inclusive, outside range to stop


Enter integer :2
Enter integer :4
Enter integer :6
Enter integer :9
Enter integer :3
Enter integer :1
Enter integer :2
Enter integer :0
Total no of even integer entered is 4
Total no of mulBples of 3 entered is 3

5. The C program implements the following:


(a) It accepts b and c (from the keyboard) of the quadraBc equaBon x2 + bx + c = 0
such that either the condiBon b + c ≤ −6 or the condiBon b + c ≥ 5 holds. If neither
of the condiBon holds, then the program terminates with a message “Wrong Input”.
(b) It then finds the non-real roots and prints them with two decimal places.
(c) In case of real roots, it prints the message “Non-real roots do not exist”.

Note down the output with (i) b = 2, c = 3 (ii) b = −5, c = 2 (iii) b = 4, c = 5

6. Write a C program to count the number of vowels and the number of consonants
in a word.

The C program implements the following:


(a) It accepts b and c (from the keyboard) of the quadraBc equaBon x2 + bx + c = 0
such that either the condiBon b + c ≤ −6 or the condiBon b + c ≥ 5 holds. If neither
of the condiBon holds, then the program terminates with a message “Wrong Input”.
(b) It then finds the non-real roots and prints them with two decimal places.
(c) In case of real roots, it prints the message “Non-real roots do not exist”.

Note down the output with (i) b = 2, c = 3 (ii) b = −5, c = 2 (iii) b = 4, c = 5

7. Write a C program to display and find the sum of the series 1+11+111+....111 upto n.
For eg. if
n=4, the series is : 1+11+111+1111. Take the value of 'n' as input from the user.

8. Write a C program to find the reverse of an integer number.

9. Write a C program to check if a number has three consecuBve 5. If yes, print YES, else
print NO.
Example:
Number: 1353554
Result: NO
Number: 345559
Result: YES
10. The given number is ugly prime number if it's prime factor contains only among 2,3 or
5. e.g. 20= 2*2*5 is ugly prime number and 14=2*7 is not a ugly prime number. So
write a C funcBon which takes values from 1 to n and returns the number of ugly
primes number in it.
Example:
input: 20 output: 3

You might also like