0% found this document useful (0 votes)
16 views6 pages

Assignment No.3

The document contains an assignment from the Institute of Space Technology, Islamabad, focusing on programming fundamentals in C++. It includes tasks such as printing a message, calculating the sum and product of two numbers, converting temperature from Fahrenheit to Celsius, calculating the area of a circle, and discussing the differences between C and C++. Each task is accompanied by code examples and algorithms outlining the steps involved.

Uploaded by

talha zulfiqar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

Assignment No.3

The document contains an assignment from the Institute of Space Technology, Islamabad, focusing on programming fundamentals in C++. It includes tasks such as printing a message, calculating the sum and product of two numbers, converting temperature from Fahrenheit to Celsius, calculating the area of a circle, and discussing the differences between C and C++. Each task is accompanied by code examples and algorithms outlining the steps involved.

Uploaded by

talha zulfiqar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

INSTITUTE OF SPACE TECHNOLOGY

ISLAMABAD

Assignment No. 3

Introduction to Information Technology


Electrical Engineering Department
Programming Fundamentals

Submitted To:
Haroon Ibrahim
Submitted By:
Noor ul Hassan
Registration No. :
210401078
Task 1: Write a simple program to print “This is the first Cpp lab
of Fundamentals Programming Lab” on screen.
Ans)
#include <iostream>
using namespace std;
int main()
{
cout << "This is the first Cpp lab of Fundamentals Programming Lab";
return 0;
}

Task 2: Calculate the sum and product of the two numbers and
then print the result on screen.
Ans)
#include <iostream>
#include<conio.h>
using namespace std;

int main()
{
int a, b;
cout << "Enter first value=";
cin >> a;
cout << "Enter second value=";
cin >> b;
cout << a << "+" << b << "=" << a + b << endl;
cout << a << "*" << b << "=" << a * b << endl;
}

Algorithm:
Step 1: START
Step 2: Sum and Multiply
Step 3: Sum=a+b, Product=a*b
Step 4: Display Sum and Product
Step 5: Stop

Task 3: Write a C++ program to read temperature in Fahrenheit.


Convert the temperature to Celsius degree by using the formula
c=5/9(f-32).
Ans)
#include <iostream>
using namespace std;
int main()
{
float Celsius, Fahrenhiet;
cout << "Enter the temperature in Fahrenhiet" << endl;
cin >> Fahrenhiet;
Celsius = 5 * (Fahrenhiet - 32) / 9;
cout << "temperature in Fahrenhiet = F " << Fahrenhiet << endl;
cout << "temperature in Celsius = C " << Celsius << endl;
return 0;
}

Algorithm:
Step 1: START Fahrenheit to Celsius
Step 2: Enter temperature in Fahrenheit
Step 3: Write the formula of Celsius=5*(Fahrenheit – 32)/9
Step 4: Enter the value in Fahrenheit
Step 5: Enter the value in Celsius
Step 6: STOP

Task 4: Calculate the area of a circle, (area = Пr2, П=3.14).


Ans)
#include<iostream>;
using namespace std;
int main()
{
float radius, Area;
cout << "\nEnter radius of circle:";
cin >> radius;
Area = 3.14 * (radius * radius);
cout << "\nArea of Circle = " << Area;
cout << endl;
return 0;
}

Algorithm:
Step 1: START Area and Radius
Step 2: Enter radius of Circle
Step 3: Write the formula circle(Area=3.14*radius*radius)
Step 4: Enter Area of Circle
Step 5: Display Area
Step 6: Stop
Task 5: If C++ and C are high level languages? If yes, then
comment on it. Also, state difference between C++ and C
language.
Ans)
C++ is still known as a high-level language, but with the arrival of
latest languages (Java, Ruby etc..), C++ is beginning to be
assembled with lower languages.
There are conditions in which C can be either high level, mid-
level or low level, which is stated as
If you’re an assembly language programmer then C is a high-
level language.
If you’re writing scripts in Perl or Python, then C is a mid-level
language.
If you are doing object-oriented programming in Java or C#, then
C is a low-level language.
Differences b/w C++ and C
Key C C++
Intro C was developed by Dennis C++ was developed by
Ritchie in around 1969 at Bjarne Stroustrup in 1979.
AT&T Bell Labs.
Language As mentioned before C is On the other hand, C++
Type procedural programming. supports both procedural
and object-oriented
programming paradigms
OOPs As C does not support the C++ has support for
feature OOPs concept so it has no polymorphism,
Support support for polymorphism, encapsulation, and
encapsulation, and inheritance as it is being an
inheritance object-oriented
programming language
Data As C does not support On another hand in the
Security encapsulation so data case of C++ encapsulation
behave as a free entity and hides the data to ensure
can be manipulated by that data structures and
outside code. operators are used as
intended.
Driven C in general known as On the other hand, C++ is
type function-driven language. known as object driven
language.

Feature C does not support function On the other hand, C++


supported and operator overloading supports both function and
also do not have operator overloading also
namespace feature and have namespace feature
reference variable and reference variable
functionality. functionality.

You might also like