Source Code :
#include <stdio.h>
#define SIZE 20
int jml, n[SIZE];
int cari(int k);
int main(void) {
int i, k, c;
printf("Jumlah data [max 20]: ");
scanf("%d", &jml);
for(i = 0; i < jml; i++) {
printf("data ke-%d: ", i);
scanf("%d", &n[i]);
}
printf("cari: ");
scanf("%d", &k);
c = cari(k);
if(c < 0)
printf("tidak ketemu");
else
printf("ketemu, pada index: %d", c);
return 0;
}
int cari(int k) {
int i = 0;
do {
if(k == n[i])
return i;
} while(++i < jml);
return -1;
}
Outputnya :
0 comments:
:)) :)] ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} ~x( :-t b-( :-L x( =))
Post a Comment