Sei sulla pagina 1di 7

Assignment # 1 Please note down the following rules very carefully.

Write a program for each of the given lab task. Cheating and copying cases will be dealt strictly. A viva will be conducted from each individual student in the first class of the next week. Bring your laptops for viva in my office. This assignment is to be solved by each individual, so please do not share your code with others otherwise both student (one who copies and the other who provides copy) will be given ZERO. Negative marks may also be given if the same code copy is found from multiple students. No late submissions will be accepted. If any student fail to appear in the viva on the given date and time, he will be awarded ZERO in this assignment even though he has made all the programs correctly. So, remember the viva is necessary to prove that a student has done all the work himself/herself and he/she has complete understanding of his own code. No excuse in this regard will be accepted after wards.
Lab Task 1
Write program to take a number from user and find whether a number is even or odd.

Lab Task 2
Write program to take a number from user and find whether a number is positive or negative.

Lab Task 3
Take 5 subject marks as input and calculate their average and display the accumulated grade according to given grading scheme use (if, else if). 40% to 49%-------------Grade D 50% to 59%-------------Grade C 60%to 69%--------------Grade B 70% to 79%--------------Grade A 79% to 100% ------------A-one Grade

Lab Task 4
Write a program of a BMI calculator application that reads the user's weight and height and then calculates and displays the user's body mass index. The formula for calculating BMI is: BMI = Weight / (Height * Height) Note: (Height is in meter) Also, the application should display the following information from the scale provided below. BMI VALUES Underweight: less than 18.5 Normal: between 18.5 and 24.9 Overweight: between 25 and 29.9 Obese: 30 or greater

Lab Task 5
Make a program in C++ that take temperature as input and tells the form of Water whether it is Ice, Water or Steam. Display the menu also as under. Temperature Less than 0 = ICE Temperature Greater than 0 & Less than 100 = Water Temperature Greater than 100 = STEAM

Lab Task 6
Write a program that calculates the shopping bill of the customer. The price of an item and the quantity of the item are entered by the user. If the customer's bill is $1000 or more the customer receives 5% discount.

Lab Task 7
Write the value of each variable after the statement is executed. You can check your answer by coding this function and using cout statements after completing the table. i void evaluate() { int i=0; int j=1; int k=5; bool btype = true; j k btype btype2

bool btype2 = false; btype = 100<7 && !(5>10) || !btype2 && (j==0); btype = 11>5 && (j=9) || (i=4); btype = 10<4 || (i=1) && (j=7); btype = (i=100) || (j=0) && (k=12); btype = (k=0) && (j=1) || (i=13); btype = (k=1) && (btype2) || (j=2); btype = (k=3) && (j=5) || (i=0) && (btype2=true); btype = (j=8) || (k=9) && (i=1) || (btype2=false); btype = (k=0) && (j=5) || (i=0) && (btype2=true); i = j = (k=5) && (11>5); }

Lab Task 8
Write a program that calculates the pay a user has earned. The user enters the number of hours he worked. If the number of hours worked by the user are less than or equal to 40 the user receives $10 for every hour worked. If the hours worked exceed 40 than the user receives $12 for every hour worked over 40.

Lab Task 9
After execution of the following code, what will be the value of x? x = 30; y = 20; if (y != (x - 10)) x = x - 5; else

x = y;

Lab Task 10
What is the output of the following code fragment?(Read the code carefully!!!) int alpha = 10; if (alpha < 5) cout << "Apple "; cout << "Orange "; cout << "Banana";

Lab Task 11
After execution of the following code, what will be the value of y? int x=10, y=0; if (x > 0) y = y + 1; else if ( x < 0) y = y + 2; else y = y + 5;

Lab Task 12
Write a program which Gets 3 angles from the user and determines whether the triangle is valid or not. If it is a valid, triangle than determine if it is a right angle, equilateral or isosceles triangle. Note: Equilateral triangle: Triangle having two equal angles. Isosceles triangle: Triangle having all three equal angles. Right Triangle: Triangle having one angle equal to 90 degrees. Expected Output: Enter First Angle: 90 Enter Second Angle: 120 Enter Third Angle: 80 Triangle is invalid Enter First Angle: 60 Enter Second Angle: 60 Enter Third Angle: 60

Triangle is valid Triangle is Isosceles

Lab Task 13
Write a Program that prompts the user to input the x-y coordinate of a point in a Cartesian plane. The program should then output a message indicating whether the point is at origin, located at x or y axis or appears in a particular quadrant.

Lab Task 14
In a company an employee paid as under: If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA = 90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the employee's salary is input through the keyboard write a program to find his gross salary.

Lab Task 15
Write a program in C++ to input a single character and print a message it is vowel" if it is vowel otherwise print message "It is a "consonant Use if-else structure and OR (||) operator only.

Lab Task 16
Write a program which reads in two values from the user Manufacturing cost of product Selling price of product. And determines and prints whether a profit or a loss is made. If profit is greater than 10% calculate and Display a Bonus of 1% from profit to the employee. Expected Output: Enter Manufacturing cost of product: 700 Enter selling price of product: 1100 Profit = 400 36% Profit is made from this product. Bonus = 4

Lab Task 17
Write a program that will take input of the age from the user and display following message according to his age: Age < 40 You are young Otherwise You are too old

Lab Task 18
Write a program that reads in a four-digit number, separates the number into its individual digits and prints them separated by three spaces. Thus given the number 4233, the program should print: 4 2 3 3

Potrebbero piacerti anche