Docsity

Quiz Questions for Computer Programming (for Engineers) at Mohammad Ali Jinnah University, Exercises of Computer Programming

Toggle sidebar
bg1
Mohammad Ali Jinnah University, Islamabad Campus
Quiz# 7
Course Title Computer Programming (for Engineers)
Instructor Maryam Kausar
Weightage 2% Absolute
Question1: Write a program that take input from a user and determines that if
value enter by a user if less than 50 or greater than 100, it prints number entered is
invalid, and when number enter is between 50-100 it is a valid number.
int value=0;
cin>>value;
if{value<50)
cout<<”value invalid”;
if(value >100)
cout<<”value invalid”;
cout<<”you entered”<<value<<end1;
return 0;
docsity.com
pf2

Partial preview of the text

Download Quiz Questions for Computer Programming (for Engineers) at Mohammad Ali Jinnah University and more Exercises Computer Programming in PDF only on Docsity!

Mohammad Ali Jinnah University, Islamabad Campus

Quiz# 7

Course Title Computer Programming (for Engineers)

Instructor Maryam Kausar

Weightage 2% Absolute

Question1: Write a program that take input from a user and determines that if

value enter by a user if less than 50 or greater than 100, it prints number entered is

invalid, and when number enter is between 50-100 it is a valid number.

int value=0;

cin>>value;

if{value<50)

cout<<”value invalid”;

if(value >100)

cout<<”value invalid”;

cout<<”you entered”<<value<<end1;

return 0;

docsity.com

Question 2: Determine the output of the following program.

int count1=100; int main() { int count1=10; int count3=50; c out<<”Value or outer count1=”<<count1; c out<<” Value or global count1=” <::<count1; { int count1=20; int count2=30; c out<<” Value or inner count1=”<<count1; c out<<” Value or global count1=”<< ::count1; count1+=3; count3+=count2; } cout<<end1; <<”Value or outer count1=”<<count1; <<end1; <<”Value or outer count3 =” <<count3; <<end1; return 0; }

Question 3: Determine the output of the following program

int main() { double fish_count=20.0; double ave_legth= 9.0/12.0; double pond_area= 0.0; double pond_diameter=0.0; const Double fish_factor=2.0/0.5; const double pi=3.14149; pond_area= fish_count* ave_legth* fish_factor; pond_diameter=2.0*sqrt(pond_area/pi); Cout<<end1; <<”Pond diameter required is” <<pond diameter; <<”feet.: “; Return 0; }

docsity.com