Finding Largest and Smallest in a list of Integers || C Language

preview_player
Показать описание
This video helps you to understand how to write a C Program for finding the Largest and Smallest in a list of integers.
Рекомендации по теме
Комментарии
Автор

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10], N, i, MAX;
printf("How many number do U want to enter (Max. 10) : ");
scanf("%d", &N);
printf("\nPleasse enter %d integer number : ", N);
for(i=0; i<N; i++)
scanf("%d", &a[i]);
MAX=a[0];
for(i=1;i<N;i++)
if(MAX<a[i])
MAX=a[i];
printf("\n The largest no is: %d", MAX);


getch();
}

Output:
How many number do U want to enter (Max. 10) : 7

Pleasse enter 7 integer number : 2
1
0
-7
4
6
3

The largest no is: 6

BCABoy-bc
Автор

Sir we can write smallest and largest of 3 number using nestted if else statement only in one program

shubha.vshubha
Автор

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10], N, i, Min;
printf("How many number do U want to enter (Max. 10) : ");
scanf("%d", &N);
printf("\nPleasse enter %d integer number : ", N);
for(i=0; i<N; i++)
scanf("%d", &a[i]);
Min=a[0];
for(i=1;i<N;i++)
if(Min>a[i])
Min=a[i];
printf("\n The smallest no is: %d", Min);


getch();
}
Output:
Pleasse enter 6 integer number : 9
7
6
5
4
7

The smallest no is: 4

BCABoy-bc