Você está na página 1de 9

CS-114 Fundamentals of Programming (2+1)

DE-41 EE Semester 1
Fall 2019

LAB REPORT # 01

Submitted by Roll No

Talha Bin Riaz 00000294666


Syndicate A-

Instructor In-charge: Dr. Saad Rehman

DEPARTMENT OF ELECTRICAL ENGINEERING


College of Electrical and Mechanical Engineering (CEME)
National University of Sciences and Technology (NUST)
Lab Number: 1
Lab Title: Variable Declaration
Aim: To Study The Types Of Data, Variable Declaration And Simple Arithmetic Operations

Topic(s) covered:

1- Data Types
2- Variable Declaration
3- Arithmetic Operations

(Tasks starting from next page)


TASK 1:

Write a C++ program to print the following lines:


You are 10 years old.
You are too young to play the game.

Code:

#include<iostream>

using namespace std;

int main()

cout << "You are 10 years old" << endl;

cout << "You are too young to play the game" << endl;

cin.get();

return 0;

OUTPUT :
TASK 2:

Write five C++ statements to print the asterisk pattern as shown below.
*
**
***
****
*****

Code:

#include <iostream>
using namespace std;
int main()
{
cout << "*" << “\n**” << “\n***” << “\n****” << “\n*****” << endl;
cin.get();
return 0;
}
OUTPUT:

TASK 3:
Declare two integers and one float variable. Assign (initialize them to) 10, 15, and 12.6
to them respectively.

Code:
#include<iostream>
using namespace std;
int main()
{
//declaring variable and float//
int a, b;
float c;
//initializing//
a = 10;
b = 15;
c = 12.6;
system("pause");
return 0;
}
OUTPUT:

TASK 4
Take two integers as input from the user apply arithmetic operations on them(+,-,*,/)
and print them on screen.

Code:

#include<iostream>
using namespace std;
int main()
{
double a, b;
int sum, sub, mult;
double div;
cin >> a >> b;
sum = a + b;
cout << "sum " << sum << endl;
sub = a - b;
cout << "sub " << sub << endl;
mult = a*b;
cout << "mult "<< mult << endl;
div = a / b;
cout << "div "<< div << endl;
system("pause");
return 0;
}

OUTPUT :
TASK 5:
Give meaningful names and appropriate data types for the following variables.

A variable to store the price of an item.


A variable to store the number of juice bottles.
A variable to store the number of miles traveled.
A variable to store the count of students.
A variable to store an alphabet.

Code:

#include<iostream>
using namespace std;
int main()
{
double PriceOfItem;
int JuiceBottles;
float MilesTravelled;
int CountOfStudents;
char Alphabet;
system("pause");
return 0;
}
OUTPUT:

Conclusion:
In this lab we have learned about Data Types ,Variable And Basic Arithmetic Operations.

Você também pode gostar