-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Find Maximum Number in Array | ||
|
||
This code demonstrates how to find maximum integer in an array of integer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//Program Array menampilkan 10 bilangan | ||
//dengan memberi * untuk yang terbesar | ||
|
||
#include <stdio.h> | ||
#include <conio.h> | ||
#include <stdlib.h> | ||
|
||
char toUpper(char x){ | ||
if (x >= 97 && x <= 122) x = x - 32; | ||
return x; | ||
} | ||
|
||
int main(){ | ||
int n[9], MAX; | ||
char r; | ||
do{ | ||
system("cls"); | ||
printf("Program Pencetak 10 Bilangan\n"); | ||
printf("============================\n"); | ||
printf("* menunjukkan bilangan terbesar\n\n"); | ||
//diasumsikan bilangan terbesar yang pertama adalah n[0] | ||
MAX=0; | ||
for(int i=0; i<=9; i++){ | ||
printf("Masukkan Bilangan ke-%d: ", i+1); | ||
scanf("%d", &n[i]); fflush(stdin); | ||
if(n[i]>n[MAX]) MAX=i; | ||
} | ||
for(int i=0; i<=9; i++){ | ||
printf("\nBilangan ke-%d: %d", i+1, n[i]); | ||
if(i==MAX) printf("*");; | ||
} | ||
printf("\n\nIngin Mengulang [Y/N]? "); | ||
do{ | ||
r = toUpper(getch()); | ||
}while(r != 'Y' && r != 'N'); | ||
}while(r == 'Y'); | ||
return 0; | ||
} |