0% found this document useful (0 votes)
17 views

Programming Assignment From Chapter 1 To 6

The document contains 10 programming problems related to control flow statements in C programming. The problems cover concepts like if-else, switch, loops, functions and involve tasks like checking types of triangles, determining youngest among three ages, calculating digit sum of a number.

Uploaded by

Mayuri Popat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Programming Assignment From Chapter 1 To 6

The document contains 10 programming problems related to control flow statements in C programming. The problems cover concepts like if-else, switch, loops, functions and involve tasks like checking types of triangles, determining youngest among three ages, calculating digit sum of a number.

Uploaded by

Mayuri Popat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY

CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY


F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17
Subject: CE141 Computer Concepts and Programming
PROGRAMMING QUESTION BANK FROM ALL CHAPTER

1. Certain grade of steel is graded according to the following conditions.

Hardness must be greater than 50.


Carbon content must be less than 0.7
Tensile strength must be greater than 5600

The grades are as follows.

Grade is 10 if all the conditions are met.


Grade is 9 if conditions 1 and 2 are met
Grade is 8 if conditions 2 and 3 are met
Grade is 7 if conditions 1 and 3 are met
Grade is 6 if only one condition is met
Grade is 5 if none of the conditions are met

Write a program, which will require the user to give values of hardness, carbon
content and tensile strength of the steel. Output the grade of steel. Use Switch
statement.

2. A university has the following rules for a student to qualify for a degree with A as
the main subject and B as the subsidiary subject:

(a) He should get 55 percent or more in A and 45 percent or more in B.


(b) If he gets less than 55 percent in A he should get 55 percent or more in B.
However, he should get at least 45 percent in A.
(c) If he gets less than 45 percent in B and 65 percent or more in A he is allowed to
reappear in an examination in B to qualify.
(d) In all other cases he is declared to have failed.

Write a program to receive marks in A and B and Output whether the student has
passed, failed or is allowed to reappear in B. Use nested if…else statement.

3. If the three sides of a triangle are entered through the keyboard, write a program to
check whether the triangle is isosceles, equilateral, scalene or right angled triangle.
 An isosceles triangle is a triangle with (at least) two equal sides.
 An equilateral triangle is a triangle in which all three sides are equal.
 A scalene triangle is a triangle that has three unequal sides.
 A right-angled triangle is a triangle in which one angle is a right
angle (that is, a 90-degree angle). Use Pythagorean Theorem i.e. If a , b
and c are the sides of the triangle then if a 2+b2=c2 then it is a right –angled
triangle where a and b are shorter side and c is the largest side or
hypotenuse. Use Else..if Ladder.

1
CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY
CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY
F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17
Subject: CE141 Computer Concepts and Programming
PROGRAMMING QUESTION BANK FROM ALL CHAPTER
4. If the ages of Ram, Shyam and Ajay are entered through the keyboard, write a
program to determine the youngest of the three. Use nested conditional operator
or ternary operator.

5. Write a program that will read the value of X and evaluate the following function.

1 for X<0
Y= 0 for X=0
` -1 for X>0

Use nested Switch Statement.

6. Write a program to reverse a number using if and goto statement. For Ex: if 2763
is entered its reverse is 3672.

7. If an number is input through the keyboard, write a program to calculate the sum of
its digits. For ex: if 2341 number is entered then 2+3+4+1 = 10. So 10 should be
displayed as sum of its digit. Use for loop.

8. Write a program to obtain the reversed number of the entered number and to
determine whether the number is palindrome number or not. A number is
palindrome if the original and reversed numbers are equal. For ex: if 12321 is
entered through the keyboard then reverse of this number is same as original
number. Use while loop.

9. Write a program to read a character until * is encountered. Also count the number
of upper case, lower case and numbers entered by the users without using
functions of ctype.h. Use do…while loop. (Hint: Use ASCII values).

10. Write a program to input the age of 5 persons. If the age is less than 18, then
person is not eligible for voting, else print the list of candidates and ask voter to
enter the vote. At the end display total number of votes given to each candidate.
Use break and continue statements.

1. A 2. A
A B B B
A B C C C C
D D D D
A B C D E E E E E
A B C D E
3. 4. 1
5 4 3 2 1 1 1
5 4 3 2 1 2 1
5 4 3 1 3 3 1
1 4 6 4 1

2
CHAROTAR UNIVERSITY OF SCIENCE AND TECHNOLOGY
CHANDUBHAI S PATEL INSTITUTE OF TECHNOLOGY
F.Y. B.Tech (CE/IT/EC)
ACADEMIC YEAR: 2016-17
Subject: CE141 Computer Concepts and Programming
PROGRAMMING QUESTION BANK FROM ALL CHAPTER
5 4
5
5. 6.
1
1 2 1
1 2 1
1 2 3
1 2 3 2 1
1 2 3 4
1 2 3 4 3 2 1
1 2 3 4 5
7. 8. 1 1
5 5 5 5 5 1 2 2 1
4 4 4 4 1 2 3 3 2 1
1 2 3 4 4 3 2 1
3 3 3 1 2 3 4 5 5 4 3 2 1
2 2
1
9. * 10. 1 2 3 4 5
* * * 2 3 4 5
* * * * * 3 4 5
* * * * * * *
* * * * * * * * * 4 5
* * * * * * * 5
* * * * *
* * *
*

11. Write a program to find all the prime numbers between 1 to N using nested while
loop.

12. Write a program to print all the perfect numbers between 1 to N using nested
do…while loop.

You might also like