35 Problems Challange
35 Problems Challange
35 Problems Challange
..
Page 1 of 3
23. Input mark s fro m a user, i f marks are g reater than 85 display “Ex cellent”, i f t he marks are b etween 80 and 84 (b oth
inclusive) display “Very Good”, if the marks are between 75 and 79 (both inclusive) display “Good”, if the marks are
between 70 a nd 7 4 (b oth i nclusive) d isplay “ Fair”, if t he ma rks ar e between 65 a nd 6 9 (b oth inclusive) d isplay
“Satisfactory”, otherwise display “You may not get the degree with such marks”.
24. Write a program t hat mimics a c alculator. The program sh ould take as input t wo integers a nd the o peration to be
performed. It should t hen o utput t he numbers, the oper ator, and the result. (For division, if t he d enominator i s ze ro,
output an appropriate message.) Some sample outputs follow:
Output should be:
Enter 1st number : 13
Enter 2nd number: 5
Enter operator: *
13 * 5 = 65
25. In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of other two sides.
Write a pro gram that prompts t he user t o e nter t he le ngths of three sides o f a tria ngle a nd then ou tputs a m essage
indicating whether the triangle is a right triangle.
26. Input three values a, b and c and print the roots, if real, of the quadratic equation: ax2 + bx + c = 0 (Sample Input 1: a=1,
b=1, c=-6 the output should be “ Roots of the equation are -3 and 2”) (Sample Input 2: if the input is a=1, b=0, c=9 the
output should be “Sorry! The roots are not real may be imaginary or complex”)
27. Consider a qua dratic expression, say x2 – x -2. Describing where this quadratic is positive, involves describing a set of
numbers that are either less than the smaller root (which is -1) or greater than the larger root (which is +2). Write a C++
Boolean expression that is true when this formula has positive values.
28. Consider the quadratic expression x2 – 4x +3. Describing where this quadratic is negative involves describing a set of
numbers that are si multaneously greater t han t he sm aller root (+1) and less than the larger root (+3). Write a C++
Boolean expression that is true when the value of this quadratic is negative.
29. Write a program that takes two numbers from user and determines that first number is a factor of second number. [Hint:
Use if–else and modulus operator]
30. Write a program that takes a point (x, y) from the user and find where does the point lies. The point can lie on any of the
following (you are not allowed to use any of the logical operator &&, || or !)
1st Quadrant
2nd Quadrant
3rd Quadrant
4th Quadrant
31. Write a program that reads a single char digit (0-9) and then prints the number as a literal string. For example, if input is
7, then the output should be word “seven”. Use a switch statement.
32. Write a program that reads two characters and two integers. If the first character or the two characters together form one
of the six relational operators (<, >, <=, >=, = =, !=), then two integers are compared using that operator and a message
describing the result is printed.
Output should be:
!= 33 77
33 is not equal to 77
33. Write a program that reads a grade, A, B, C, D, E or F and then prints “excellent”, “very good”, “good”, “fair”, “poor”, or
“failure” respectively. Use if-else structure
Output should be:
Enter a grade letter: B
good…
34. Rewrite the above program using switch statement.
Page 2 of 3
35. Prompts t he user to e nter his/her marks o btained in first semester su bjects as well as the c redit h ours of each s ubject.
(You can hard code the five subjects of your first semester and you can also hard code the total marks in each subject to
be 1 00). Com pute the gr ade po ints (G PTS) and Let ter g rade of ea ch sub ject. F inally com pute t he t otal gra de p oints,
Grade point Average and Letter grade for the entire semester. Also mention that whether the s tudent is on probation or
not.
GRADING SYSTEM for Fall 2010 batch
PERCENT MARKS GRADE POINTS
85-100 4.00
80-84 3.70
75-79 3.30
70-74 3.00
65-69 2.70
61-64 2.30
58-60 2.00
55-57 1.70
50-54 1.00
Below 50 0.00
A student attains Probation Status if his/her CGPA becomes 1.70 or more but less than 2.00.
A sample output can be as given below. But you are free to design as per your design capabilities, I mean better than this.
SEMESTER CGPA CALCULATOR
Subjects Total Marks Obtained Mks Credit Hours GPTS Letter Grade
Total Grade Points:
Semester GPA:
Letter Grade:
Page 3 of 3