Professional Documents
Culture Documents
*
Example 5: what is the output of the following code?
2
#include <iostream.h>
void main()
{
for ( ; ; )
cout << "Hello" << endl;
}
Infinite loop
Try:
for (int i=1; ; )
cout << "Hello" << endl;
Try:
for (int i=1; ; i++ )
cout << "Hello" << endl;
Example 5: what is the output of the following code?
#include <iostream.h>
void main()
{
for (int x=1, n=10; x<=5&&n>=5 ; x++, n--) cout<<x<<" "<<n<<endl;
}
Exercise: write a C++ program to insert n values and print out the maximum.
Exercise: write a C++ program to insert an integer values and print out its factorial
Exercise: write a C++ program to calculate S where
S=1+22+32+42++102
S=1/n+3/n+5/n++9/n