Please Hand in: Printout of your C++ program with a heading comment. Do not forg
ID: 640181 • Letter: P
Question
Please Hand in:
Printout of your C++ program with a heading comment. Do not forget to add space and indentation.
Copy of a screenshot after your program is executed.
Observe the behavior of the program and describe it in plain English what is done in each section of
the program.
/*
ELEN 1301-02
Name : Name.
Student ID : 20303649.
Due date : February 10, 2015
Purpose of the program : Observe, and describe the behavior of a program.
*/
void main() {
// Section 1.
cout << "Please add 5 to the last digit of your student ID and enter : ";
cin >> id;
cout << endl;
// Section 2.
for (i = 1; i <= id; i++)
// Section 3.
for (i = 1; i <= id; i++)
t += i;
} // main
Explanation / Answer
//observing the integer in various conditins in an loops
#include
using namespace std;
void main() {
int i, id, t = 0;
// Section 1.
cout << "Please add 5 to the last digit of your student ID and enter : ";//adding 5 followed by your id
cin >> id;//reading id from user
cout << endl;
// Section 2.
for (i = 1; i <= id; i++)//braces not using....i iterates until condition met(<=id)
cout << i << " ";//print i every time
cout << endl << endl;
// Section 3.
for (i = 1; i <= id; i++)//braces not using....i iterates until condition met(<=id)
t += i;//incrementing t
cout << t << endl << endl;/printing t
} // main
section one reading input from user...
second section printing all ids upto your id
third section same as above except uodating extra variable t ..incrementing by one