Practice Questions


 1:   Write a C++ program to print the following lines:
 You are 10 years old. 
 You are too young to play the game.



 2:    Write a C++ program to declare two integer , one float variables and assign 10,
       15, and 12.6 to them respectively. It then prints these values on the screen.
      Exercise 4: Write a C++ program to prompt the user to input her/his name and print this name
       on the screen, as shown below. The text from keyboard can be read by using cin>> and to display
 the text on the screen you can use cout<<.
Hello Sok! .



3:   Write a C++ program to prompt the user to input 3 integer values and print these values in 
forward and reversed order, as shown below.
Write a program to print the following pattern:
                        C
                      i   I
                    s       s
                  b           b
                e               e
              s                   s
            t s e b s i C i s b e s t



 4:  Write a program that, given a date, three ints (for example, 11 27 1997), will print the number of that 
 day within its year: i.e. Jan 1st is always 1, Dec 31st is either 365 or 366.



5:   Write a program to read a file and count the number of chars, words, and lines, and print these quantities.
 Add pin numbers to the bank accounts and add a special pin number for the bank manager. Add a transaction 
 type S to open the bank. Only the manager should be allowed to do transactions S, P, I, and E. For each transaction,
  the computer must ask for the pin number. In an Open transaction, the user chooses the pin number for the account.


6:   Rewrite your leap year program as a function and write a main() to test it.


7:  Rewrite your day_of_the_year program as a function and write a main() to test it.


8:  Write a program to read in a date, 3 ints, and print the corresponding day of the week (Monday, Tuesday, . . ., Sunday). 
You will be given a range of valid dates and the day of the week for a certain date.
A function is required that checks strings to see if they are palindromes. A palindrome string that reads the same,
 backwards, or forwards. For example,
I was able no on elba saw I


9:  The palindrome can be even or odd in length. Give the body to the following function and write a main()
 to read in strings from the user and pass them to your function to test it. It returns TRUE if
  the string passed in is a palindrome:
int is_palindrome(char *s);
Note that strings are terminated with the zero valued character. For the purposes of this exercise, the
 terminating zero is not part of the string.