Computer Science, asked by darkwebxd10, 9 months ago

Write a program to display maximum and minimum number amongst 5 numbers accepted from the user.

Answers

Answered by rajlaxmi56
0

Answer:

I know how to create the program using array.

int largestNumber;

int smallestNumber;

int numbers[n];

largestNumber=numbers[0]; smallestNumber=numbers[0];

for (i=0 ;

i<n;

i++) { if (numbers[i] > largestNumber)

{ largest = numbers[i]; } if (numbers[i] < smallestNumber) { smallestNumber= numbers[i]; } }

 &lt;marquee behaviour-move&gt;&lt;font color="maganta red"&gt;&lt;h2&gt;hope this helps you&lt;/ ht&gt;&lt;/marquee&gt;

Answered by 641829krishna
0

Answer:

In this program user ask to find the Maximum number between the 5 numbers. Here user declares the variables that which store the value. User asks to enter the five numbers for compilation. Here user uses for loop to vary the condition regarding to situation. Here user declare nested loop statement for number and then if condition. If (a[i]>a[j]) if all the condition got vary then the loop statement will collaborate the number that it varies and put on the screen as result it has.

Problem Statement:

This is C program that asks user to find the bigger number from the 5 numbers.

Declaring the variable.

Using loop statement.

Vary control statement.

Display result on the screen.

Here is C source code for finding the maximum number from five No. The output of this program shown below.

#include<stdio.h>

void main()

{

int a[5],i,j,c;

clrscr();

printf("Enter five no. :");

for(i=0;i<=4;i++)

{

scanf("%d",&a[i]);

}

for(i=0;i<=4;i++)

{

for(j=i+1;j<=4;j++)

{

if(a[i]>a[j])

{

c=a[i];

a[i]=a[j];

a[j]=c;

}

}

}

for(i=0;i<=4;i++)

{

printf("%d",a[i]);

}

printf("\n");

getch();

}

Maximum Number Between 5 No

Similar questions