Thursday, November 19, 2015

Highest and Lowest Number Checker in C

A simple program that I wrote to ask the user to give five numbers and then our program will determine and display the highest and the lowest number.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

#include <stdio.h>
#include <stdlib.h>
main()
 {
     int value[5],a=0,b=0,highest=0,lowest=0;
     system("cls");
     for (a=0; a<5; a++) {
        printf("Enter value in item no. %d :",a+1);
        scanf("%d",&value[a]);
     }
     printf("\n\n");
     printf("List of values you have given");
     printf("\n\n");
     highest=value[b];
     for (b=0; b<5; b++){
         if(highest<value[b])
           highest=value[b];
     }
     lowest =value[0];
      for (b=0; b<5; b++){
         if(lowest>value[b])
          lowest=value[b];
     }
     printf("Highest Number :  %d. ",highest);
     printf("\n\n");
     printf("Lowest Number :  %d. ",lowest);
     printf("\n\n");
     system("pause");

 }


No comments:

Post a Comment