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

09. Conditionals Questions

The document contains assignment questions focused on conditional statements in C++. It includes tasks such as writing programs to determine if a number is positive, negative, or zero, checking for leap years, and evaluating the output of specific C++ code snippets. Additionally, it asks for verification of Armstrong numbers and provides a bonus question regarding the differences between typedef, macros, and const in C++.

Uploaded by

cm2810451
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

09. Conditionals Questions

The document contains assignment questions focused on conditional statements in C++. It includes tasks such as writing programs to determine if a number is positive, negative, or zero, checking for leap years, and evaluating the output of specific C++ code snippets. Additionally, it asks for verification of Armstrong numbers and provides a bonus question regarding the differences between typedef, macros, and const in C++.

Uploaded by

cm2810451
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Conditional Statements

(Assignment Questions)

Question 1 : Write a C++ program to get a number from the user and print whether
it's positive, negative or zero.

Question 2 : Write a C++ program that takes a year from the user and print whether
that year is a leap year or not.
.
Hint : A leap year is exactly divisible by 4 except for century years (years ending with
00). The century year is a leap year only if it is perfectly divisible by 400.
Eg : 1999 is not a leap year
2000 is a leap year
2004 is a leap year

Question 3 : What will be the value of x & y in the following program:


int main() {
int a = 63, b = 36;
bool x = (a < b) ? true : false;
int y = (a > b) ? a : b;
cout << x << "," << y << endl;
return 0;

Question 4 : What’ll be the output of the program:


int main() {
int a = 5;

if (++a*5 <= 25) {


cout<<"Hello\n";
} else {
cout<<"Bye\n";
}
return 0;
}

Question 5 : For any 3 digit number check whether it’s an Armstrong number or not.
Armstrong number is a number that is equal to the sum of cubes of its digits.
Eg : 371 is an armstrong number.
3*3*3 + 7*7*7 + 1*1*1 = 371

Bonus : Read up about the difference between typedef (keyword), macros & const
(keyword) in C++.

https://t.me/+nEKeBr_yhXtmY2Yx
https://telegram.me/+nEKeBr_yhXtmY2Yx

You might also like