Вы находитесь на странице: 1из 1

March 4, 2010  [HOME WORK 1] 

Computer Programming – FALL II‐09  
Course Instructor : Muhammad Umair 
www.umairm.webs.com 

Please Note: 

I. You are not required to submit the solution however your file should contain the solution. 

 
Q1: Construct a table which shows the execution of for loop? Do you find any logical error in any of the 
following codes? (No code is required, solve on paper) 

a)for  (int a=0;a!=5;a++) 


  cout << “a= “ << a; 

b) for (int count=5;count>0;count‐‐) 

  { 

    count‐‐; 

    cout << count+5; 

  } 

c)for (int data=7;data !=4; data++) 

  { 

    cout << data*data 

  } 

Q2: Write a program which inputs the age of 5 students and then shows the age of oldest and youngest 
student along with class age average? 

Q3:  Write  a  program  which  inputs  two  variable  (input1  &  input  2)  and  then  show  the  values  as 
following? (Assuming user entered 23 and 34 for input1 & input2 respectively) 

Input 1  input2  (input1>input2)   (input1==input2)  (input1!=input2) 

23  34  False      False      True 

  Page 1 
 

Вам также может понравиться