0% found this document useful (0 votes)
14 views9 pages

(249524) CP Lab #1

The lab report introduces programming concepts using C++, focusing on the importance of programming, compilers, and basic coding practices. It includes tasks that require writing programs for input/output operations, arithmetic calculations, and utilizing libraries. The conclusion highlights the skills learned, such as using libraries, performing arithmetic operations, and understanding basic input/output functions.

Uploaded by

awkhan515.69
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)
14 views9 pages

(249524) CP Lab #1

The lab report introduces programming concepts using C++, focusing on the importance of programming, compilers, and basic coding practices. It includes tasks that require writing programs for input/output operations, arithmetic calculations, and utilizing libraries. The conclusion highlights the skills learned, such as using libraries, performing arithmetic operations, and understanding basic input/output functions.

Uploaded by

awkhan515.69
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/ 9

Computer programing LAB # 1

AIR UNIVERSITY

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

LAB REPORT

Lab Title: Introduction to programming.

Student Name: ABDUL WAHAB Reg. No: 249524.

Objective:

 To know the importance of programming.


 To know about C++ compilers.
 To learn how to write a simple code in C++.
 To learn what does the compiler do in different situations.
 To learn how to add comments in your code.
 To learn how to take input from user.
 To learn how to display anything (output) on console. Description

LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes (5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks:

Obtained Marks:

1
Computer programing LAB # 1

LAB REPORT ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained


Marks:

Date: Signature:

2
Computer programing LAB # 1

Course: CE112L Computer Programming


Lab Report 1

Submitted To: Mam. Saba Mumtaz


Submitted By: ABDUL WAHAB
Registration number: (249524)

Lab Objective:
 To know the importance of programming.
 To know about C++ compilers.
 To learn how to write a simple code in C++.
 To learn what does the compiler do in different situations.
 To learn how to add comments in your code.
 To learn how to take input from user.
 To learn how to display anything (output) on console. Description

Task 1:
Write a program that displays the following output on screen.
She asked, \“Are you alright?”\
He replied.“Yes! I’m fine”

Solution :

3
Computer programing LAB # 1

Result:

Explanation:

 We have used 2 libraries to perform this task


 (#include <iostream> )
It is used to perform input and output operations in a code.

 (using namespace std; )


It is used to avoid standard library names. And it is used at this starting point to avoid
the repetition of library name in every line.

 These are the basic algorithms used to perform a basic task on “DEV C++”.

 In this task we have used [int main()] main function is used to execute the program.

 We are using (cout) to print the data.

 (cin) is used to receive data from the user.

 ( return 0 ) is used to end the program.

 In this we have printed the given data. Which contain simple and special characters.

4
Computer programing LAB # 1

Task 2:

Write a program that declares two variables, perform any arithmetic operation on the main
obtain a float output whatever the inputs are.

Solution:

Result:

5
Computer programing LAB # 1

Explanation:
 We have used 2 libraries to perform this task
 (#include <iostream> )
It is used to perform input and output operations in a code.

 (using namespace std; )


It is used to avoid standard library names. And it is used at this starting point to avoid
the repetition of library name in every line.

 These are the basic algorithms used to perform a basic task on “DEV C++”.

 In this task we have used [int main()] main function is used to execute the program.

 In this we have created integers using (int) function. To get the data stored in the integers.

 We are using (cout) to print the data.

 (cin) is used to receive data from the user.

 (float) is used to perform arithmetic operations, in which we can get the output in the
form of decimal,

 ( return 0 ) is used to end the program.

 In this we have performed a division operation using (float).

6
Computer programing LAB # 1

Task 3:
Write a program in C++ that takes 2 inputs from user, divide them, and displays the division
result at the output?
Output Console should look like this:
Enter 1 number: 6
st

Enter 2 nd number: 3
6/3 = 2
Solution:

Result:

7
Computer programing LAB # 1

Explanation:

 Most of the explanation is same as mentioned in the above task no. 2.


 In this code we are using two numbers from the user.
 Calculates their division.
 And prints the result along with the mentioned instructions in the lab task.
 It demonstrates basic input and output fumction.

Task 4:

Write a program that declares 2 variables and display the result of their addition,
subtraction, multiplication, and division at the output console.

Solution:

8
Computer programing LAB # 1

Result:

Explanation:

 The program includes the iostream library for input-output operations.


 It uses the (namespace) library to avoid standard library names.
 The main function starts the execution of the program.
 It performs addition, subtraction, multiplication, and division on the input numbers as
required by the lab manual.
 The results of these operations are printed to the console.
 In this we have taken the data from the user and performed various arithmetic operations
as described on the lab manual.

Lab Conclusion:

In this lab we have learnt:


1. How to use different libraries such as; iostream, namespace etc.
2. Different operations. (addition, subtraction, division, multiplication).
3. Function of (cout) and (cin).
4. Function of (int), (float).
5. How to print data.

You might also like