0% found this document useful (0 votes)
50 views

IT Final Lab Solution

The document is an exam paper for an Introduction to Information Technology lab course. It contains instructions for students taking the exam, which is to be completed online within 1 hour. Students are to answer 10 multiple choice coding questions by running sample codes and predicting their output. They are also asked to write a function to calculate an electricity bill based on unit consumption and rates. The function must apply surcharges, fees and discounts as outlined in the question.

Uploaded by

rafey h
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

IT Final Lab Solution

The document is an exam paper for an Introduction to Information Technology lab course. It contains instructions for students taking the exam, which is to be completed online within 1 hour. Students are to answer 10 multiple choice coding questions by running sample codes and predicting their output. They are also asked to write a function to calculate an electricity bill based on unit consumption and rates. The function must apply surcharges, fees and discounts as outlined in the question.

Uploaded by

rafey h
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

INSTITUTE OF SPACE TECHNOLOGY

DEPARTMENT OF ELECTRICAL ENGINEERING


108418- Introduction to Information Technology Lab
Batch & Section: BS EE-19 (A & B) Assessment Final/OHT: Lab Final Prepared by (sign): Haroon Ibrahim
Student Registration No.: 200401054 Max Time Allowed: 1 hours (exam solving) + 15 mins (exam
uploading)
Student Full Name: Rafeh Hameed Max Marks: =40 Approved by (sign): Dr. Khurram
Khurshid

❖ Provide your credentials on this question paper.


❖ Turn on your webcams as this is an online exam
❖ Place your notes and other helping materials far from your exam desk
❖ Be sure that you do not possess a mobile or other electronic gadget during the exam time
❖ Leaving your exam place during exam is not allowed
❖ Please go through your exam and ask queries in first 10 minutes of exam
❖ Answer all the questions on Microsoft word and upload on MS Teams.
❖ Save it with file name format (Student Reg no-ITLAB-EE-18-Section)
❖ Cheating by all means is prohibited and any such attempt may leads to serious consequences.

Question # 1 Dry run the code in your mid mentioned the exact outputs within these boxes.[Q Marks-20]

[1] #include<iostream> [2] #include<iostream>


using namespace std; using namespace std;
int main() int main()
{ {
int a=10; int z, x=5, y=-10, a=4, b=2;
cout≪++a≪endl; z=x++ - --y * b/a;
cout≪a++≪endl; cout≪z;
cout≪a--≪endl; system(“pause”);
cout≪--a≪endl; return 0;
system(“pause”); }
return 0;
}
OUTPUT: 11,11,12,10 OUTPUT: 10

[3] #include<iostream> [4] #include<iostream>


using namespace std; using namespace std;
int main() int main()
{ {
int k, num=30; int num=20, num1=3;
k=(num>5? (num≤10?100:200):500); num+=num1;
cout≪num≪k; cout≪num1;
system(“pause”); cout≪num;
return 0; system(“pause”);
} return 0;
OUTPUT: num=30, k=200 }
OUTPUT: num1=3,num=23

12012021 Session-2020 1/3


[5] #include<iostream> [6] #include<iostream>
using namespace std; using namespace std;
int main() int main()
{ {int z=1, d;
int x, y; z+=4;
x=3*7-6+2*5/4+6; cout << z << endl;
y=(3*9*(3+(9*3/(3)))); cout << z++ << endl;
x - -; d=++z;
y++; if((10<d) && (d<13))
cout≪”x”≪y≪endl; cout≪”d”;
system(“pause”); system(“pause”);
return 0; return 0;
} }
OUTPUT: value stored of y in x is 325 or x325 OUTPUT: value in z=5 and d=5

[7] #include<iostream> [8] #include<iostream>


using namespace std; using namespace std;
int main() int main()
{ int grade; {float a=2;
cin≫grade; float b=7.6, c;
if(grade≥60) (∷consider grade=67) c=b/a;
cout≪”passed\n”; a=++c;
else cout≪++a≪endl;
cout≪”failed\n”; cout≪a++≪endl;
cout≪”you must take this course\n”; cout≪c;
system(“pause”); system(“pause”);
return 0; return 0;
} }
OUTPUT: If we put 67 result is passed and in next OUTPUT: at ++a value is 5.8, at a++ value is
line you must take this course 5.8 and at c value is 4.8 or 5.8,5.8,4.8

12012021 Session-2020 1/3


[9] #include<iostream> [10] #include<iostream>
using namespace std; using namespace std;
int main() int main()
{int num=20; {int k=11, kk;
cout≪”num>10=”≪num++≪endl; kk=(k%2==0?k*=1:k%=11);
cout≪”num<10=”≪(num*0.01)*--num ≪endl; cout≪kk;
cout≪”num!=10=”≪num/++num; system(“pause”);
system(“pause”); return 0;} }
return 0; OUTPUT: the output is 0
}
OUTPUT: num>10= 20, num<10= 4, num!= 10 = 1

Question # 2 [Q Marks-20]

Write a FUNCTION that calculates how much bill user has to pay according to the usage of
Electricity units. User will provide just number of units he consumed in main function.

Constraints:
1. Rate of the first 100 units is Rs15/unit, for 100-300 units - its Rs25/Unit and for more than
that, its Rs27/Unit.
2. You have to add Nelum-Jehlum surcharge as 15% of total bill.
3. Now add TV charges RS50 in every bill.
4. If the bill exceeds RS500, give them discount of 3% on total.

Check for these values:


1. Enter number of units: 1 a. Your total bill is RS: 67.25

2. Enter number of units: 10 a. Your total bill is RS: 222.5

3. Enter number of units: 120 a. Your total bill is RS: 2350

4. Enter number of units: 321 a. Your total bill is RS: 7931.74

5. Enter number of units: 500 a. Your total bill is RS: 13325

12012021 Session-2020 1/3


PROGRAM:

#include <iostream>
#include <conio.h>
using namespace std;
void calc_Electricity(int unit);
int main()
{

int unit;
cout << "Enter total units consumed: ";
cin >> unit;
calc_Electricity(unit);
return 0;
}

void calc_Electricity(int unit) {

double amount;
float sur = 0.15, total = 0, bill;
int tv = 50;

if (unit >= 1 && unit <= 100)


{
amount = 15 * unit;

bill = (sur * amount) + amount;


bill = bill + tv;
total = bill;
cout << "Electricity bill = Rs." << total;

}
else if (unit > 100 && unit < 300)
{
amount = 25 * unit;
bill = (sur * amount) + amount;
bill = bill + tv;
total = bill;
cout << "Electricity bill = Rs." << total;

}
else if ((unit > 300)) {
amount = 27 * unit;
bill = (sur * amount) + amount;
bill = bill + tv;
total = bill;
cout << "Electricity bill = Rs." << total;

}
else if (total > 500)
total = total *0.3;
else
cout << "your bill is" << total;
}

12012021 Session-2020 1/3


12012021 Session-2020 1/3

You might also like