0% found this document useful (0 votes)
53 views5 pages

3017-Antara Mudi Comp Lab Assign1

The document describes a student assignment to write C programs to find the greatest of three numbers using if-else statements and ternary operators, and to calculate the square root of a quadratic equation. It includes algorithms, flowcharts, programs and output screenshots for both parts of the assignment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views5 pages

3017-Antara Mudi Comp Lab Assign1

The document describes a student assignment to write C programs to find the greatest of three numbers using if-else statements and ternary operators, and to calculate the square root of a quadratic equation. It includes algorithms, flowcharts, programs and output screenshots for both parts of the assignment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment no: 1 Student Id: 211003003017

Name: Antara Mudi


Date: 25/02/2022
Aim:
Write a C program to find the greatest of 3 numbers using if-else Statements. Rewrite the same program using
ternary operators.

Algorithm:
1. Start

2. Print “Enter a Number”

3. Read Number 1, Number 2, Number 3

4. If Number 1 > Number 2 and Number 1 > Number 3) print “Number 1 is Greatest”

5. If (Number 2 > Number 1 and Number 2 > Number 3) print “Number 2 is Greatest”

6. If (Number 3 > Number 1 and Number 3 > Number 1) print “Number 3 is greatest”

7. Stop

Flowchart:

TRUE
PRINT
START READ NUM1, IS NUM1>NUM2
NUM2, NUM3 IS NUM1>NUM3 “NUM1 IS GREATEST”

FALSE

PRINT
“ALL
NUMBERS FALSE IS NUM3>NUM1 FALSE IS NUM2>NUM1 TRUE PRINT
ARE EQUAL” IS NUM3>NUM2 IS NUM2>NUM1 “NUM2 IS GREATEST”

TRUE

PRINT
“NUM2 IS GREATEST”

STOP
PROGRAM:
Using If-Else:

Using Ternary Operation:


Output Screenshot :
Using If-Else:

Using Ternary Operations:


Assignment No: 1 Student Id: 211003003017
Name: Antara Mudi
Date: 25/02/2022
Aim: Write a C program to calculate the square root of a quadratic equation
Algorithm:
1. Start
2. Read a, b, c values
3. Compute d=b2 – 4ac
4. If d > 0 then
5. Compute r1 = -b + sqrt(d)/(2*a)
6. Compute r2 = -b – sqrt(d)/(2*a)
7. Print r1, r2 values
8. Other-wise if d =0 then
9. Compute r1 = -b/2a, r2 = -b/2a
10. Print r1, r2 values
11. Other-wise if d < 0 then print roots are imaginary
12. Stop

Flowchart:

START Read 3 Numbers


Compute
d = b2 – 4ac

Compute True False True


Is Is Compute
r1=-b + sqrt(d)/2a d>0? d=0? r1 = -b/2a
r2=-b + sqrt(d)/2a r2 = b/2a

False

Print Print
Print
Roots are r1, r2
r1, r2 values
imaginary values

STOP
Program:

Output Screenshot:

You might also like