We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1
Pir Mehr Ali Shah
Arid Agriculture University Rawalpindi
University Institute of Information Technology
Mid Examination-Fall 2018
BSCS/BSIT/BSSE Programming Fundamentals Reg. No.________________ Total Time: 1.5 hrs Name: ______________________________ Maximum Marks: 18 ------------------------------------------------------------------------------------------------------------------------- Q.No.1: Give output of the following programs. Marks: 4 A)int main() B)int main() { int i, x[4], y, z[4]; { int a=1, b=1,c=0; for (i = 0; i < 4; i++) cout<< a<<b<<’\t’; { c = a + b; a = b; b = c; z[i] = i + 3; cout<< a<<b<<’\t’; y = z[i]; c = a + b; a = b; b = c; x[i] = y++%4; cout<< a<<b<<’\t’; } c = a + b; a = b; b = c; for (i = 0; i < 4; i++) cout<< a<<b<<’\t’; cout << x[i] << " "; c = a + b; a = b; b = c; return 0; return 0; } } Q. No.2: Marks: 4 A company wants to transmit data over the telephone, but is concerned that its phones could be tapped. All of the data are transmitted as four-digit integers. The company has asked you to write a C++ program that encrypts the data so that it can be transmitted more securely. Your program should read a four-digit integer and encrypt it as follows: replace each digit by (the sum of that digit plus 7) modulus 10. Print the encrypted digits. Example: if user enters a 4 digit number 1234, then the output would be 8901 Q.No.3: Marks: 4 Write program in C++ to display following pattern like a pyramid. (One space between characters) A A B A A B C B A A B C D C B A A B C D E D C B A Q.No.4: Marks: 6 The new government has decided to increase the gas prices to cover the deficit of billion of rupees. There are two types of consumers one is commercial ( C) and other one is domestic ( D). For commercial consumer there is only one slab and existing unit rate is Rs.350/- per cubic meter and the increase in rate is 40%. However domestic consumers have following slabs, previous rates and %age increase in rates: Domestic consumer uses gas upto 50 cubic meters, unit price is Rs.4/- and increase is 10 % Domestic consumer uses gas upto 100 cubic meters, unit price is Rs.5/- and increase is 15 % Domestic consumer uses gas upto 300 cubic meters, unit price is Rs.10/- and increase is 25 % Domestic consumer uses gas more than 300 cubic meters, unit price is Rs.20/-,increase is 143 % Write a program in C++ which ask user i) No. of Units: and ii) Type of Consumer: Then it calculates and displays the Old Price and New Price to the user. This program will continue till user enters ‘y’ for multiple inputs. Also you have to use switch case for type of consumer. ------------ Good Luck ------------