A program that I wrote that will ask the use to give five numbers and then our program will check which of the five numbers is the smallest and the highest in terms of values using two dimensional array in C language.
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.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
#include <stdio.h>
main()
{
int value[5][1],a=0,b=0,highest=0,lowest=0;
int c[5][1] = {1,2,3,4,5};
for (a=0; a<5; a++) {
for (b=0; b<1; b++) {
printf("Enter value in item no. %d :",c[a][b]);
scanf("%d",&value[a][b]);
}
}
printf("\n\n");
printf("List of values you have given");
printf("\n\n");
highest=value[0][0];
for (a=0; a<5; a++) {
for (b=0; b<1; b++){
if(highest<value[a][b])
highest=value[a][b];
}
}
lowest =value[0][0];
for (a=0; a<5; a++) {
for (b=0; b<1; b++){
if(lowest>value[a][b])
lowest=value[a][b];
}
}
printf("Highest Number : %d. ",highest);
printf("\n\n");
printf("Lowest Number : %d. ",lowest);
printf("\n\n");
}
No comments:
Post a Comment