Professional Documents
Culture Documents
Course Instructor:
Lab Instructor:
Sample Program.
Write a program which takes marks as input and then shows output as follows:
Marks Output
87 – 100 Grade A
80 - 87 Grade B+
72 – 80 Grade B
67 – 72 Grade C+
60 - 67 Grade C
Below 60 Failed
Sample Code:
#include<iostream>
using namespace std;
int main()
{
int marks;
cout<<"Enter marks";
cin>>marks ;
++numNeighbors;
else {
--numNeighbors;
int number = 4;
if (alpha > 0)
else{
}
Lab Tasks
Task 1:
Write a program, which takes age as input from user and prints appropriate message depending upon the
following conditions:
If age less than 6 then prints, “What a nice child!”
If age is between 6 and 9 then prints, “That’s a good age!”
If age is between 9 and less than 20 then prints, “Ah! In the prime of life”
If age between 20 and less than 30 then prints, “Watch out, the younger ones are gaining on
you.”
More than 30 then it prints, “Well, have fun, and don’t look back.”
Task 2:
Write a program which takes 3 numbers as input then it finds the minimum and maximum number and
print output as follows:
Task 3:
Write a program in which it takes two numbers from keyboard as input and subtract larger
number from smaller?
Task 4:
Write a Program using Nested if-else structure. The program will get a Single Character from
user and Tell either it is Vowel or Not and it a capital or small letter?
Sample output:
Enter a character : A
A is a Vowel and it is Capital Letter.
Enter a character: y
y is not a Vowel and it is small Letter.
Task 5:
1. If character variable taxCode is ’T’, increase price by adding the taxRate percentage of
price to it.
2. If integer variable opCode has the value 1, read in double values for X and Y and
calculate and print their sum.
3. If integer variable currentNumber is odd, change its value so that it is now 3 times
currentNumber plus 1, otherwise change its value so that it is now half of
currentNumber (rounded down when currentNumber is odd).
4. Assign true to the boolean variable leapYear if the integer variable year is a leap year. (A
leap year is a multiple of 4, and if it is a multiple of 100, it must also be a multiple of
400.)
5. Assign a value to double variable cost depending on the value of integer variable
distance as follows:
Distance Cost
0 through 100 5.00
More than 100 but not more than 500 8.00
More than 500 but less than 1,000 10.00
1,000 or more 12.00