Programming Assignment From Chapter 1 To 6
Programming Assignment From Chapter 1 To 6
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:
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
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.