0% found this document useful (0 votes)
2 views2 pages

Lab 1

This document outlines a lab assignment for students at the University of Central Punjab, focusing on programming concepts such as If-else, Switch Statements, Loops, and Arrays. It includes six questions that require students to write C++ programs for tasks like finding the second maximum of three integers, performing various unit conversions, reversing a number, printing a specific shape, finding minimum and maximum values in an array, and implementing a find and replace function. The objective is to provide hands-on experience with these programming concepts.

Uploaded by

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

Lab 1

This document outlines a lab assignment for students at the University of Central Punjab, focusing on programming concepts such as If-else, Switch Statements, Loops, and Arrays. It includes six questions that require students to write C++ programs for tasks like finding the second maximum of three integers, performing various unit conversions, reversing a number, printing a specific shape, finding minimum and maximum values in an array, and implementing a find and replace function. The objective is to provide hands-on experience with these programming concepts.

Uploaded by

hirrah21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 1 PF Spring 22

University of Central Punjab


Faculty of Information Technology

PF- Lab1
Topics: If-else , Switch Statements , Loops , Nested Loop , Integer Array , Character Array
Objective: Learning objectives of this lab are to get hands on experience on the concepts of If-else, Switch
Statements, Loops, Nested Loop, Integer Array, and Character Array.

Question 1

Write a program which takes 3 inputs integers and tell the 2nd maximum.

Sample Input: 90 5 60

Sample Output: 60

Question 2
Write a program that takes one value from the user, asks about the type of conversion and then
performs a conversion depending on the type of conversion. If user enters:
• I -> convert from inches to centimeters. [1 inch = 2.54 centimeter]
• C -> convert from centimeters to inches. [1 centimeter = 0.393701 inch]
• G -> convert from gallons to liters. [1 gallon = 3.78541 liter]
• L -> convert from liters to gallons. [1 liter = 0.264172 gallon]
• M -> convert from mile to kilometer. [1 mile = 1.60934 kilometer]
• K -> convert from kilometer to mile. [1 kilometer = 0.621371 mile]
• P -> convert from pound to kilogram. [1 pound = 0.453592 kilogram]
• O -> convert from pound to ounce. [1 pound = 16 ounce]
• F -> convert from Fahrenheit to Celsius. [c = (f - 32) * (5 / 9)]
• C -> convert from Celsius to Fahrenheit. [f = c * (9 / 5) + 32]
Question 3
Write a C++ program to find the reverse of the given number.
Sample Input: Given number is 4235
Sample Output: The reverse of given number is 5324
Question 4
Write a program to print the following shape on the screen.
1
24
369
4 8 12 16
5 10 15 20 25

Question 5
Write a C++ program that create an integer array of Size 10 and initialize it with some random
numbers and finds minimum and maximum number in array.
Sample 1
Array[10]= {2,4,5,66,75,8,53,11,3,45}
Output:
Minimum number in array is = 2
Maximum number in array is =66
Sample 2
Array[10]= {-2,-4,-5,-66,-75,-8,-53,-11,-3,-45}
Output:
Minimum number in array is = -66
Maximum number in array is =-2

Question 6
Write a program that preforms the find and replace function of Microsoft word. The user enters
some text in the array of size 50. Then the user wants to replace say all the “I” characters present
in the array with M characters.

Example:

D R O I E A M R I B A N G R I K

Output:
Enter character to be found: I
Enter character to be replaced by: M

D R O M E A M R M B A N G R M K

You might also like