0% found this document useful (0 votes)
1 views1 page

C Programming (Basics) - 5 Worksheet

The document contains a worksheet focused on basic C programming concepts, specifically using ternary operators. It includes tasks such as finding absolute values, checking character types, determining maximum and minimum numbers, and calculating BMI. Each task specifies input requirements and expected outputs using ternary operations.

Uploaded by

santanum00770
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)
1 views1 page

C Programming (Basics) - 5 Worksheet

The document contains a worksheet focused on basic C programming concepts, specifically using ternary operators. It includes tasks such as finding absolute values, checking character types, determining maximum and minimum numbers, and calculating BMI. Each task specifies input requirements and expected outputs using ternary operations.

Uploaded by

santanum00770
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/ 1

C Programming(Basics) - 5 Worksheet

(Ternary Operators)

1.​ Find the Absolute Value of a Number​


Input: One number​
Task: Print its absolute value using the ternary operator.​

2.​ Check if a Character is a Vowel or Consonant​


Input: A lowercase letter​
Task: Print "Vowel" or "Consonant" using a ternary operator.
3.​ Find the Maximum of Three Numbers​
Input: Three numbers​
Task: Print the largest number
4.​ Find the Smallest of Three Numbers​
Input: Three numbers​
Task: Print the smallest using nested ternary operators.​

6.​ Check if a Number is Divisible by Both 3 and 5​


Input: One number​
Task: Print "Divisible by both" or "Not divisible by both" using ternary.
7.​ Check if a Triangle is Valid​
Input: Three sides of a triangle​
Task: Use ternary operators to check if it forms a valid triangle (sum of two sides > third side).
8.​ Century Year Checker​
Input: A year​
Task: Check if the year is a century year (divisible by 100) using a ternary operator.
9.​ Check if a Character is Uppercase, Lowercase, Digit, or Special Character​
Input: A character​
Task: Use nested ternary operators to classify.
10.​BMI (Body Mass Index) Calculator with Category​
Input: Weight and Height BMI = weight /(height)^2​
Task: Calculate BMI and categorize as:
○​ Underweight (<18.5)
○​ Normal (18.5-24.9)
○​ Overweight (25-29.9)
○​ Obesity (30 or greater)

11. Electricity Bill Calculator Using Ternary​


Input: Units consumed​
Task:

●​ Less than 100 → ₹1.5/unit


●​ 100-300 → ₹2/unit
●​ More than 300 → ₹3/unit

Souradip Chakraborty Classes (6290484723 / 8910471560)

You might also like