0% found this document useful (0 votes)
35 views

C++ Performance Act2

The document contains two C++ programs that use for loops. The first program asks the user to input a number and then prints that many stars. The second program prints all even numbers from 2 to 20. Both programs use a for loop to iterate through a range of numbers and print output each iteration. The questions ask the user to explain the output of each program and provide code to print a name multiple times.

Uploaded by

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

C++ Performance Act2

The document contains two C++ programs that use for loops. The first program asks the user to input a number and then prints that many stars. The second program prints all even numbers from 2 to 20. Both programs use a for loop to iterate through a range of numbers and print output each iteration. The questions ask the user to explain the output of each program and provide code to print a name multiple times.

Uploaded by

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

Name: Section: Date:

Performance Activity #2

Program 1.

cout << "How many stars do you want printed? ";


cin >> num;
cout << "Here are your stars: \n";

for (int i = 1; i <= num; i++)


{
cout << " * ";
}

Question: Execute the program. What is the output of the program? Why?
What is the code if you want to display your name several times?
_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________
Program 2.

cout << "Even numbers from 1 to 20: \n";

for (int num = 2; num <= 20; num += 2)


{
cout << num << " " ;
}

Question: Execute the program. What is the output of the program?


_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________

You might also like