Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Overig

C++ Lab Practice Exercises With Solutions

Beoordeling
-
Verkocht
-
Pagina's
65
Geüpload op
14-11-2022
Geschreven in
2021/2022

These documents are full lab work. There is a questions section and there is an answers section. It includes all the work and solutions in this course. These documents are very important for learners of the c++ programming course and will fully develop their skills.

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

AMERICAN UNIVERSITY OF SCIENCE & TECHNOLOGY
FACULTY OF ARTS AND SCIENCES




CSI205 – Programming I Lab
All Sections

Fall Term 2021-2022

Lab Work 1

Part 1 - Introduction
I. Introduction to Computer Programming I Lab (CSI205L) objectives and
requirements.
II. Explanation of lab policies and procedures, as well as lab syllabus and grading
policy. (Read and explain the syllabus in details)
III. Work on the C++ environment to show students the following steps:
1. Create a new Win32 Console Application empty project
workspace.
2. Type and save the following C++ program as “Program1.cpp”.

#include <iostream>
using namespace std;
int main( )
{

system("pause");
return 0;
}

3. Compile, link and execute the program. (explain each step)
4. Type “Return 0” instead of “return 0” and ask students to repeat
step3. Show students how to correct the compilation mistakes till
they are able to execute the program.
5. Type “int Main” instead of “int main” and ask them to repeat step
3. Show students the difference between the linking and
compilation errors.
6. Ask the students to remove “system("pause");”, and to repeat
step 3. Discuss with students the program execution results.
1

,Part 2 – Practice

1. Create a new Win32 Console Application empty project
workspace.
2. Type and save the following C++ program as “Program2.cpp”.

#include <iostream>
using namespace std;
int main( )
{
cout<<"American University of Science & Technology\n\n";
cout<<"Department Of Computer Science\n\n\n";
cout<<"CSI205L – Programming I Lab\n";
cout<<"Fall 2020/2021\n";
system("pause");
cout<<"\nWelcome to the Microsoft Visual Studio 2013 C++
programming environment";
cout<<"\n\nCSI205L First Lab Session\n";
system("pause");
system("pause");
cout<<"GOOD LUCK ALL\n";

system("pause");
return 0;
}

3. Compile, link and execute the program. Discuss with students the program
execution results.


Part 3 – Write Program:
Write a C++ program to output AUST in block letters using asterisks.




2

, 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
}




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;
3

, 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;
}



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.

4

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
14 november 2022
Aantal pagina's
65
Geschreven in
2021/2022
Type
OVERIG
Persoon
Onbekend

Onderwerpen

€7,98
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
huss21

Maak kennis met de verkoper

Seller avatar
huss21 American University of science and technology
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
3 jaar
Aantal volgers
0
Documenten
0
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen