Exercises for the C++ course (Beginners Course)
Problem 1.
Write a C++ program using two for
loops to produce the following pattern
of asterisks.
*
**
***
****
*****
******
*******
********
Rewrite the program using two while
loops.
Problem 2.
Write a C++ program that enters an 8-digit string
for a birthdate from the keyboard. The first two digits
in the string are the month of birth, the
next two are the day and the remaining four are
the year. The C++ should squeeze out these
substrings and display it on the screen as follows:
month of birth:
day of birth:
year of birth:
Problem 3.
Write a C++ program that reads in
three floating point numbers from
the keyboard and the finds
the arithmetic, harmonic and geometric mean.
Problem 4.
Write a C++ program that generates three
integer random numbers in the range 0 .. 10.
Problem 5.
Write a C++ program that finds the smallest
and largest number in an array of double .
Use a function
void sl(double* array,double& largest,double& smallest,int size)
to do the job. Here size is the size of the array.
Problem 6.
Write a C++ program that finds the position of the smallest
and largest number in an array of double .
Use a function
void slposition(double* array,int& plargest,int& psmallest,int size)
to do the job. Here size is the size of the array.