Get premium membership and access revision papers, questions with answers as well as video lessons.
Got a question or eager to learn? Discover limitless learning on WhatsApp now - Start Now!

Procedural Programming Question Paper

Procedural Programming 

Course:Bachelor Of Science (Mathematics & Computer Science)

Institution: Karatina University question papers

Exam Year:2012



1. What is the difference between x = 3 and x == 3?
2. Are negative numbers true or false?
3. What does the "conditional expression operator" do?
4. What does if(x) and if(!x) mean?
5. Rewrite the following line by using the if ... else statement.
y = (x > 2 && x<=9) ? x*x:1.0/x;
6. What is wrong with the following code?
if( x > y > z ) cout << x*y*z << endl;
7. What is the output of the following program?
#include <iostream>
int main(){
int z, x = 11, y = 221;

if(y) z = y < x ? x/y : y/x;
else z = 0.0;

std::cout << "z = " << z << std::endl;

return 0;
}
8.What is the output of the following program?
#include <iostream>
int main()
{
int a = 1, b = 1, c;

if (c = (a-b)) std::cout << "The value of c is: " << c;
else
std::cout << "The value of c is: " << c;
return 0;
}
9.What is the output of the following program?
#include <iostream>
int main()
{
int a = 5, b = 7, c;

if ( (c = a + b) != 35 )
std::cout << "The value of c is: " << c;
else
std::cout << "The value of c is: " << c;

return 0;
}

10.Write a program to input an integer number and output whether it is even or not.

11.Write a program that reads a year from the keyboard and outputs whether it is leap year or not.

12.Write a program that reads a grade A, B, C, D, or F and then prints "excellent", "good", "fair", "poor", or "failure". Use else if.

13. Write a program for the question(12) using switch statement.






More Question Papers


Popular Exams



Return to Question Papers