Professional Documents
Culture Documents
LOOP 1:
1) Find the error in the following code segments and
correct it
1- for i=0; i<5; i++
cout>>”Hello”;
2- for (i=0; i<5; i++) ;
cout>>”Hello”;
3- for (i=0; i>5; i++)
cout<<”Hello”;
4- for (i=0; i<5; i--)
cout<<”Hello”;
2) Write a program to print the sum of all squares between 1 and n, where n
is a number accepted from the keyboard (i.e. 1+ 4 + … + (n*n) )
3) Write a program to compute the factorial of a number using loops