C++ II Assignment
C++ II Assignment
1. Write a program in C++, to calculate the volume of a sphere, cube and cylinder. Use separate
functions to calculate each volume.
2. Write a program using a function in C++ to convert temperature in Celsius to Fahrenheit and vice
versa.
3. Write a main () function and a second function that main () calls. Ask users for their annual income
in main (). Pass the income to the second function and print a congratulatory message if the user
makes more than $50,000 or an encouragement message if the user makes less.
4. Write a three-function program, consisting of the following functions: Main (), fun1 (), fun2 ()
Declare a 10-element character array in main (), fill it with the letters A through J in fun1 (), then print
that array backwards in fun2 ().
5. Write a C++ program that reads a sentence from the keyboard and prints the reversed sentence
using a recursive function.
6. Write a C++ program that takes a C-style string from the user, calculates and prints the number of
vowels, consonants, digits and white-spaces.
7. Write a C++ program that inputs a C-style string from the user and prints frequency of a given
character. 8. Write a C++ program to check whether an inserted string/ word is a Palindrome or not.
9. Write a C++ program to detect a key press on a keyboard and print the pressed key together with
its ASCII code.
10. Write a C++ program, using a structure to record appropriate information of 20 employees and
print the information on screen in a form of a list.
Assignment two
“For a long time it puzzled me how something so expensive, so leading edge, could be so useless. And
then it occurred to me that a computer is a stupid machine with the ability to do incredibly smart things,
while computer programmers are smart people with the ability to do incredibly stupid things. They are,
in short, a perfect match.”
Number of lines ,
NB: Try to perform all activities using the concept of File Handling.