0% found this document useful (0 votes)
13 views28 pages

Conditional Operator Programming Questions

The document contains a series of programming questions focused on conditional operators, primarily aimed at students of QSpiders, JSpiders, and PySpiders in Noida. Each question requires writing a program to solve various logical problems, such as checking even numbers, determining factors, and identifying valid triangles. Additionally, there are questions designed to test knowledge of Java/JavaScript output related to conditional expressions.

Uploaded by

mitchellsamir999
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)
13 views28 pages

Conditional Operator Programming Questions

The document contains a series of programming questions focused on conditional operators, primarily aimed at students of QSpiders, JSpiders, and PySpiders in Noida. Each question requires writing a program to solve various logical problems, such as checking even numbers, determining factors, and identifying valid triangles. Additionally, there are questions designed to test knowledge of Java/JavaScript output related to conditional expressions.

Uploaded by

mitchellsamir999
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

QSpiders|JSpiders|PySpiders, NOIDA

B-4, Block-B, Sector-3, Noida


Conditional Operator Programming Questions by
Shambhu Sir
@javac_java Monday, 11 August 2025 @kumarsam07

SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA

Q1
Q:1
WAP to check and print the given number is an
even number or not.

12/22/2025 Shambhu Kumar QSpiders | JSpiders, 1


NOIDA
SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q2
WAP to check and print the given +ve
number is a three digit number or not.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 2


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q3
WAP to check and print the given number
is divisible by both 3 and 5 or only by 3,
only by 5 or None.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 3


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q4
For given numbers x and y. check whether
y is a factor of x or not.
Input: x=12, y=4
Output: x is a factor of y
Input: x=28, y=5
Output: x is not a factor of y

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 4


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q5
WAP to check whether the three sides of
a triangle is valid or not.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 5


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Logical Operator based Programming

Q6
For a given year print true if it is a leap year or
print false if it is not a leap year.

[Link]
ges/write-a-function/problem

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 6


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q7
WAP to check whether the given
character is an upper case alphabet or
not.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 7


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q8
WAP to check whether the given
character is a lower case alphabet or not.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 8


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q9
WAP to check whether the given
character is an alphabet or not.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 9


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q10
Given a character, check if it's uppercase,
lowercase, digit or special character.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 10


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q11
WAP to print the bigger of two numbers.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 11


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q12
WAP to print the smaller of two numbers.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 12


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q13
WAP to print the biggest of three
numbers.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 13


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q14
WAP to print the smallest of three
numbers.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 14


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q15
print second largest of three distinct
numbers using ternary operator only.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 15


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q16
Given three numbers, print them in
sorted order (ascending)
int a = 9, b = 2, c = 7;
// Output: 2 7 9

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 16


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q17
WAJP to print the biggest of four
numbers.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 17


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q18
WAJP to print the smallest of four
numbers.

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 18


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q19
Test the Rank of a student
int marks = 72;
Output: "Distinction" (>=75), "First Class"
(>=60), "Second Class" (>=50), “Pass“
(>=35), or “Fail”

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 19


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q20 Only For Java/JavaScript Students


What is the output of the program:
int a = 5, b = 10;
int c = (a > b) ? a++ : b++;
[Link](a + " " + b + " " + c);
a)5 11 5 b) 6 10 6
c) 5 11 10 d) 6 11 10

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 20


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q21 Only For Java/JavaScript Students


What is the output of the program:
int a = 3, b = 4, c = 5;
int result = (a > b) ? (a > c ? a : c) : (b > c ? b : c);
[Link](result);
a) 3 b) 4 c) 5 d) 6

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 21


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q22 Only For Java/JavaScript Students


What is the output of the program:
int x = 10;
int y = 5;
int z = (x > y) ? (x < 15 ? x : y) : (x > 5 ? y : x);
[Link](z);
a) 10 b) 5 c) 15 d) none}

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 22


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q23 Only For Java/JavaScript Students


What is the output of the below program?

int x = 10;
int y = 5;
int z = 7;
int result = (x < y) ? (y < z ? z : y) : x;
[Link](result);
a) 10
b) 5
c) 7
d) Compilation error
12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 23
SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q24 Only For Java/JavaScript Students


What is the output of the below program?

int a = 1, b = 2, c = 3;
int result = a < b ? a < c ? c : a : b;
[Link](result);

a) 1 b) 2 c) 3 d) Compile Time Error

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 24


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q25 Only For Java/JavaScript Students


What is the output of the below program?

int a = 5;
int b = 10;
int c=(a>b) ? b++ : (a<b ? --b : b) ;
[Link](c);
a) 5
b) 6
c) 10
d) 9

12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 25


SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q26 Only For Java/JavaScript Students


What is the output of the below program?

int val=10;
int result=(value>5) ? (value<8?1:2) : 3;
[Link](result);
a) 1
b) 2
c) 3
d) Compilation error
12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 26
SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q27 Only For Java/JavaScript Students


What is the output of the below program?

int x=5, y=7, z=3;


int result=(x>y) ? (x>z? x:z) : (y>z ? y:z);
[Link](result);
a) 5
b) 7
c) 3
d) Compilation error
12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 27
SHAMBHU KUMAR QSpiders |JSpiders | PySpiders, NOIDA
Conditional Operator based Programming

Q28 Only For Java/JavaScript Students


What is the output of the below program?

int x=5, y=7, z=3;


int result=(x<y) ? (x<z? x:z) : (y<z ? y:z);
[Link](result);
a) 5
b) 7
c) 3
d) Compilation error
12/22/2025 Shambhu Kumar @QSpiders, NOIDA Instagram: @javac_java 28

You might also like