0% found this document useful (0 votes)
15 views2 pages

CS100 HW6

Uploaded by

Olivia Harp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

CS100 HW6

Uploaded by

Olivia Harp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS 100 Bradley University Dept.

of Computer Science &


Instructor: Tachun Lin Spring 2021 Information Systems

Introduction to Programming Concepts and Languages: HW#6

1. (4 pts) Given a variable x. Show the four different ways that we can increment x by
1.

2. (1 pts) What would happen if we have the following while loop in our program?

while(true)
{
cout << "Hi";
}

3. (3 pts) Write a program which prints out letters ’K’ to ’R’. Use a while loop to
achieve it.

4. (3 pts) Write a program which does the following.

(a) Prompt the user to input an integer value count.


(b) Print out count number of ’*’ in one row.

For example, if you enter 3, the program prints out ***.


Note: Use a for loop to achieve it.
Hint: The for loops we have written so far only use a fixed number as the upper/lower
bound. Here, you are going to use the value in the varriable as the bound.

5. (1 pts) Explain what the following program does.

#include <iostream>
using namespace std;
int main()
{
for(int i=1; i<3; i++)
{
for(char j=’a’; j <= ’c’; j++)
{
cout << i << j << endl;
}
}
}

6. (5 pts) Write a program to calculate your GPA. The program will do the following.

1
CS 100 Bradley University Dept. of Computer Science &
Instructor: Tachun Lin Spring 2021 Information Systems

(a) Prompt the user how many courses/grades you would like to calculate.
(b) Use a loop (for or while) to accept the inputs of the grades.
(c) Sum up all the grades.
(d) Your GPA (based on the grades you enter) is calculated by

The sum of your grades


GPA =
The number of courses/grades you entered
(e) Print out your GPA.

You might also like