Lab Sheet
Lab Sheet
Computer Programming
1- Write a temperature conversion program that gives the user the option of
converting a value of temperature to Celsius and Fahrenheit scales of temperature.
2- Write a program that takes balance of a user’s account as input. It should then
ask the user how much amount he wants to withdraw from his account. The program
should take this amount as input and deduct from the balance. Similarly it should ask
the user how much amount he wants to deposit in his account. It should take this
amount as input and add to the balance. The program shall display the new balance
after amount has been withdrawn and deposited.
Note: Your program should have a check on balance and amount being withdrawn.
Amounts greater than balance cannot be withdrawn i.e. balance cannot be negative.
PAGE 0
3- Write a program which takes two numbers as input from user and determines
which is the larger of the two numbers. The Program should also tell which of the
entered numbers is even or odd.
4- You need to design a calculator that performs four basic arithmetic operations.
You will write a program that takes two numbers as input from the user. It then
displays a list of arithmetic operations. The user selects one operation and the
program displays the result of the corresponding operation. The program should also
display which of the two input numbers is greater and which is smaller. Use do-while
loop. Interaction with the program might look like the following:
PAGE 1
7- Write a program that repeatedly asks the user to enter two money amounts
expressed in pounds. The program should then add the two amounts and
display the answer in pounds. The program should then convert the amount
in Rupees. (Set conversion rate: 1£=120.33 rupees). Display the answer in
Rupees. Use a do-while loop that asks the user whether the program should
be terminated.
9- Write a C++ program to find the sum and average of one dimensional integer
array.
PAGE 2
10- Take 10 integer inputs from user and store them in an array. Now, copy all the
elements in another array but in reverse order.
11- Write a program to find the sum and product of all elements of an array.
12- Write a program to print sum, average of all numbers, smallest and largest
element of an array and sort array element in descending order.
13- Write a program that asks the user to type 10 integers of an array and an
integer s. then search the value s from the array and display the value of s if it
is found in the array otherwise print sorry not found.
void my_recursive_function(int n)
{
if(n == 0)
return;
printf("%d ",n);
my_recursive_function(n-1);
}
int main()
{
my_recursive_function(10);
return 0;
}
PAGE 3
};
Town t = {"Canton", "Haywood", 9478 };
A) what is t.townName? B) what is t.countyName?
C) what is t.population? D) what is t.elevation?
PAGE 4
1- C++ Program to Display Factors of a Number
#include <iostream>
using namespace std;
int main()
{
int n, i;
cout << "Enter a positive integer: ";
cin >> n;
cout << "Factors of " << n << " are: " << endl;
for(i = 1; i <= n; ++i)
{
if(n % i == 0)
cout << i << endl;
} return 0;
}
int main()
{
int n, i;
bool isPrime = true;
PAGE 5