EXERCISE 1,CSC1254/1,S

EXERCISE 1, CSC1254/1, SPRING 2015
Introduction to Programming with C++ II, Hartmut Kaiser
http://www.cct.lsu.edu/~hkaiser/spring_2015/csc1254.html
This gives you a list of possible exercises you can solves in order to gain some programming experience
with strings. Feel free to submit your solutions through the submission system on our server as prog11
for bonus points or if you have questions. Please send an email to me alerting me of any submissions
you make. Please create a separate file named task1.cpp … task10.cpp depending on the exercise you
solve.
General advice: write the programs in a way allowing user input to specify a number of lines to print.
1. Write a program to display the half pyramid of *.
*
*
*
*
*
*
* *
* * *
* * * *
2. Write a program to print half pyramid as using numbers as shown in figure below.
1
1
1
1
1
2
2 3
2 3 4
2 3 4 5
3. Write a program to print triangle of characters as below
A
B
C
D
E
B
C C
D D D
E E E E
4. Write a program to print inverted half pyramid using * as shown below.
*
*
*
*
*
* * * *
* * *
* *
*
5. Write a program to print inverted half pyramid as using numbers as shown below.
1
1
1
1
1
2 3 4 5
2 3 4
2 3
2
6. Write a program to display the pyramid of *.
*
* *
* * *
* * * *
*
*
*
*
*
*
* *
* * *
* * * *
7. Write a program to print the pyramid of digits in a pattern as below.
2
3 4
4 5 6
5 6 7 8
1
3
5
7
9
2
4 3
6 5 4
8 7 6 5
8. Write a program to display a reverse pyramid.
* * * *
* * *
* *
*
*
*
*
*
*
* * * *
* * *
* *
*
9. Write a program to Draw Pascal's triangle as below.
1
1
1
1
1
1
1
2
3
4
5
6
10
1
3
1
4
1
10 5
1
10. Write a program to display Floyd's Triangle.
1
2 3
4 5 6
7 8 9 10