Introduction To Computing Lab (CPEN-1214) : Department of Mechanical Engineering
Introduction To Computing Lab (CPEN-1214) : Department of Mechanical Engineering
Introduction To Computing Lab (CPEN-1214) : Department of Mechanical Engineering
Engineering
(CPEN-1214)
Lab Manual
1. Introduction to Computer:
Software
2. Types of Software
System software:
4. Computer Programming
Process of writing or editing source code.
Person called computer programmer/software developer/coder.
Lengthy process of computer programming is referred to as software
development.
5. Programming languages
Languages use to write, and code computer programs.
It is vocabulary & set of grammatical rules for instructing a computer.
Examples: BASIC,C,C++, COBOL,java,Fortran, ada& Pascal
We are going to learn C++ programming language in this lab
6. Dev C++
C++ is high level programming language, while computer only understands
machine language.
To successfully run and execute computer program we need a compiler to convert
source code to object code so that computer can understand it.
We are using Dev C++ compiler for this purpose in lab
7. Practice exercise
Install Dev C++ in your PC’s.
Create and save a new file in Dev C++. As introduction to computing Lab.
Scale
Unable to use
Quite able to utilize
modern tools on
Skill to perform test modern tools to Able to use modern
Able to use modern his own and lab
programming perform program tools with some help
tools with a lot of help instructor
2 (PLO-05, with negligible help from the lab
from the lab instructor. provides help in
Psychomotor Domain) from the lab instructor.
almost every step
instructor.
of the experiment.
Scale
Table 1: Viva Voce
Sr.# Performance Exemplary Satisfactory Developing Unsatisfactory
Indicator (5 Marks) (4-3 Marks) (2-1 Marks) (0 Marks)
Scale
Lab Session # 02
Introduction to C++: Basic I
Objective:
9. Program Structure:
#include<iostream> // allows program to output data to screen
using namespace std;
int main () // Function main begins program execution
{
cout<< "Welcome to Introduction and computing Lab”; // display message
return 0; // indicate that program ended successfully
} // ended function main
---------------------------------------------------------------------------------------------------
Process exited after 18.97 seconds with return value 0
Press any key to continue .….
1.
function.
int Main()
It indicate that main returns an integer(whole number) value.
{ leftbrace_function begins.
} right brace_ function ends.
First number = 2
3. 2nd number = 2
4. Answer is = 4
---------------------------------------------------------------------------------------------------
Process exited after 12.87 seconds with return value 0
Press any key to continue .….
Welcome
To
Programming
return 0;
}
Welcome
To
Programming
---------------------------------------------------------------------------------------------------
Process exited after 12.87 seconds with return value 0
Press any key to continue .….
6.
return 0;
}
Welcome
Output Window of Task-4
To
Programming
---------------------------------------------------------------------------------------------------
Process exited
Introduction to after 12.87 Lab
computing seconds with return value 0
Press any key to continue .….
7.
Task-5: Print out like below.
Hello
My Name is ‘Hafiz Ali’
I am student of Mechanical Engineering
My roll number is ME 1810060
Program to print out a text.
#include<iostream>
using namespace std;
int main ()
{
return 0;
}
Scale
Unable to use
Quite able to utilize
modern tools on
Skill to perform test modern tools to Able to use modern
Able to use modern his own and lab
programming perform program tools with some help
tools with a lot of help instructor
2 (PLO-05, with negligible help from the lab
from the lab instructor. provides help in
Psychomotor Domain) from the lab instructor.
almost every step
instructor.
of the experiment.
Scale
Table 1: Viva Voce
Sr.# Performance Exemplary Satisfactory Developing Unsatisfactory
Indicator (5 Marks) (4-3 Marks) (2-1 Marks) (0 Marks)
Scale
Lab Session # 03
Basic Arthimethic Statements and Expression
Objective
Task 1 : Write C++ Program that will find the value of “a” by using following
equation where b=5 and c=6
d=b+c
e=d-b
f=e*d
g=f/c
a=(2*g)/5
Program task 1
#include <iostream>
Int main ()
‘Task 2: Write a C++ program that will enter width and length of a rectangle
Program task 2
#include <iostream>
Task 3 Write a C++ program that will enter value of “a” from user where a is
integer and find the value of b
b=a+2/a*(5+6)
program task 3
Task 4: Write a C++ program that will asks user his year of birth and tell him
his approximate age.
Program task 4
#include<iostream>
Task 5: Write a C++ program that will asks user about item for which he want
to calculate profit and profit percent also he ask user to about sale price and
cost price of that item.
Program task 5
#include <iostream>
Introduction to computing Lab
Using namespace std;
int main ()
{ int c,s,p;
Cout<<”cost price of item =”;
Cin>>c;
Cout<<”sales price of item =”;
Cin<<s;
P=s-c;
int mul = p*100;
int div = mul /c;
cout<<”your profit is =”<<p<<”your profit percent is =”<<div;
return 0;
}
Task 6:Write a c++ program that will calculate aggregate of student for
admission enengineering according to UET LHR criteria ,70% goes from Fsc
(Total 1100) and 30% from ECAT (Total 400)
Program task 6
#include <iostream>
Task 7: Write a C++ program that will enter value of a and b from user and find
value of (a-b)3
Where as (a-b)3=a3-3a2b+3ab2-b3
Program task 7
#include<iostream>
Task 8: Write a c++ program that that input two numbers from user and will
perform summation ,subtraction , multiplication on numbers.
Program task 8
#include <iostream>
Using namespace std;
If-else statement
If statement can be followed by an optional,which excutes when the Boolean expression is
true
Syntax
If (Boolean-expression )
{} //statement will execute if Boolean expression is true
else
{} //statement will excute if Boolean expression is true
If (Boolean-expression)
{} //statement will excute if Boolean expression is true
else
{} // statement will execute if Boolean expression is true
If the Boolean expression evaluates to true ,then the if block of ode will be executed
,otherwise else block of code will be executed
Program
#include <iostream>
Using namespace std;
int main ()
{ int a;
Cout <<”enter number “;
Cin>>a;
If (a<20)
Cout<<”you are good”;
else
Cout<<”you are Bad”;
return 0;
}
If-else-If….else Statement
If statement can be followed by an optional else if…else statement ,which is very useful to
test various conditions using single if ..else if statement
Syntax
If (Boolean –expression 1 )
{} //executes when the Boolean expression 1 is true
else if (Boolean-expression)
{} //executes when the Boolean expression 2 is true
else if (Boolean-expression)
{} //executes when the Boolean expression 3 is true
else
{} //executes when the none of above condition is true
Program
#include <iostream>
Using namespace std;
Int main ()
{ int a;
Cout<<”enter number=”;
Cin>>a;
If (a==20)
Cout<<”you are good’;
else if (a==40)
Cout<<”you are very good”
else if (a==60)
Cout<<”you are Bad”;
else
Cout<<”you are very Bad”;
return 0;
}
Program task 1
#include <iostream>
using namespace std;
int main ()
{ int a;
Cout<<”enter number”;
Cin>>a;
If (a>40)
Cout<<”pass”<<endl;
else
Cout<<”not pass”<<endl;
return 0;
}
Task-2: Write a C++ program that will “pass” if marks are greater than 40
otherwise print “fail”.
Program task 2
Introduction to computing Lab
#include<iostream>
using namespace std;
int main ()
{ int a;
Cout<<”enter number”;
Cin>>a;
If (a>40)
Cout<<”pass”<<endl;
else
Cout<<”fail”<<endl;
return 0;
}
Task-4 :Write a C++ program that will declare a number as positive ,negative
or zero.
Program task 4
#include <iostream>
Task-5: Write a C++ program that will check whethera numberis even or not.
Program task 5
#include <iostream>
using namespace std;
Task-6 : Write a c++program that will enter a number and check whether it is
divisible by 8 or not.