c allows for, while and do while loops to be nested. that is one loop is inside another loop.
Example:-
Output:-
.....
....
...
..
.
one type of loop can be nested with other type of loop. for example while loop is inside for loop.
Example:-
Previous Code:-
Do while loop
List Code:-
C++ Codes
Next Code:-
Switch case
C++ Programs
List of c++ Programs
Do while loop
List Code:-
C++ Codes
Next Code:-
Switch case
C++ Programs
List of c++ Programs
What are loops and how we can use them?
ReplyDeleteIn general a loop is a sequence of statements which is specified once but which may be carried out several times in succession. The function of the loop is to repeat the calculation a given number of times until it reaches a certain value. The code inside the loop is obeyed a specified number of times, or once for each of a collection of items, or until some condition is met, or indefinitely. We can divide loops into:
1) Count-controlled loops,
2) Condition – controlled loops,
3) Collection - controlled loops,
4) General iteration,
5) Infinite loops,
6) Continuation with the next iteration,
7) Redo the current interation and
8) Restart loop
For more information please visit: http://megacplusplustutorials.blogspot.com
Hmm... Good one
ReplyDeleteThanks a lot
DeleteThe output of first question is wrong.. it should be like this -->
ReplyDelete......
.....
....
...
..
.
i try this tips
ReplyDelete. Write a program that uses nested loops to display the following lines.
ReplyDelete1 2 4 6
2 2 4 6
3 2 4 6
4 2 4 6
5 2 4 6
question
ReplyDelete11
21 22
31 32 33
41 42 42 44
pleassolve it
// C++ program to add numbers until user enters 0
Delete#include
using namespace std;
int main()
{
int j, i ;
for (i= 1 ; i <= 4 ; i++){
for ( j=1 ; j <=i ; j++ ){
cout << i << j <<" " ; }
cout << "\n";
}
return 0;
}
pleas help me to c++
ReplyDeleteA.
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
B.
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
C.
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
A.
1 2 3 4 5
6 7 8 9
10 11 12
13 14
15
please help in c++
ReplyDeleteinput number = n
ex.n =5
output
1+2+3+4+5=15