IFs Assignment
IFs Assignment
1. Write and run a program that reads a six-digit integer and prints the sum of its six digits.
Sample Input: 153426
Sample output: 21
2. Write and run a program that plays the game of “Rock, paper, scissors.” In this game, two players
simultaneously say (or display a hand symbol representing) either “rock,” “paper,” or “scissors.” The
winner is the one whose choice dominates the other. The rules are: paper dominates (wraps) rock, rock
dominates (breaks) scissors, and scissors dominate (cut) paper. You can use
1=rock,2=paper,3=scissors
Sample Input: 1 1
Sample Output: Draw
Sample Input: 1 2
Sample Output: 2nd player wins
3. Write a program which will output ChessBoard initial configuration (One player with small letters and
2nd player with Capital letters).
Output: The Complete Screen Chess Board
4. Take a character input from the user and tell whether the number is a capital letter or a small letter.
Sample Input: A
Sample Output: Capital letter
Sample Input: g
Output: small letter
Sample Input: )
Sample Output: Non
5. Write and run a program that reads two integers and then uses the conditional expression operator to
print either “multiple” or “not” according to whether one of the integers is a multiple of the other.
Sample Input: 12 6
Output: 12 = 6 * 2
Sample Input: 18 8
Output: 18 = 8 * 2 + 2
Sample Input: 12 13
Output: 14 = 12 * 1 + 1
6. Write and run a program that simulates a simple calculator. It reads two integers and a character. If the
character is a ‘+’, the sum is printed; if it is a ‘-‘, the difference is printed; if it is a ‘*’, the product is printed;
if it is a ‘/’, the quotient is printed; and if it is a ‘%’, the remainder is printed.
7. ITC has 6 sections we are required to find out which sections average is higher. Write a program which
takes each section’s PF average and Output which section has won w.r.t average.
Sample Input: B 90
D 80
C 60
A 99
E 91
F 80
Output: A got the highest average
8. Write a program which takes marks of 5 courses as input, of 5 students and output the students who
got the highest aggregate.
Roll# C1 C2 C3 C4 C5
Sample Input:
1391 80 70 60 14 88
1376 70 80 80 88 89
1374 71 82 50 80 79
1372 77 90 90 99 100
1375 73 83 40 81 69
Sample Output: 1372 has highest Aggregate of 456
9. Write a program which will take at max: a six digit number and output each of its digit in words, (Bonus)
if the number is less than 6 digits it should not out print initial zeros. If the number is greater than 6 digits
then it should output wrong input.
Sample Input: 651432
Output: Six Five One Four Three two
(Bonus)Sample Input: 1432
Sample Output: One Four Three two.
10. Write a program which takes as input 4 points and tell whether these points are the coordinates of
Rectangle, Square or Quadrilateral.
Sample Input: P1 0 0
P2 1 0
P3 1 1
P4 0 1
Output: Its a square
11. Write a program which takes as input 3 points and tell whether these points are the coordinates of
isosceles or equilateral or right angled or scalene triangle.
Sample Input: P1 0 0
P2 1 0
P3 1 1
Sample Output: Right Angle Triangle
12. Take 4 coordinates of the Rectangle and a point P. Your program should be able to tell whether P lies
inside the Rectangle or Not.
Sample Input: P1 0 0
P2 2 0
P3 2 2
P4 0 2
P 1 1
Output: P lies inside Square
13. Write a program which takes 3 inputs integers and tell the 2nd maximum.
Sample Input: 90 5 60
Sample Output: 60
14. Write a program which takes as input a floating number and prints its ceiling Integer.
Sample Input: 5.5
Output: 6
Sample Input: -5.5
Output: -5
Sample Input: 5
Output: 5
15. Write a program which takes as input a floating number and prints its floor value.
Sample Input: 5.5
Output: 5
Sample Input: -5.5
Output: -6
Sample Input: 5
Output: 5
Bonus(Chocolate)
Problem # 1: Write a program that takes marks of 5 different students(1,2,3,4,5) in 5 different courses as
input and output the highest marks in each course along with the id of student(e.g. 1,2,3,4,5) who scored it.
Problem # 2: A program that takes marks of n different students(1,2,3,4,5) in k different courses as input and
prints the highest marks in each course along with the id of student(e.g. 1,2,3,4,5...n) who scored it.
Make sure there is a subtle difference between the two questions:
In problem 1 the input is student 1(all courses result) then 2nd student all results.... and so on.
In problem 2 the input is Course 1(all the students result) and then course 2(all students result)... and so on.