Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Report-1

Course Code: CSE-3316


Course Title: Compiler Design and Construction Sessional

Submitted To:

Zumana Islam Mou


Adjunct Lecturer
Department of Computer Science & Engineering
Leading University, Sylhet

Submitted By:

Md. Abul Khair


Student ID: 2012020339
Section: 53(G)
Department of Computer Science and Engineering
Leading University, Sylhet

Date of Submission: 02-08-2023


#include <iostream>
using namespace std;

int main()

{
// Declare four string variables to store user input
string w, x, y, z;

// enter their name


cout << "Enter your name:";
// Read the entire line of input, including spaces
getline(cin, w);
cout << endl;

// enter their university name


cout << "Enter your university name:";
// Read the entire line of input, including spaces
getline(cin, x);
cout << endl;

// enter their section


cout << "Enter your section:";
// Read the entire line of input, including spaces
getline(cin, y);
cout << endl;

// enter their student ID


cout << "Enter your student ID:";
// Read the entire line of input, including spaces
getline(cin, z);
cout << endl;

// Display the collected information with labels


cout << "Your Name: " << w << endl
<< "University: " << x << endl
<< "Section: " << y << endl
<< "ID: " << z << endl;

// Indicate successful program execution by returning 0


return 0;
}
Here is an explanation of the code:

Line 1: This line includes the iostream header file, which provides the cout and cin objects that
are used to print and read text from the console.

Line 2: This line uses the using namespace std; statement to import all the names from the std
namespace into the current scope. This means that we can refer to the cout and cin objects
without having to prefix them with std::.

Line 4: This line declares four string variables to store the user's name, university name, section, and
student ID.

Line 6: This line prompts the user to enter their name.

Line 7: This line uses the getline() function to read the entire line of input, including spaces. The
getline() function takes two arguments: the first argument is a reference to a string object, and the
second argument is a reference to an input stream object. In this case, the first argument is the w
variable, and the second argument is the cin object.

Line 8: This line prints a newline character to the console.

Lines 9-12: These lines are similar to lines 6-8, except that they prompt the user to enter their
university name, section, and student ID.

Lines 14-18: These lines display the collected information with labels. The cout object is used to
print the text to the console.

Line 19: This line returns 0 to indicate that the program has executed successfully.

You might also like