Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
283 views

Fundamentals of Programming: Lab Practical Week 1 Objective

The document provides instructions for students on completing their first programming lab assignment in C++. It includes directions on downloading and installing an IDE, writing a "Hello World" program, performing basic arithmetic and input/output operations, using different operator types like increment/decrement, relational, and assignment operators, and examples of programs to develop for exercises using these new programming concepts.

Uploaded by

Ali Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
283 views

Fundamentals of Programming: Lab Practical Week 1 Objective

The document provides instructions for students on completing their first programming lab assignment in C++. It includes directions on downloading and installing an IDE, writing a "Hello World" program, performing basic arithmetic and input/output operations, using different operator types like increment/decrement, relational, and assignment operators, and examples of programs to develop for exercises using these new programming concepts.

Uploaded by

Ali Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Fundamentals of Programming Lab Week 1 Page 1

Fundamentals of Programming
Lab Practical week 1
Objective:
The install IDE and compile your first program.

Download & Install:


Download software from following link
https://drive.google.com/open?id=1KkZiWsQulJRvppCIVP7i4-YXoWwPyhX7
Right click the file and click Run as administrator.
Select English language, agree the terms, click next and install the software and upon
completion, click Run DevC++ and click finish.

First time Run:


Select English(Original) and click next
Click next leaving the options as it is, and press ok.
Now you are ready to write your first C++ program

First Program:
“Hello World”

Click on the File tab in top left corner and create new Source file.
Write the following code (always keep in mind that C++ is case-sensitive language, for
example if you typed Include instead of include the compiler will report error)

//HelloWorld.cpp
/* This is my first C++ program.
*/
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}// End of Program

When you are done with code writing, compile and run the file by pressing F11.

City University of Sciences and Technology Peshawar Furqan Nasir


Fundamentals of Programming Lab Week 1 Page 2

A window will pop up, asking you to select place to save the file and give it name,
remember give name keeping in mind the working of program and add extension .cpp at
the end of program name. Click save and you will see the following

Exercise:
1. Try printing the following strings, what do they do?
1. "Hello \t World"
2. "Hello \n World"

2. Change the HelloWorld.cpp program so that it displays AssalaMu AlaiKum! Instead of


Hello World!

City University of Sciences and Technology Peshawar Furqan Nasir


Fundamentals of Programming Lab Week 1 Page 3

Arithematic Operators
Arithmetic operators are the symbols that represent arithmetic math operations.
Examples include + (addition operator), - (subtraction operator), * (multiplication
operator), / (division operator) and %(remainder operator).

Program:

Program:

City University of Sciences and Technology Peshawar Furqan Nasir


Fundamentals of Programming Lab Week 1 Page 4

Result:

For taking input from user, first we declare variable(int a;) and then following command
takes input from user

cin>>a;

so a will have the value given at console by user.

Exercise:
1. Make calculator performing addition, subtraction, multiplication, division and finding
remainder taking inputs from user.
2. Develop a temperature conversion program taking temperature in Fahrenheit and
converting it into Celsius.

Conversion Formula: Celsius= (Fahrenhrit - 32) *5/9

City University of Sciences and Technology Peshawar Furqan Nasir


Fundamentals of Programming Lab Week 1 Page 5

Some other operators

++ (Increment)
-- (Decrement)
+= (Increment Assignment)
-= (Decrement Assignment)
*= (Multiplication Assignment)
/= (Division Assignment)
%= (Remainder Assignment)
Increment and Decrement operators can be used in two ways, i.e.
i) Prefix
ii) Postfix

Program

City University of Sciences and Technology Peshawar Furqan Nasir


Fundamentals of Programming Lab Week 1 Page 6

Relational Operators
A relational operator compares two values. Comparisons involved in relation operators
can be
i) < Less than
ii) > Greater than
iii) == Equals to
iv) != Not equals
v) <= Less than or equals
vi) >= Greater than or equals
The result of comparison is either True or False. If a comparison provides 1, it
means True and if it provides 0, it means False.

Program:

City University of Sciences and Technology Peshawar Furqan Nasir

You might also like