0% found this document useful (0 votes)
15 views3 pages

Week 4

The document outlines a program that identifies the largest and smallest numbers among user-inputted integers, using C programming language. It includes a problem statement, aim, software requirements, a step-by-step algorithm, and the source code. The program prompts the user for the total number of elements and the numbers themselves, ultimately displaying the largest and smallest values entered.
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)
15 views3 pages

Week 4

The document outlines a program that identifies the largest and smallest numbers among user-inputted integers, using C programming language. It includes a problem statement, aim, software requirements, a step-by-step algorithm, and the source code. The program prompts the user for the total number of elements and the numbers themselves, ultimately displaying the largest and smallest values entered.
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/ 3

WEEK 4:

Problem Statement:

Write a Program which determines the largest and the smallest number that can
be stored in different data types like short, int, long, float, and double. What
happens when you add 1 to the largest possible integer number that can be
stored?

Aim:

Write a Program which determines the largest and the smallest number

Software Requirements:

Operating system: Windows 11

Dev C++ 5.6

Compiler Version: TDM-GCC 4.8.1, 64-bit debug.

Description:

Here, the program asks the user to input total number of elements among which
the largest and the smallest is to be found. It then asks for the first number from
the user before the loop, which is assigned to both variable lar and variable sm.
Here, we suppose that lar is the largest number and sm is the smallest number
for now.

Algorithm:

Step 1: Start
Step 2: Declare the variables
Step 3: Enter total number of elements
Step 4: Read the given elements
Step 5: Compute the code part by applying the looping constraints
Step 6: Check the conditions
Step 7: according to the given elements on the screen , it gives the resultant
element is largest element and smallest element.
Step 8: Stop

Flow Chart:

1
Source Code:

#include<stdio.h>
#include<conio.h>
int main()
{
int i, n, lar,sm, elem;
printf ("Enter total number of elements:");
scanf ("%d", &elem);
printf ("Enter first number:");
scanf ("%d", &n);
lar = n;
sm=n;
for (i=1; i<= elem -1 ; i++)
{
printf ("\n Enter another number:");
scanf ("%d",&n);
if (n>lar)
lar=n;
if (n<sm)
sm=n;
}
printf ("\n The largest number is %d", lar);
printf ("\nThe smallest number is %d", sm);
return 0;
}

Save the file: large.c

Compiler (F9): Click on F9 to compile the program which helps us to find the
errors so that the file extends to large.exe file name.

Run (F10): After compilation of the program click on F10 to run the program
and gives output.

Output:

Enter total number of elements:5


Enter first number:30

Enter another number:10

Enter another number:5

2
Enter another number:40

Enter another number:35

The largest number is 40


The smallest number is 5
--------------------------------
Process exited after 37.33 seconds with return value 0
Press any key to continue . . .

You might also like