+ 2

c++

1) Write a program that displays the following pattern on the screen: ******* ***** *** * *** ***** ****** Solution: #include<iostream> using namespace std; int main() { cout<<"*******"<<endl; cout<<" *****"<<endl; cout<<" ***"<<endl; cout<<" *"<<endl; cout<<" ***"<<endl; cout<<" *****"<<endl; cout<<"********"<<endl; return 0; } 2) Write a program that displays the following pattern on the screen: 1 121 12321 1234321 123454321 1234321 12321 121 1 3) Write a program that prints the numbers 1 to 5 on the same line with each pair of adjacent numbers separated by one space. Write the program using the following methods: a) Using one output statement with one stream insertion operator. b) Using one output statement with four stream insertion operators. c) Using four output statements. 4) What does the following code print? cout << "*\n**\n***\n****\n*****\n";

17th Sep 2018, 12:19 PM
Abdulla Khaled
Abdulla Khaled - avatar
4 odpowiedzi
+ 12
you can use nested loops ....
17th Sep 2018, 12:42 PM
Lương Văn Tuấn
Lương Văn Tuấn - avatar
+ 3
You can try it in the code playground.
17th Sep 2018, 12:24 PM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
17th Sep 2018, 1:11 PM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
+ 1
how put this 1 121 12321 1234321 123454321 1234321 12321 121
17th Sep 2018, 12:33 PM
Abdulla Khaled
Abdulla Khaled - avatar