Lab Practice Assignment 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Object Oriented Programming using C++

Lab Practice Assignment 2

Q1. Write a program in C++ to check whether a number is odd or even.


Q2. Write a program in C++ to enter marks of five subjects and calculate total, average and percentage.
Q3. Write a program in C++ that asks the user to input lengths of three sides of a triangle and
i) prints whether it is a valid triangle or not
ii) If the triangle is valid, prints whether the triangle is equilateral, scalene or isosceles
Q4. Write a program in C++ that asks the user to input 4 integers and prints them in forward and
reversed order. (e.g., if the input is 18 56 21 32, forward order is 18 56 21 32 and reverse
order is 32 21 56 18.)
Q5. Write a program in C++ that accepts a character and does the following:
i) prints whether the character is a letter or a numeric digit or a special character
ii) if the character is a letter, prints whether the letter is upper case or lower case
iii) if the character is a numeric digit, prints its name in text (e.g., if input is 9, output is NINE)
iv) if the character is a special symbol that are present along with digits 0 to 9 on the keys of a
keyboard, prints the corresponding digit present on the same key (e.g., if input is 3, output
is #; if input is 5, output is %, etc.)
Q6. Write a program in C++ to find roots of a quadratic equation.
Q7. Write a program in C++ having a user defined function that accepts an integer argument and returns
a Boolean value. The function should return true if the integer argument is greater than or equal to
zero, and false otherwise. Call this function with a positive and negative value to test that it works,
and display the result.
Q8. Write a program in C++ having a user defined function that continuously asks for numbers until the
user provides a negative number. Make use of the function created by you in the previous question.

Q9. Write a program in C++ having a user defined function that accepts a character. If the character is
an uppercase letter, the function returns the next consecutive letter of the alphabet. If the character
is a lowercase letter, the function returns the previous consecutive letter of the alphabet. The value
returned by the function is printed on the screen. If the character is not a letter, the function returns
the question mark ('?') character and a message "Character not found in the
alphabet", is printed on the screen before the program ends.
Q10. Write a program in C++ to print Fibonacci series.
Q11. Write a program in C++ that reads a positive integer entered by a user and prints all positive divisors
of that integer in decreasing order. The program should allow the user to repeat this process as
many times as the user likes.
Q12. Write a program in C++ to perform basic arithmetic operations using switch case.

You might also like