Saturday, April 8, 2023

find the maximum and minimum number within an arrey

 //find the maximum and minimum number within an arrey 

 #include "stdio.h"

 #include "conio.h"

 

 int main (){

    int max,min,i,arr[2000],n;

    printf ("enter the size of the arrey :");

    scanf ("%i",&n);

    printf ("enter all %d numbers :\t\n",n );

    for (i=0;i<n;i++){

        scanf ("%i",&arr[i]);

    }

    min=max=arr[0]; //assume that all are same 

    for (i=0;i<n;i++){

        if (min>arr[i]){

            min=arr[i];

        }

        if (max <arr[i]){

            max=arr[i];

        }

    }

      printf ("minimum number of the arrey is : %i\n",min);

          printf ("maximum number of the arrey is : %i",max); 

         return 0;

 }

                        output               output                       output                        output       

enter the size of the arrey :6

enter all 6 numbers :

34

54

67

98

90

22

minimum number of the arrey is : 22

maximum number of the arrey is : 98

No comments:

Post a Comment

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...