0

Can someone help, how to enter more the 1 word on nama?

#include <stdio.h> int main (void) { char nama[25], nhuruf; float nim, nquis, nuts, nuas, ntotal, ntotal2; printf("Nim : "); scanf("%s",&nim); printf("Nama : "); scanf("%s",&nama); printf("Nilai Quis : "); scanf("%f",&nquis); printf("Nilai UTS : "); scanf("%f",&nuts); printf("Nilai UAS : "); scanf("%f",&nuas); ntotal=(nquis*0.2)+(nuts*0.3)+(nuas*0.5); ntotal2=(nquis+nuts+nuas); printf("Jumlah Nilai : %.0f\n",ntotal2); printf("Nilai Akhir : %.0f\n",ntotal); { if (ntotal>=80) nhuruf='A'; else if (ntotal>=60) nhuruf='B'; else if (ntotal>=40) nhuruf='C'; else if (ntotal>=20) nhuruf='D'; else if (ntotal>=0) nhuruf='E'; printf("Indeks Nilai : %c",nhuruf); return (0); } }

11th Apr 2022, 10:45 AM
budy satria eriza
1 Answer
+ 2
instead of scanf, Use fgets() like : fgets(nama, 25, stdin); //nama array, 25 max width to read, stdin is a stream of read from..
11th Apr 2022, 10:52 AM
Jayakrishna šŸ‡®šŸ‡³