C++ Program.
C++ Program.
C++ Program.
(1)
#include <iostream>
using namespace std;
int main() {
cout << "The sum is: " << sum << endl;
cout << "X= " << x << endl;
}
(2)
#include <iostream>
using namespace std;
int main() {
while (i <= y) {
power *= x;
++i;
}
#include <iostream>
using namespace std;
int main() {
unsigned int x=1;
unsigned int total=0;
#include <iostream>
using namespace std;
int main() {
c = 5;
cout << " c before preincrement: " << c << endl; // prints 5
cout << " preincrementing c: " << ++c << endl; // prints 6
cout << " c after preincrement: " << c << endl; // prints 6
}
(5)
#include <iostream>
using namespace std;
int main() {
#include <iostream>
using namespace std;
int main() {
--row;
cout << endl;
}
}
Chapter 5 :
)1(
#include <iostream>
using namespace std;
int main() {
#include <iostream>
using namespace std;
int main() {
#include <iostream>
using namespace std;
int main() {
#include <iostream>
using namespace std;
int main() {
do {
cout << counter << " ";
++counter;
} while (counter <= 10);
#include <iostream>
using namespace std;
int main() {
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int total=0;
unsigned int gradeCounter=0;
unsigned int aCount=0;
unsigned int bCount=0;
unsigned int cCount=0;
unsigned int dCount=0;
unsigned int fCount=0;
int grade;
case 8:
++bCount;
break;
case 7:
++cCount;
break;
case 6:
++dCount;
break;
default:
++fCount;
break;
}
}
if (gradeCounter != 0) {
cout << "Total of the " << gradeCounter << " grades entered is "
<< total << "\nClass average is " << average
<< "\nNumber of students who received each grade:"
<< "\nA: " << aCount << "\nB: " << bCount << "\nC: " << cCount
<< "\nD: " << dCount << "\nF: " << fCount << endl;
}
else {
cout << "No grades were entered" << endl;
}
}
)7(
#include <iostream>
using namespace std;
int main() {
cout << "\nBroke out of loop at count = " << count << endl;
}
)8(
#include <iostream>
using namespace std;
int main() {
if (count == 5) {
continue; // skip remaining code in loop body if count is 5
}