Professional Documents
Culture Documents
Exercise I
1) Write a C++ program that solves any linear equation of the form ax + b = 0
2) Write a C++ program that calculate area of the following geometric figures
3) Write a program that solves general quadratic equations of the forma ax 2 +bx +
c=0. A quadratic equation may have only one solution, two distinct solutions, or no
real solution.
4) Write a program that reads a natural number and print the reciprocal of the number
a) In decimal format
b) In fraction format
5) Write a program that performs addition of fraction numbers. The program takes two
fractions in a / b +c / d format and displays the output in e / f format.
7) Write a program that reads two integer numbers and swaps their value.
Exercise 2
1. Write a program that displays a remark based on their grade that is supplied from the
keyboard, the program should handle both upper case & lower case grades.
Page 1 of 4
Admas University: Department of Computer Science
Structured Programming I: Worksheet I
Rule:
Grade Remark
A Excellent
B Very Good
C Good
D Bad
F Very Bad.
C: Average
2. Write a program that requests the user to enter a number from the keyboard and tells
whether the number entered is zero, negative, or positive.
3. Write a program that displays Monday if the value entered is 1 or 2 or 3, Tuesday for 4 or
5, Wednesday for 6, Thursday for 7 or 8 and Friday for 9.
4. Write a C++ program that accepts two integer numbers form the user and calculate their
SUM or Difference or Product based on the arithmetic operator selected by the user
(note: Use switch case statement)
Page 2 of 4
Admas University: Department of Computer Science
Structured Programming I: Worksheet I
6. Write a program that reads a three digits number and displays the digits of the number
in reverse order
7. Write a program that accepts any number and checks whether a number is prime or not. And if
it is prime display "The number is prime", if it is not prime display "The number is not
prime".
8. Write a program that calculates the factorial of a given natural number n and display the value
to the screen.
a. ASCII value and displays the corresponding character with the given ASCII value.
b. Lists down all number between 1000 and 2000 that are divisible by 7
12. Write a C++ program that reads N numbers from the keyboard and displays the sum and their
average.
13. Write a program that continuously reads numbers from the keyboard until zero is given as
input and finally display the sum and average of the input numbers.
14. Write a program that continuously reads numbers from the keyboard until zero is given as
input and finally display the sum and average negative and positive numbers separately of.
15. Write a program that displays the maximum value from three integer number given as an
input.
Page 3 of 4
Admas University: Department of Computer Science
Structured Programming I: Worksheet I
17. Write a program that outputs the following shapes from a single asterisk (*)
a.Equilateral Triangle
b. Square
c.Square with diagonal from top left corner to bottom right
Note: dimensions (number of rows and columns will be determined by the user at run time)
Page 4 of 4