You are on page 1of 12

Computer fundamentals and

programming
Lab report
Lab-4

Electrical Engineering (section-B)


Registration No:
BSEE-12637-2020

Submitted by:
Muhammad Huzaifa Zahid
Submitted to:
Madam Maryam Asad & Madam Maliha Amin
Task-1

Coding:
#include<iostream>
using namespace std;
int main()
{
system("color 70");
int T;
cout << "enter the value of temperature = ";
cin >> T;
if (T < 0)
{
cout << "freezing weather";
}
else if (T >= 0 && T < 10)
{
cout << "very cold temperature";
}
else if (T >= 10 && T < 20)
{
cout << "cold weather";
}
else if (T >= 20 && T < 30)
{
cout << "normal temperature";
}
else if (T >= 30 && T < 40)
{
cout << "its hot";

}
else if (T >= 40)
{
cout << "its very hot";
}

getchar();
getchar();
return 0;
}
Output:

Task-2
Coding:
#include<iostream>
using namespace std;
int main()
{
system("color 70");
int A, B, remainder;
cout << "enter the value of A = ";
cin >> A;
cout << "enter the value of B = ";
cin >> B;
remainder = A%B;
if (remainder != 0)
{
cout << "if A is not completely divided by B ";
cout << "remainder is = " << remainder;

}
getchar();
getchar();
return 0;
}

Output:
Task-3
Coding:

#include<iostream>
using namespace std;
int main()
{
system("color 70");
float A;
float B;
float C;

cout << "put the value of A = ";


cin >> A;
cout << "put the value of B = ";
cin >> B;
cout << "put the value of C = ";
cin >> C;
if (A < B && A<C)
{
cout << "A is smallest " << A;
}
if (B < A && B < C)
{
cout << "B is smallest " << B;

}
if (C < A && C < B)
{
cout << "C is smallest " << C;
}
getchar();
getchar();
return 0;
}

Output:

Task-4
Coding:

#include<iostream>
using namespace std;
int main()
{
system("color 70");
float X,Y;
cout << "put the value of X = ";
cin >> X;
cout << "put the value of Y = ";
cin >> Y;

if (X == 0 && Y == 0)
{
cout << "coordinate lies on orign";
}
else if (X > 0 && Y > 0)
{
cout << "the coordinate lies in first quadrant";
}
else if (X < 0 && Y>0)
{
cout << "the coordinate lies in second quadrant";

}
else if (X < 0 && Y < 0)
{
cout << "the coordinate lies in third quadrant";
}
else if (X>0 && Y < 0)
{
cout << "the coordinate lies in forth quadrant";
}

getchar();
getchar();
return 0;
}

Output:

Task-5
Coding:

#include<iostream>
using namespace std;
int main()
{
system("color 70");
int A;
cout << "put the value of A = ";
cin >> A;
int result;
result = A % 9;

if (result ==0)
{
cout << "A is a multiple of 9 ";
}
else
{
cout << "A is not a multiple of 9 ";
}
getchar();
getchar();
return 0;
}

Output:

Task-6
Coding:
#include<iostream>
using namespace std;
int main()
{
system("color 70");
int marks;
cout << "enter the marks = ";
cin >> marks;
if (marks < 0 || marks>100)
{
cout << "marks are incorrect";
}
else if (marks>=0 && marks < 50)
{
cout << "fail";

}
else if (marks >= 50 && marks <= 60)
{
cout << "D";
}
else if (marks >= 61 && marks <= 70)
{
cout << "C";
}
else if (marks >= 71 && marks <= 80)
{
cout << "B";
}
else if (marks >= 81 && marks <= 100)
{
cout << "A";
}

getchar();
getchar();
return 0;
}

Output:
Task-7
Coding:

#include<iostream>
using namespace std;
int main()
{
system("color 70");
int A,B, remainder;
cout << "enter the value\n";
cin >> A;
B = 2;

remainder = A % B;
if (remainder == 0)
{
cout << "number is even ";
}
else
{
cout << "number is odd";
}
getchar();
getchar();
return 0;
}

Output:
Task-8
Coding:
#include<iostream>
using namespace std;
int main()
{
system("color 70");
int angle_a, angle_b, angle_c, sum;
cout << "enter value of angle a\n";
cin >> angle_a;
cout << "enter the value of angle b\n";
cin >> angle_b;
cout << "enter the value of angle c\n";
cin >> angle_c;
sum = angle_a + angle_b + angle_c;
if (sum == 180)
{
cout << "triangle is valid ";
}
else
{
cout << "triangle is not valid";
}
getchar();
getchar();
return 0;
}

Output:

Task-9
Coding:
{
system("color 70");
int year, remainder;
cout << "Enter a year\n";
cin >> year;

remainder = year % 4;
if (remainder == 0)
{
cout << year << " is a leap year.";
}
else
{
cout << "it is not a leap year";
}

getchar();
getchar();
return 0;
}

Output:

#include<iostream>
using namespace std;
int main()
{
system("color 70");
int a, b, c, disc;
cout << "enter the value of a\n";
cin >> a;
cout << "enter the value of b\n";
cin >> b;
cout << "enter the value of c\n ";
cin >> c;
disc = (b*b) - (4 * a*c);
if (disc = 0)
{
cout << "roots are equal";
}

getchar();
getchar();
return 0;
}

You might also like