You are on page 1of 6

Department of Mechanical Engineering,

University of Engineering & Technology


Main campus Peshawar,

LAB REPORT #2

Submitted by;
Name : Musaddiq Ahmad

Section : A

Class no: 20

Registration no: 00486

Submitted to;
Dr Fakhar Alam

Lab Date Marks & signature

15-10-2019
Objectives:

 To learn the basic structure of C++program .


 To learn the cout statement in C++ .

Title:
Problem 1:

Write down the C++ program to show the following Text on Screen.

 My name is_________________.
 My registration number is___________.
 I am currently enrolled in 1st semester Mechanical Engineering Department and this is my first C++ coding
program.

Problem analysis:

The problem is to code such a program in which the name of operator, His/her registration number and department in
which he/she is enrolled will be given as output stream and all these information’s will be print out in console. But it is
only possible when there is no error in the program.

Algorithm:

1. Start program.
2. Print the name, registration and department of operator.
3. End program.

Flow chart:

Start

1. Print the name,


registration and
department of
operator.

End
Problem 2:

Write down your first and last name as two different variables, and then print your full name together.

Problem Analysis:

The problem is to use my first and last name as two different variables.I denote my first name as first and the
last name as last . As name contains a lot of letters so I will save the name in string variable which is a type of local
variables. In order to print my name I will use the cout statement.

Algorithm:

There are following steps involve in programming the above problem.

1. Start program.
2. Define variables as: Variable1=Musaddiq variable2=Ahmad
3. Write “My name is ” in cout and follow the statement with variable1 and variable2 .
4. Print the cout statement.
5. End program.
Flow chart:
Start

Variale1=Musaddiq

Variable2=Ahmad

My name is
Musaddiq
AhmadAhmad

End

Figure 1 Prepared in code block C++ compiler


Problem 3:

Define your name, registration no, home address and contact no as different variables types, print your full data
as combination of all these individual variables.

Problem analysis:
The problem is to use my name, registration no , home address and contact no as different variables
types.And then to print them. I will use my name,contact no and address as string variable because the string variable
allow us to use lot of letters .I will use my registration no. as int variable. Finally to print my data I will use cout.

Algorithm:
1. Start the program.

2. Define variable as : string ; Name=Musaddiq ahmad, int; registration no=486,

String; address=kohat road Peshawar, string ;Contact no=03378008762

3. Print the name, address, contact no and registration no.

4. End the program.

Flow chart:

Start

string ; Name=Musaddiq ahmad,

int; registration no=486,

String; address=kohat road Peshawar,

string ;Contact no=03378008762

Print the name,


address, contact no and
registration no.

End
Figure 2 prepared in code block C++ compiler

**

You might also like