• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
 
 Amer Daradkah
A-)
#include<iostream>using namespacestd;intmain(){ intcount = 1; while( count <= 10 ) {cout << (count % 2 ? "*****" : "+++++")<< endl;++count;}return0;}
Output
*****+++++*****+++++*****+++++*****+++++*****+++++
 
Press any key to continue
B-)
#include<iostream>using namespacestd;intmain(){ introw = 10, column; while( row >= 1 ) {column = 1; while( column <= 10 ) {cout << (row % 2 ? "*" : "$");++column;
1
 
 Amer Daradkah
}--row;cout << endl;} return0;}
Output
$$$$$$$$$$**********$$$$$$$$$$**********$$$$$$$$$$**********$$$$$$$$$$**********$$$$$$$$$$**********
 
Press any key to continue
C-)
#include<iostream>using namespacestd;intmain(){ intx, y;cout << "Enter two integers in the range 1-20: ";cin >> x >> y; for ( int i = 1; i <= y; i++ ) { for ( int j = 1; j <= x; j++ )cout << '@';cout << endl;} return0;}
Output
Enter two integers in the range 1-20: 53@@@@@@@@@@@@@@@
2
 
 Amer Daradkah
Press any key to continue
D-)
#include<iostream>using namespacestd;intmain(){ inttotal,// sum of grades  gradeCounter,// number of grades enteredgrade,// one gradeaverage;// average of grades // initialization phasetotal = 0;// clear totalgradeCounter = 1;// prepare to loop// processing phase while( gradeCounter <= 10 ) {// loop 10 times cout << "Enter grade: ";// prompt for inputcin >> grade;// input gradetotal = total + grade;// add grade to totalgradeCounter = gradeCounter + 1;// increment counter } // termination phaseaverage = total / 10;// integer divisioncout << "Class average is " << average << endl; return0;}
Output
Enter grade: 85Enter grade: 88Enter grade: 88Enter grade: 73Enter grade: 82Enter grade: 97Enter grade: 81Enter grade: 67Enter grade: 62Enter grade: 51Class average is 77
 
Press any key to continue
E-)
#include<iostream>using namespacestd;intmain(){ intc;c = 5;cout << c << endl;// print 5
3
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...