Minggu, 12 Mei 2013

Struktur Data (Coding C)



                                                                                                                                                                           
SCRIPT :
#include
#include
#include
#include
    int main()
{
    int i,n,d,gnp=0,tgnp=0,tgnj=0;
    printf("Masukkan n = ");scanf("%d",&n);
    for(i=0;i
{
    printf("data ke-%d =",(i+1));scanf("%d",&d);
    if(d%2==0){
    gnp++;
    tgnp+=d;
    }else tgnj += d;
}
    printf("Jumlah bilangan genap = %d\n",gnp);
    printf("Jumlah bilangan ganjil = %d\n",(n-gnp));
    printf("Total bilangan genap = %d\n",tgnp);
    printf("Total bilangan ganjil = %d\n",tgnj);
getch();
}              
SCRIPT:
#include
#include

    int main()
{
    int i, a=20;
    for (i=0; i<=a; i++)
  {
    printf("%d\n",i);
    i++;
  }
}

Script :
#include
#include
    int main()
{
    int i, a=20;
    for (i=0; i<=a; i++)
  {
    if(i%2 == !0) {
    printf("%d\n",i); }
  }
}


SCRIPT:
#include
#include

    int main()
{
    int i=3;
    while (i<20 o:p="">
{
    printf("%d\n",i);
    i=i+3;

}
}
SCRIPT:
#include
#include
    int main()
{
    int i, a=20;
    for (i=3; i<=a; i++)
{
    if(i%3 == 0) {
    printf("%d\n",i); }
}
}

Tidak ada komentar:

Posting Komentar