Professional Documents
Culture Documents
Write A C Program To Find The Largest Among Three Numbers Using If Statement
Write A C Program To Find The Largest Among Three Numbers Using If Statement
Write A C Program To Find The Largest Among Three Numbers Using If Statement
OUTPUT:
DISCUSSION:
The program utilizes the ‘if’ statement to perform
conditional checks for finding the largest number.
Each ‘if’ and ‘else if’ block compares the given number with
the other two and decides the largest.
This is a straightforward approach to solving the problem
using simple conditional logic.
2. write a c program to check whether number is even or odd
using switch.
TITLE: Checking Even or Odd Using the Switch Statement
INTRODUCTION: This program demonstrates the use of the ‘switch’
statement in C to determine whether a given number is even or odd.
The ‘switch’ statement is a powerful tool for making decisions based
on specific conditions, providing an alternative to the more common
‘if’ and ‘else’ constructs.
CODE:
OUTPUT:
OUTPUT:
DISCUSSION:
The program employs a “switch” case to examine whether a number
is prime. The program design is based on the idea that prime numbers
are divisible only by 1 and themselves. The first “switch” checks for
numbers 0 and 1 which are not prime by definition. The second
“switch” outputs the prime/non-prime result based on the value of
the “isPrime” variable. The program presents a clear example of how
“switch” cases can be used for more complex decision structures. This
code encapsulates an elementary but crucial concept in number
theory and coding - prime numbers and decision-making.
4. Write a program in C to read 10 numbers from keyboard
and find their sum and average.
TITLE: Calculating Sum and Average of Numbers
INTRODUCTION: This C program reads numbers from the keyboard,
calculates their sum and average, and provides an illustrative example
of input, calculation, and output processes.
CODE:
OUTPUT:
OUTPUT: