Question 1
Correct
Untuk memasukkan nilai data terformat digunakan perintah scanf(). Spesifikasi formatnya adalah: ”% type”. Kode format dengan jenis
%f berfungsi untuk membaca nilai:
a. Karakter
b. Pecahan
c. Desimal Integer
d. Short Integer
e.
String
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 1/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 2
Incorrect
a. =
b. <<
c. &&
d. <=
e. ++
Question 3
Incorrect
a. 3 4
#include<stdio.h>
b. 3 3
int main(){
int num,a=3; c. 4 3
num = ++a; d. 5 4
printf("%d %d",num,a);
e. 4 4
return 0;
}
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 2/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 4
Correct
b.
Semua deklarasi benar
c.
Hanya (ii), (iii), dan (iv) yang benar
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 3/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 5
Incorrect
#include<stdio.h>
int main(){
float x;
x=0.2==2/10;
printf("%f",x);
return 0; }
output dari code diatas adalah:
a. 2.000000
c. 0.200000
d. 0.000000
e. 1.000000
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 4/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 6
Correct
#include<stdio.h>
main()
{
int jawab,hasil;
jawab = 100;
}
Output dari code program diatas adalah:
a. 109
b. 99
c. 89
d. 107
e. 120
Question 7
Incorrect
a. 1 bytes
b. 8 bytes
c. 4 bytes
d. 2 bytes
e. 3 bytes
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 5/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 8
Incorrect
Tipe data yang paling cocok digunakan untuk menyimpan angka 120 pada sistem 32-bit adalah:
a. float
b. unsigned long
c. short int
d. unsigned integer
e. int
Question 9
Correct
int main()
{
int i = 1;
int j, temp = i;
i++;
i = temp;
printf("%d \n",i+1);
}
a. 0
b. error
c. 1
d. 2
e. 3
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 6/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 10
Correct
#include <stdio.h>
int main()
{
int ch = 1;
switch (ch)
{
case 1:
printf("yes\n");
break;
case 2:
printf("no\n");
break;
}
}
a. yes
b. 2
c. no
d. 0
e. 1
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 7/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 11
Correct
#include <stdio.h>
int main()
{
float f = 10.20;
ch = x;
printf ("line 1: %c \n", ch);
x = f;
printf ("line 2: %i \n", x);
ch = 'a';
f = ch;
printf ("line 3: %f \n", f);
x = 20;
f = x;
a. 10
b. tidak ada
c. 20.00000
d. 29
e. 97.00000
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 8/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 12
Correct
#include <stdio.h>
int main()
{
float f = 10.20;
ch = x;
printf ("line 1: %c \n", ch);
x = f;
printf ("line 2: %i \n", x);
ch = 'a';
f = ch;
printf ("line 3: %f \n", f);
x = 20;
f = x;
a. 20.00000
b. 97.00000
c. 29
d. 10
e. tidak ada
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 9/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 13
Correct
#include <stdio.h>
int main()
{
int x = 10;
int y = ++x;
y = x++;
y = ++x + y++;
a. 23
b. 25
c. 24
d. 21
e. 22
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 10/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 14
Correct
#include <stdio.h>
int main()
{
int x = 7;
int y = ++x;
y = x++;
y = x + y++;
a. 17
b. 18
c. 19
d. 15
e. 16
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 11/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 15
Correct
#include <stdio.h>
int main()
{
//int x = 12;
printf ("shift right: %d\n", 9 << 3);
}
output dari code diatas adalah:
a. 32
b. 72
c. 64
d. 16
e. 144
Question 16
Correct
#include <stdio.h>
int main()
{
//int x = 12;
printf ("shift right: %d\n", 12 >> 2);
}
output dari code diatas adalah:
a. 8
b. 16
c. 4
d. 3
e. 32
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 12/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 17
Correct
#include <stdio.h>
int main()
{
a. 11
b. 0
c. 1
d. 10
e. 12
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 13/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 18
Correct
#include <stdio.h>
int main()
{
}
output dari code diatas adalah:
b. 79
e. anda lulus
Question 19
Incorrect
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 14/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 20
Incorrect
a. <=
b. !=
c. >
d. >>
e. ==
Question 21
Correct
18%5
a. 3
b. 5
c. 3.60000
d. 13
e. 23
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 15/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 22
Correct
27 & 21
a. 23
b. 15
c. 17
d. 1
e. 1010
Question 23
Incorrect
10 ^ 29
a. 15
b. 1
c. 23
d. 17
e. 1010
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 16/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 24
Correct
a. ==
b. +
c. *
d. <<
e. &
Question 25
Incorrect
a. ()
b. >>
c. *
d. +
e. &&
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 17/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 26
Correct
a. 1000001
b. 1100001
c. 1010011
d. 1010001
e. 1100001
Question 27
Incorrect
a. berorientasi objek
c. fungsional
d. prosedural
e. deklaratif
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 18/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 28
Incorrect
#include <stdio.h>
int main()
{
int x = 8;
int y = --x;
y = x--;
y = x * y;
a. 204
b. 2
c. 64
d. 168
e. 128
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 19/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 29
Incorrect
#include <stdio.h>
int main()
{
int x = 8;
int y = --x;
y = x--;
y = x * y;
a. 204
b. 0
c. 42
d. 168
e. 128
Question 30
Correct
jika kita hendak menyimpan nilai 32000 pada suatu variabel, tipe data manakah yang paling tepat untuk digunakan?
a. double
b. int
c. long
d. short int
e. unsigned int
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 20/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 31
Correct
#include<stdio.h>
int main()
{
int i = 1;
int j, temp = i;
++i;
i = temp + 2;
printf("%d \n",i);
}
Select one:
True
False
Question 32
Correct
Select one:
True
False
Question 33
Correct
Select one:
True
False
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 21/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 34
Correct
Select one:
True
False
Question 35
Correct
Select one:
True
False
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 22/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
Question 36
Complete
Task
Given an integer, , perform the following conditional actions:
If is odd, print Weird
If is even and in the inclusive range of to , print Not Weird
If is even and in the inclusive range of to , print Weird
If is even and greater than , print Not Weird
Input Format
A single line containing a positive integer, .
Constraints
Output Format
Print Weird if the number is weird; otherwise, print Not Weird.
Sample Input 0
3
Sample Output 0
Weird
Sample Input 1
24
Sample Output 1
Not Weird
#include <stdio.h>
int main ()
{
int n;
printf("masukan bilangan ");
scanf("%d",&n);
if ( n )
{
printf("weird");
}
printf("not weird");
}
}
else if(n>20)
{
printf("not weired");
}
else
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 23/24
3/16/2021 Ujian Tengah Semester Programming 1: Attempt review
return 0;
}
Question 37
Complete
Task
Complete the getLetter(s) function in the editor. It has one parameter: a string, s, consisting of lowercase English alphabetic letters
(i.e., a through z). It must return A, B, C, or D depending on the following criteria:
If the first character in string s is in the set {a, e, i, o, u}, then return A.
If the first character in string s is in the set {b, c, d, f, g}, then return B.
If the first character in string s is in the set {h, j, k, l, m}, then return C.
If the first character in string s is in the set {n, p ,q,r, s, t, v, w, x, y, z}, then return D.
Hint: You can get the letter at some index i in s using the syntax s[i] or s.charAt(i).
Input Format
Stub code in the editor reads a single string denoting s from stdin.
Constraints
1 <= |s| <= 100, where |s| is the length of s.
String s contains lowercase English alphabetic letters (i.e., a through z) only.
Output Format
Return either A, B, C, or D according to the criteria given above.
Sample Input 0
1 adfgt
Sample Output 0
1 AA
#include <stdio.h>
int main ()
{
int
}
https://ecourse.del.ac.id/mod/quiz/review.php?attempt=117553&cmid=22486 24/24