Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views3 pages

Programming Lab Exercises

Csi

Uploaded by

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

Programming Lab Exercises

Csi

Uploaded by

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

AMERICAN UNIVERSITY OF SCIENCE & TECHNOLOGY

FACULTY OF ENGINEERING

CSI205L – Programming I Lab


Section R

Spring Term 2023-2024


Lab Work 2

Problem 1: Find the errors and correct them.

#include <iostream> #include <iostream>


using namespace std; using namespace std;
int main() int main{ }
{ (
x=0; int x = 3;
cout<<x; cout<<x;
system("pause"); Return 5;
return 0; )
}

#include <iostream> #include <iostream>


using namespace std; using namespace std;
int main() int Main()
{ Int x; {
x=3; float y;
cout<<x; y=5.02;
} cout<<y;
return 10
}

1
Problem 2: What is the output of the following programs?

#include <iostream>
using namespace std;
int main()
{
float n ;
n=2.0 ;n=n*n ;
n= n*n ;
n=n*n;
cout<<"n = "<<n<<"\n";
system("pause");
return 0;
}

#include <iostream>
using namespace std;
int main()
{
int day, month, year ;
day=05; month=10;
year = 2020;
cout<< "Day\tmonth\tyear\n";
cout<< "---\t-----\t----\n";
cout<<day<<"\t"<< month<<"\t"<< year<<endl;

system("pause");
return 0;
}

Problem 3:
Fill in the blanks with the missing C++ statements that find the average of three given
grades:

//this c++ program calculates and outputs the average:

#include <iostream>
using _____________ std;
int main()
{ int G1,G2,G3;
double Avg;
G1=75; G2=80;
G3= 90;

Avg = _________________;

cout<<"The grades are: "<<____<<____<<____<<"\n";


cout<<”the average =”<<________________________;

system(_________);
return 0;
}

2
Problem 4:
Type the following program then apply the below listed steps:

//this c++ program output the measurement units values


#include <iostream>
using namespace std;
int main()
{
cout<<"measurements units\n";
cout<<"------------ -----\n\n";
cout<<"1m = 100cm"<<endl;

system("pause");
return 0;
}
1. Compile, link then execute the program.
2. Type a cout statement to display "1m = 1000mm";
3. Type a cout statement to display "1m = 39.37 inches";
4. Modify the program to show the same output using only one cout statement.

Problem 5:
Write a C++ program to output three lines of five asterisks using five output
statements. Repeat this with one output statement.

Problem 6:
Write a C++ program that will print the phrase “So far, so good" vertically using a
cascaded cout statement:
S s
o o
f g
a o
r o
, d

Problem 7:
Write a C++ program that will ask the user to input the side size of a square. The
program should compute and output the square area.

You might also like