TI

Pertanyaan

contoh program c++ menggunakan fungsi if

2 Jawaban

  • #include<stdio.h>
    #include<cstdlib>
    main()
    {
        int i,j;
        for(i=0;i<3;i++)
        {
         for(j=0;j<0;j++)
        {
            //IF(I==J)
            //{
         printf("1\t");
          }
          //else
           printf("5\t");
            }
           
          printf("\n");
            }
            {
               
    system("PAUSE");
    return EXIT_SUCCESS;
    }
    }



  • #include <conio>
    #include <iostream>
    #include <windows>
    main()
    {
    system("TITLE Contoh If");
    char pilihan[2],hasil[5];
    cout<<"Masukkan Pilihan [A/B]: ";cin>>pilihan;

    if(strcmp(pilihan,"A")==0)
     {
     hasil="aku A";
     }
    else
    {
    hasil="aku B";
    }
    clrscr();
    cout<<"Pilihan yang kamu pilih adalah: "<<hasil;
    getch();
    }

Pertanyaan Lainnya