Hi quest ,  welcome  |  sign in  |  registered now  |  need help ?

adsense link 728px X 15px

membuat respon dalam range 10 (array)

Written By Mr Poetrixuz on Minggu, 23 Januari 2011 | 03.57

#include<stdio.h>
#include<conio.h>
main()
{
    int hitungan[11],i,respon;
    for(i=1;i<=10;++i)
        hitungan[i]=0;
    printf("masukkan respon anda (1000x):\n");
    for(i=1;i<=1000;++i){
        scanf("%d",&respon);
            if(respon==999)break;
            if(respon<1||respon>10)
                printf("respon salah:%d\n",respon);
            else
                ++hitungan[respon];}
            printf("\n\n");
            printf("Nomor                         Jumlah Respon\n");
            printf("-------------------------------------------------\n");
            for(i=1;i<=10;++i)
                printf("%4d                       %ld\n",i,hitungan[i]);
            getch();
}

0 komentar:

Posting Komentar