Explain the elements of loop in cpluS plus with example.
Answers
Answered by
1
There are diffrent loop in c++ did you mean for loop?
syntax for for loop is...
for ( init-expression ; cond-expression ; loop-expression ) statement;
example
#include <iostream>
using namespace std;
int main()
{
// The counter variable can be declared in the init-expression.
for (int i = 0; i < 2; i++ )
{
cout << i;
} // Output: 01 // The counter variable can be declared outside the for loop.
}
syntax for for loop is...
for ( init-expression ; cond-expression ; loop-expression ) statement;
example
#include <iostream>
using namespace std;
int main()
{
// The counter variable can be declared in the init-expression.
for (int i = 0; i < 2; i++ )
{
cout << i;
} // Output: 01 // The counter variable can be declared outside the for loop.
}
Attachments:
Answered by
1
Hello friend,
In programming, one of the frequently arising problem is to handle numerous data of same type.
Consider this situation, you are taking a survey of 100 people and you have to store their age. To solve this problem in C++, you can create an integer array having 100 elements.
An array is a collection of data that holds fixed number of values of same type. For example:
int age[100];
Hope it helps you
Mark it as brain list
In programming, one of the frequently arising problem is to handle numerous data of same type.
Consider this situation, you are taking a survey of 100 people and you have to store their age. To solve this problem in C++, you can create an integer array having 100 elements.
An array is a collection of data that holds fixed number of values of same type. For example:
int age[100];
Hope it helps you
Mark it as brain list
Similar questions