(249524) CP Lab #1
(249524) CP Lab #1
AIR UNIVERSITY
LAB REPORT
Objective:
LAB ASSESSMENT:
Total Marks:
Obtained Marks:
1
Computer programing LAB # 1
Data presentation
Experimental results
Conclusion
Date: Signature:
2
Computer programing LAB # 1
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:
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 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.
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.
(float) is used to perform arithmetic operations, in which we can get the output in the
form of decimal,
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:
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:
Lab Conclusion: