Source Code :
#include <stdio.h>
#include <conio.h>
using namespace std;
int main () {
char huruf;
char nama[]="Muhammad Juan Syarin";
int usia, berat, tinggi;
int arr[8] = {1, 2, 3, 4, 5, 6, 7, 8}
huruf='M';usia=19;berat=68;tinggi=170;
printf("Huruf depan : %s", huruf);
printf("Nama Lengkap : %s", nama);
printf("Usia : %d", usia);
printf("\nBerat : %d", berat);
printf("\nTinggi : %d", tinggi);
printf("\nNilai ke-7 dari Array (77,78,80,81,82,83,85,89) adalah %i", arr[7]);
getchar();
return 0;
}
I tried to change the value and the variable and to be true i don't know what to do since this is the very first time i try to learn how to make a source code.I hope some guidance for this newbies.
CodePudding user response:
You missed a semicolon while defining the array. Also the format specifier in the first printf statement is for strings, not characters. Replace the %s there with %c. So in change line 10 to int arr[8] = {1, 2, 3, 4, 5, 6, 7, 8};
and replace %s
in line 13 to %c