0% found this document useful (0 votes)
111 views

Lab No. 7 Using If Else and Loops

This document outlines 6 tasks for a C++ lab. Task 1 has the user enter 10 numbers and prints only those divisible by 7. Task 2 helps students select a university department based on NTS and F.Sc. marks by comparing scores to criteria. Task 3 calculates library late fees based on return dates. Task 4 determines the state of water based on temperature. Tasks 5 and 6 both calculate factorials for a user-entered number, using while, for, and do-while loops.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Lab No. 7 Using If Else and Loops

This document outlines 6 tasks for a C++ lab. Task 1 has the user enter 10 numbers and prints only those divisible by 7. Task 2 helps students select a university department based on NTS and F.Sc. marks by comparing scores to criteria. Task 3 calculates library late fees based on return dates. Task 4 determines the state of water based on temperature. Tasks 5 and 6 both calculate factorials for a user-entered number, using while, for, and do-while loops.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab No.

7 using if else and loops


Lab Task 1  

Write a program that will ask the user for 10 values and only print those that are divisible by 7. 
Expected Output: 
Enter a number: 45 
You entered 45. 
Enter a number: 14 
Enter a number: 21 
You entered 21. 
Enter a number: 30 



Lab Task 2  
Write a C++ program in which user enter his NTS and F.Sc marks and your program help 
student in selection of university. Based on these marks Student will be allocated a
seat different department of different university. 
University Departments  Criteria 
Name 
Oxford IT   Above 70% in Fsc. and 70 % in NTS 
University  Electronics Engr:   Above 70% in Fsc. and 60 % in NTS 
Telecommunication  Above 70% in Fsc. and 50 % in NTS 
MIT  IT  70% -60 % in Fsc. and 50 % in NT 
Chemical Engr:  59% -  50 % in Fsc. and 50 % in NTS 
Computer Engr:   Above 40% and below 50 % in Fsc. and 50 % in NTS 

Lab Task 3  


The community library allows its members to check out books. If the user returns the book after
the due date fine is imposed on the member. The policy of fine is as follows: 
 
·         Rs.1 within 5 days 
·         Rs.2 after 5 days. 
 
Write a C++ Code to implement the program to calculate the fine. 
Lab Task 4  
Make a program in C ++ that asks the user to enter the temperature of water and then tells the
state 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 5  
Write a C++ program to evaluate n! As long as user wants. 
Sample Run: 
 
Enter number: 3 
Answer: 6 
Do you want to continue(y/n): Y 
Enter number: 5 
Answer: 120 
Do you want to continue(y/n): n  
Note: First do this task using while loop, then for loop, then do while loop. 
Lab Task 6  
Write a C++ program to evaluate n! As long as user wants. 
Sample Run: 
 
Enter number: 3 
Answer: 6 
Do you want to continue(y/n): Y 
Enter number: 5 
Answer: 120 
Do you want to continue(y/n): n  
Note: First do this task using while loop, then for loop, then do while loop. 

You might also like