Ujian Tengah Semester Bahasa Pemrograman

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By MuhammadKhoirul Anam
M
MuhammadKhoirul Anam
Community Contributor
Quizzes Created: 1 | Total Attempts: 344
Questions: 31 | Attempts: 345

SettingsSettingsSettings
Ujian Tengah Semester Bahasa Pemrograman - Quiz


Questions and Answers
  • 1. 

    Penulisan Preprocessor yang benar di awali dengan tanda pound atau tanda :

    • A.

      #

    • B.

      &

    • C.

      @3

    • D.

      =

    Correct Answer
    A. #
    Explanation
    The correct answer is # because in preprocessor directives, the pound sign (#) is used to indicate that the line is a preprocessor directive. It is followed by various preprocessor commands or macros that are used to modify the source code before it is compiled. The other options (ampersand (&), at symbol (@), and equals sign (=)) are not valid preprocessor directives and would result in a compilation error.

    Rate this question:

  • 2. 

    Contoh penulisan file header yang benar yaitu :

    • A.

      &include <conio.h>

    • B.

      #include <conio.h>

    • C.

      =include <conio.h>

    • D.

      *include <conio.h>

    Correct Answer
    B. #include <conio.h>
    Explanation
    The correct answer is "#include ". This is the correct way to write a file header in C++ to include the "conio.h" library. The "#" symbol is used to indicate a preprocessor directive, and "include" is the keyword used to include a header file. The header file name is enclosed in angle brackets "" to indicate that it is a system header file. The correct syntax is followed in the given answer.

    Rate this question:

  • 3. 

    Perintah cout<< dan cin>> merupakan perintah miliknya file header :

    • A.

      #include <iostream.h> 

    • B.

      #include <stdlib.h>

    • C.

      #include <conio.h>

    • D.

      #include <stdio.h> 

    Correct Answer
    A. #include <iostream.h> 
    Explanation
    The correct answer is #include . This is because the cout> commands are part of the iostream library, which is included using the #include statement. The other header files listed (stdlib.h, conio.h, and stdio.h) are not related to the iostream library and do not provide the necessary commands for input and output.

    Rate this question:

  • 4. 

    Dalam bahasa pemrograman C++ untuk membuat komentar lebih dari satu barismenggunakan :

    • A.

      /* … */

    • B.

      ||

    • C.

      \\

    • D.

      {}

    Correct Answer
    A. /* … */
    Explanation
    The correct answer is /* ... */. In C++, to create a multi-line comment, we use /* at the beginning and */ at the end. This allows us to write comments that span multiple lines without having to add // at the beginning of each line.

    Rate this question:

  • 5. 

    Untuk mendeklarasikan variabel dalam bahasa pemrograman C++ yaitu :

    • A.

      Int a,b;   

    • B.

      Int 1; 

    • C.

      Int a;b;  

    • D.

      Char a<3>

    Correct Answer
    A. Int a,b;   
    Explanation
    The correct answer is "int a,b;". This is because in C++, to declare multiple variables of the same type, you can separate them with commas. In this case, the variables "a" and "b" are both of type "int" and are declared correctly. The other options are incorrect. "int 1;" is invalid because variable names cannot start with a number. "int a;b;" is also invalid because there should be a space between the variable names. "char a" is invalid because the angle brackets are not used in variable declarations.

    Rate this question:

  • 6. 

    Tipe data Boolean yaitu tipe data yang :

    • A.

      Tipe data untuk numeric 

    • B.

      Tipe data untuk string

    • C.

      Tipe data yang hanya memiliki dua nilai true dan false

    • D.

      Tipe data untuk bilangan ganjil

    Correct Answer
    C. Tipe data yang hanya memiliki dua nilai true dan false
    Explanation
    The correct answer is "Tipe data yang hanya memiliki dua nilai true dan false" which translates to "Boolean data type is a data type that only has two values, true and false." This means that a Boolean data type can only represent two possible states or values, true or false, and is commonly used in programming to represent logical conditions or binary choices.

    Rate this question:

  • 7. 

    Untuk menampilkan text “Selamat Datang” menggukanan perintah :

    • A.

      Cout<< “Selamat Datang”;

    • B.

      COUT<< “Selamat Datang”;

    • C.

      Cout<<”Selamat Datang”;

    • D.

      Cout>>”Selamat Datang”;

    Correct Answer
    C. Cout<<”Selamat Datang”;
    Explanation
    The correct answer is "cout<<”Selamat Datang”;". This is because the "cout" command is used to display output on the screen in C++. The "

    Rate this question:

  • 8. 

    Untuk menginputkan data ke variabel menggunakan perintah :

    • A.

      Cout<<

    • B.

      Getch() 

    • C.

      <<endl;

    • D.

      Cin>>

    Correct Answer
    D. Cin>>
    Explanation
    The correct answer is "cin>>". This is because "cin" is the input stream object in C++ that is used to read data from the user. The ">>" operator is used to extract data from the input stream and store it into a variable. Therefore, "cin>>" is the correct way to input data into a variable in C++.

    Rate this question:

  • 9. 

    Manakah yang salah dari 4 pilihan di bawah ini :

    • A.

      Cout<<”Selamat Pagi Semua”<<end

    • B.

      Cout<<endl<<”Selamat Pagi Semua”;

    • C.

      Cout<<”Selamat Pagi Semua”<<endl;

    • D.

      Cout<<”\nSelamat Pagi Semua”;

    Correct Answer
    A. Cout<<”Selamat Pagi Semua”<<end
    Explanation
    The correct answer is "cout

    Rate this question:

  • 10. 

    Dari program di bawah ini, berapa hasil output dari variabel jwb : #include <iostream.h> #include <conio.h> main() { int i = 4; int j = 8; int k = 12; int  jwb; jwb = i + j; cout << jwb ; jwb += k; cout <<endl<< jwb; getch(); }

    • A.

      12 dan 20

    • B.

      24 dan 30

    • C.

      12 dan 24

    • D.

      24 dan 24

    Correct Answer
    C. 12 dan 24
    Explanation
    The program initializes variables i, j, and k with values 4, 8, and 12 respectively. The variable jwb is declared but not initialized. The value of jwb is then assigned the sum of i and j, which is 12. The value of jwb is printed out as the first output. Then, the value of jwb is incremented by k, which is 12, resulting in a new value of 24. This new value of jwb is printed out as the second output. Therefore, the correct answer is 12 and 24.

    Rate this question:

  • 11. 

    Dari program di bawah ini apa outputnya jika kita menginputkan nilai 5 : #include #include main() { int nilai;  cout<<"Masukkan Nilai ="; cin>>nilai; if (nilai % 2 == 0) cout<<"bilangan genap"; elsecout<<"bilangan ganjil"; getch(); }

    • A.

      Bilangan genap

    • B.

      Bilangan ganjil

    • C.

      Bilangan nol

    • D.

      Semua salah

    Correct Answer
    B. Bilangan ganjil
    Explanation
    The given program asks the user to input a value and checks if the value is divisible by 2 using the modulo operator (%). If the remainder is 0, it prints "bilangan genap" (even number), indicating that the input value is even. If the remainder is not 0, it prints "bilangan ganjil" (odd number), indicating that the input value is odd. In this case, since the input value is 5, which is not divisible by 2, the program will output "bilangan ganjil".

    Rate this question:

  • 12. 

    Dalam bahasa pemrograman C++ untuk membuat komentar satu baris menggunakan :

    • A.

      //

    • B.

      ||

    • C.

      \\

    • D.

      {}

    Correct Answer
    A. //
    Explanation
    The correct answer is "//" because in C++, the "//" symbol is used to create a single-line comment. Anything written after "//" on the same line is considered as a comment and is ignored by the compiler. This allows programmers to add explanatory notes or disable certain lines of code without affecting the program's functionality.

    Rate this question:

  • 13. 

    Perulangan yang sudah diketahui batas perulangannya, merupakan perulangan :

    • A.

      While

    • B.

      Goto

    • C.

      Do while

    • D.

      For

    Correct Answer
    D. For
    Explanation
    A for loop is a loop that is used when the number of iterations is known beforehand. It consists of three parts: initialization, condition, and increment/decrement. The loop will continue to execute as long as the condition is true. In this case, since the number of iterations is already known, a for loop would be the appropriate choice.

    Rate this question:

  • 14. 

    Perulangan yang melakukan pengecekan kondisi di awal blok struktur, merupakan perulangan :

    • A.

      While

    • B.

      Goto

    • C.

      Do while

    • D.

      For

    Correct Answer
    A. While
    Explanation
    The correct answer is "while" because a while loop checks the condition at the beginning of the loop structure. It continues to execute the loop as long as the condition is true.

    Rate this question:

  • 15. 

    Perulangan yang melakukan pengecekan kondisi di akhir blok struktur, merupakan perulangan :

    • A.

      While

    • B.

      Goto

    • C.

      Do while

    • D.

      For

    Correct Answer
    C. Do while
    Explanation
    The correct answer is "do while" because a do while loop is a type of loop that executes a block of code at least once, and then repeats the execution as long as a certain condition is true. In this type of loop, the condition is checked at the end of the loop, which means that the code block will always be executed at least once before the condition is evaluated.

    Rate this question:

  • 16. 

    Dalam menyusun suatu program, langkah pertama yang harus dilakukan adalah :

    • A.

      Membuat program

    • B.

      Membuat Algoritma 

    • C.

      Membeli komputer

    • D.

      Mempelajari program

    Correct Answer
    B. Membuat Algoritma 
    Explanation
    The correct answer is "Membuat Algoritma". In programming, the first step is to create an algorithm. An algorithm is a step-by-step procedure or a set of rules to solve a specific problem. It helps in organizing and planning the logic of the program before actually writing the code. By creating an algorithm, programmers can have a clear understanding of the problem and the steps required to solve it, which makes the coding process more efficient and effective.

    Rate this question:

  • 17. 

    Sebuah prosedur langkah demi langkah yang pasti untuk menyelesaikan sebuah masalah disebut :

    • A.

      Proses

    • B.

      Program

    • C.

      Algoritma

    • D.

      Prosesor

    Correct Answer
    C. Algoritma
    Explanation
    An algorithm is a precise step-by-step procedure to solve a problem. It provides a clear set of instructions that can be followed to achieve a desired outcome. Unlike a process, which is a series of actions or steps, an algorithm is specifically designed to solve a problem. A program, on the other hand, is a set of instructions written in a programming language to carry out a specific task. A processor refers to the hardware component of a computer that executes instructions. Therefore, the correct answer in this case is "Algoritma" as it best fits the description of a definite step-by-step procedure to solve a problem.

    Rate this question:

  • 18. 

    Pseudocode yang digunakan pada penulisan algoritma dapat berupa :

    • A.

      Bahasa Inggris

    • B.

      Bahasa Puitis

    • C.

      Bahasa pemrograman

    • D.

      Sembarang bahasa asal terstruktur

    Correct Answer
    D. Sembarang bahasa asal terstruktur
    Explanation
    The correct answer is "Sembarang bahasa asal terstruktur". This means that pseudocode used in algorithm writing can be in any structured language. This suggests that there is flexibility in choosing the language for writing pseudocode, as long as it follows a structured format.

    Rate this question:

  • 19. 

    Diberikan algoritma P=10; P=P+5; Q=P. Nilai P dan Q masing-masing adalah:

    • A.

      15 dan 0

    • B.

      0 dan 15

    • C.

      15 dan 15 

    • D.

      10 dan 15

    Correct Answer
    C. 15 dan 15 
    Explanation
    The given algorithm initializes P with a value of 10. Then, it adds 5 to P, resulting in a new value of 15. Finally, the value of P is assigned to Q. Therefore, both P and Q will have a value of 15.

    Rate this question:

  • 20. 

    Pada pembuatan program komputer, algoritma dibuat :

    • A.

      Sebelum pembuatan program

    • B.

      Pada saat program dibuat

    • C.

      Sesudah pembuatan program

    • D.

      Pada saat verifikasi program

    Correct Answer
    A. Sebelum pembuatan program
    Explanation
    The correct answer is "Sebelum pembuatan program" because in the context of computer program development, algorithms are created before the actual program is made. Algorithms are step-by-step procedures or instructions that outline the logical process of solving a problem. They serve as a blueprint for the program and help in organizing the code and achieving the desired functionality. Therefore, it is necessary to create algorithms before starting the actual program development process.

    Rate this question:

  • 21. 

    Apabila a=5, b = 10, maka jika diberikan instruksi a=b; b=a akan mengakibatkan :

    • A.

      A=0 , b=5

    • B.

      A=10, b=5

    • C.

      A=10, b=10 

    • D.

      A=10 , b=0

    Correct Answer
    C. A=10, b=10 
    Explanation
    If the instructions "a=b; b=a" are given when a=5 and b=10, it means that the value of a is assigned to b first (b=5), and then the value of b is assigned to a (a=5). Therefore, both a and b will have a value of 5.

    Rate this question:

  • 22. 

    Dalam bahasa C++ terdapat suatu tipe data yang nilainya tidak boleh memiliki nilai desimal, yaitu :

    • A.

      Float

    • B.

      Boolean

    • C.

      Int

    • D.

      Char

    Correct Answer
    C. Int
    Explanation
    The correct answer is "int". In C++, the "int" data type is used to store whole numbers without decimal points. It can hold both positive and negative values within a certain range. The "float" data type is used to store numbers with decimal points, while the "boolean" data type is used to store true or false values. The "char" data type is used to store single characters.

    Rate this question:

  • 23. 

    Tipe data yang digunakan untuk menampung sebuah karakter adalah :

    • A.

      String

    • B.

      Int

    • C.

      Boolean

    • D.

      Char

    Correct Answer
    D. Char
    Explanation
    The correct answer is "char". The data type "char" is used to store a single character in programming. It can hold any character from the ASCII character set, including letters, numbers, and special characters. Unlike a string, which is a sequence of characters, a char variable can only hold one character at a time.

    Rate this question:

  • 24. 

    Diberikan penggalan algoritma : do cout<<x ; x-- while (x>7) Apabila nilai awal x adalah 9, maka nilai yang ditampilkan berturut-turut adalah

    • A.

      9, 8, 7,6

    • B.

      9, 8 ,7 

    • C.

      9

    • D.

      8, 7

    Correct Answer
    B. 9, 8 ,7 
    Explanation
    The given algorithm starts by printing the value of x, which is initially 9. Then, it decrements the value of x by 1 using the x-- statement. The algorithm continues to repeat this process as long as the value of x is greater than 7. Therefore, the values that will be displayed are 9, 8, and 7.

    Rate this question:

  • 25. 

    Diberikan penggalan algoritma : while (x>7) x- - ; cout<<x ; Apabila nilai awal x adalah 9, maka nilai yang ditampilkan berturut-turut adalah

    • A.

      9, 8, 7

    • B.

      9, 8

    • C.

      9

    • D.

      8, 7

    Correct Answer
    D. 8, 7
    Explanation
    The given algorithm uses a while loop to decrement the value of x by 1 until it is greater than 7. The value of x starts at 9. So, in the first iteration, x becomes 8 and is displayed. In the second iteration, x becomes 7 and is displayed. Since x is no longer greater than 7, the loop terminates. Therefore, the values displayed are 8, 7.

    Rate this question:

  • 26. 

    Diberikan algoritma : Apabila warna merah maka jadi hijau. Apabila warna hijau maka jadi putih, selain warna merah dan hijau maka jadi ungu. Jika kondisi input warna adalah hitam, maka warna jadi :

    • A.

      Merah

    • B.

      Ungu

    • C.

      Hijau

    • D.

      Putih

    Correct Answer
    B. Ungu
    Explanation
    The given algorithm states that if the input color is not red or green, then it will become purple. Since the answer is "purple," it implies that the input color is neither red nor green, and therefore it falls into the category of "other colors" mentioned in the algorithm.

    Rate this question:

  • 27. 

     Tahapan dalam menyelesaikan suatu masalah adalah :

    • A.

      Masalah – Pseudocode – Flowchart – Program – Eksekusi – Hasil

    • B.

      Masalah – Model – Algoritma – Eksekusi – Hasil

    • C.

      Masalah – Algoritma – Flowchart – Program – Eksekusi – Hasil

    • D.

      Masalah – Model – Algoritma – Program – Eksekusi – Hasil

    Correct Answer
    D. Masalah – Model – Algoritma – Program – Eksekusi – Hasil
    Explanation
    The correct answer is "Masalah - Model - Algoritma - Program - Eksekusi - Hasil". This sequence represents the step-by-step process of problem-solving. First, we identify the problem (Masalah), then we create a model or plan (Model) to solve the problem. Next, we develop an algorithm (Algoritma) which is a set of instructions to solve the problem. After that, we write a program (Program) based on the algorithm. The program is then executed (Eksekusi) to obtain the desired result (Hasil). This sequence ensures a systematic approach to problem-solving.

    Rate this question:

  • 28. 

    Tempat menampung data atau konstanta di memori yang mempunya nilai atau data yang dapat berubah-ubah selama proses program disebut . . .

    • A.

      Tipe data

    • B.

      Variabel

    • C.

      Konstanta

    • D.

      String

    Correct Answer
    B. Variabel
    Explanation
    A variable is a place in memory where data or constants are stored, and their values can change during the program's execution. It is used to store and manipulate data in a program.

    Rate this question:

  • 29. 

    Struktur pernyataan yang BUKAN berupa perulangan (looping) adalah :

    • A.

      For

    • B.

      Do...while

    • C.

      If

    • D.

      While

    Correct Answer
    C. If
    Explanation
    The statement "if" is not a looping structure. It is a conditional statement that allows the execution of a block of code only if a specified condition is true. Unlike looping structures such as "for", "do...while", and "while" which repeat a block of code multiple times, the "if" statement is used for making decisions based on the evaluation of a condition.

    Rate this question:

  • 30. 

    Suatu Proses yang memanggil dirinya sendiri , disebut proses :

    • A.

      Iteratif

    • B.

      Transitif

    • C.

      Rekursif 

    • D.

      Branching

    Correct Answer
    C. Rekursif 
    Explanation
    Rekursif adalah suatu proses yang memanggil dirinya sendiri. Dalam rekursif, sebuah fungsi atau prosedur dapat memanggil dirinya sendiri untuk memecahkan masalah yang lebih kecil, yang pada gilirannya dapat memanggil dirinya sendiri lagi, dan seterusnya. Dengan demikian, rekursif memungkinkan solusi yang lebih sederhana dan elegan untuk masalah yang dapat dipecahkan dengan cara ini.

    Rate this question:

  • 31. 

    Diketahui bahwa kantong P kosong, kantong Q berisi 10 buah kelereng dan kantong R berisi 15 kelereng. Apabila yang terbawa hanya sebuah kantong dan dikatakan BUKAN Kantong P yang terbawa, maka jumlah kelereng yang terbawa adalah :

    • A.

      10

    • B.

      15

    • C.

      10 atau 15

    • D.

      Kosong

    Correct Answer
    C. 10 atau 15
    Explanation
    Jumlah kelereng yang terbawa bisa jadi 10 atau 15, karena dikatakan bahwa yang terbawa bukan Kantong P. Jadi, yang terbawa bisa jadi kantong Q yang berisi 10 kelereng atau kantong R yang berisi 15 kelereng.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 16, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 23, 2019
    Quiz Created by
    MuhammadKhoirul Anam
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.