C++ Program to Calculate Student Grades (CPCSG)



AVAILABLE:    1

Previously we have known how the basic principles of using  Functions With Return Values  , accompanied by some simple examples. Not only that, friends have also been shown about  the Difference Between Return Value Functions and Without Return Values .

Now, it's time for friends to be given a more complete program example, using various forms of functions, both with return values ​​and without. The implementation in this case is to calculate student grades.

Variation 1:

C++ Function With Return Value To Calculate Student Grades
C++ Function With Return Value To Calculate Student Grades

Source Code:

#include <iostream.h>
#include <conio.h>
#include <string.h>

/**
*bundet.com
*Contoh C++ Fungsi Dengan Nilai Balik
*Menghitung Nilai Mahasiswa
*/

void judul();
char tanya();
void isi();
char huruf(float rat);

void cetak(int a, int b, char *teks)
{
 gotoxy(b,a);cout<<teks;
}

void cetakc(int a, char *teks)
{
 gotoxy(40-((strlen(teks)/2)),a);cout<<teks;
}

void main()
{
 judul();
 isi();
   cout<<endl<<endl;
 cout<<"copyright2014-www.gatewan.com";
 getch();
}

void judul()
{
 cetakc(1,"DAFTAR NILAI");
 cetakc(2,"PRODI TEKNIK INFORMATIKA");
cetak(4,4,"========================================================================");
 cetak(5,4,"|");
 cetak(5,7,"No");
 cetak(5,10,"|");
 cetak(5,14,"NIM");
 cetak(5,21,"|");
 cetak(5,27,"N A M A");
 cetak(5,44,"|");
 cetak(5,46,"UTS");
 cetak(5,50,"|");
 cetak(5,52,"UAS");
 cetak(5,56,"|");
 cetak(5,58,"TUGAS");
 cetak(5,64,"|");
 cetak(5,66,"NILAI HRF");
 cetak(5,76,"|");
cetak(6,4,"========================================================================");
}

void isi()
{
 int nim,uts,uas,tugas,tot;
 char nama[15],maxnm[15],minnm[15];
 float rata,maxnil,minnil,ratkelas,totrat;
 char jawab;
 static int i = 1;
 maxnil=0;minnil=100;totrat=0;
 do
 {
 gotoxy(4,6+i);cout<<"|";
 gotoxy(7,6+i);cin>>i;
 gotoxy(10,6+i);cout<<"|";
 gotoxy(12,6+i);cin>>nim;
 gotoxy(21,6+i);cout<<"|";
 gotoxy(23,6+i);cin>>nama;
 gotoxy(44,6+i);cout<<"|";
 gotoxy(46,6+i);cin>>uts;
 gotoxy(50,6+i);cout<<"|";
 gotoxy(52,6+i);cin>>uas;
 gotoxy(56,6+i);cout<<"|";
 gotoxy(58,6+i);cin>>tugas;
 gotoxy(64,6+i);cout<<"|";

 tot=uts+uas+tugas;
 rata=tot/3;
 totrat=totrat+rata;
 ratkelas=totrat/i;
 if(rata>maxnil)
 {
  maxnil=rata;
  strcpy(maxnm,nama);
 }
 if(rata<minnil)
 {
  minnil=rata;
  strcpy(minnm,nama);
 }
 gotoxy(69,6+i);cout<<huruf(rata);
 gotoxy(76,6+i);cout<<"|";
 jawab=tanya();
 if(jawab=='t')
 {
 gotoxy(4,7+i);
 cout<<"========================================================================";
 gotoxy(4,8+i);cout<<"Jumlah data : "<<i;
 gotoxy(4,9+i);cout<<"Rata kelas : "<<ratkelas;
 gotoxy(4,10+i);cout<<"Nilai tertinggi : "<<maxnil;
 gotoxy(30,10+i);cout<<"Nama : "<<maxnm;
 gotoxy(4,11+i);cout<<"Nilai terendah : "<<minnil;
 gotoxy(30,11+i);cout<<"Nama : "<<minnm;
 }
 i++;
 }while(jawab!='t');
}

char tanya()
{
 char jw;
 cetak(3,20,"input data lagi[Y/T]? : ");
 cin>>jw;
 gotoxy(20,3);clreol();
 return(jw);
}

char huruf(float rat)
{
 if(rat>80)
 return('A');
 else if(rat>70)
 return('B');
 else if(rat>60)
 return('C');
 else if(rat>50)
 return('D');
 else
 return('E');
}

Meanwhile, below is an example of a C++ program created to calculate student grades, but still uses  the Basic Concept of Structure (struct) .

Variation 2:

C++ Structure To Calculate Student Grades
C++ Structure To Calculate Student Grades

Source Code:

#include <stdio.h>
#include <conio.h>
#include <string.h>
#define maks 3
struct TMhs

/**
*bundet.com
*Contoh C++ Struktur
*Menghitung Nilai Mahasiswa
*/

{
char NIM[9];
char Nama[21];
int NilaiUTS,NilaiUAS,NilaiQuis;
float NilaiAkhir;
char index;
};

main()
{
TMhs mhs[maks]; // array struct

int i;
for(i=0;i<maks;i++)

{
printf("\nPengisian Data Mahasiswa Ke-%i\n",i+1);
printf("NIM : ");fflush(stdin);gets(mhs[i].NIM);
printf("NAMA : ");fflush(stdin);gets(mhs[i].Nama);
printf("Nilai QUIZ : ");scanf("%d",&mhs[i].NilaiQuis);
printf("Nilai UTS : ");scanf("%d",&mhs[i].NilaiUTS);
printf("Nilai UAS : ");scanf("%d",&mhs[i].NilaiUAS);

mhs[i].NilaiAkhir=0.2*mhs[i].NilaiQuis+0.3*mhs[i].NilaiUTS+0.5*mhs[i].NilaiUAS;

if(mhs[i].NilaiAkhir>=80) mhs[i].index='A';
else

if(mhs[i].NilaiAkhir>=60) mhs[i].index='B';
else

if(mhs[i].NilaiAkhir>=40) mhs[i].index='C';
else

if(mhs[i].NilaiAkhir>=20) mhs[i].index='D';
else

if(mhs[i].NilaiAkhir>=0) mhs[i].index='E';
};
clrscr();
printf("Data yang telah dimasukan adalah : \n");
printf("---------------------------------------\n");
printf("| NIM | NAMA | QUIS | UTS | UAS | Nilai Akhir | INDEX |\n");
printf("---------------------------------------\n");

for(i=0;i<maks;i++)
{
printf("| %-3s | %-4s | %-4i | %3i | %3i | %11f | %5c |\n",
mhs[i].NIM,mhs[i].Nama,mhs[i].NilaiQuis,mhs[i].NilaiUTS,
mhs[i].NilaiUAS,mhs[i].NilaiAkhir,mhs[i].index);
}
printf("--------------------------------------\n");
getch();
return 0;
}

Variation 3:

https://youtu.be/-ZgEzI2VdcM

Conclusion of Debugging Program Variation 3:

Finally finished debugging the source code of this program, after almost a year of leave from campus activities, now in this holy month I have the opportunity to touch up old assignments that were stuck and never finished. Alhamdulillah this time it's finished. Among several errors, one of them is the previous program using looping variables for index variables. Here are the conclusions or lessons that can be learned:

  1. Never use global variables for looping processes (repeating a program block)
  2. Dedicate a looping variable for each program block, for example; if a buffer uses the variable i, then each looping must not use the same variable name, for example for (int i=1; i < k; i++) this is not allowed. Although it is actually possible, either with the same data type or different data types, but for structured programming purposes this is highly discouraged.
  3. Never ignore the standardization of program line creation. Therefore, plan in advance when compiling a flowchart.

And one of the efforts to identify the error, I tried to create a simple manual looping program, the goal is so that I can peek at the changes in the actual looping value, as well as compare or be a reference for all the loops contained in the source code.

Assistance Program:

#include <iostream.h>
#include <conio.h>
#include <cstring.h>
#include <stdio.h>
#include <iomanip.h>
#include <stdlib.h>

/**
*bundet.com
*Manual Looping Untuk Membantu Debugging
*/

int i=1;
char pil;

void main(){
for(int a=1; a>0; a++){
cout<<"y or n?";
cin>>pil;
cout<<endl;
if(pil=='y'){
i++;
}
cout<<i;cout<<" ";
}
}

Source Code:

#include <iostream.h>
#include <conio.h>
#include <cstring.h>
#include <stdio.h>
#include <iomanip.h>
#include <stdlib.h>

/**
*bundet.com
*Input Nilai Mahasiswa dg index (array dimensi 1)
*/

/* tempat mendeklarasikan prorotipe fungsi-fungsi dan
variabel-variabel yang sekiranya perlu dikenali secara global */
//--------------------------------------------------------------------------
void menu(); void entrydata12131294(); muncul12131294(); bye12131294();
void cetak12131294(int row, char *text); int bom12131294(); back();
void entrynilai12131294(); int habot12131294(int bobot);
int pilihan, w, i=1, lagi=0, bot;
string inputlg, nim, nm, jurusan, smstr, kode[15][15], nmatakul[15][15], sks[15][15], nilai[15][1];

//------------------------------------------------------------------------

 void main()
{

 for (int a=1; a>0; a++)
 {
    clrscr();
    menu();
    if (pilihan==1)
  {
    entrydata12131294();
      do{
      entrynilai12131294();
      habot12131294(bot);
      i++;
      }while(inputlg=="y");
      }
  else if (pilihan==2)
  {
      clrscr();
      muncul12131294();
      cout<<endl<<endl;
      back();
    }
  else if (pilihan==3)
  {
    bom12131294();
    exit(bom12131294());
     }
    else
  {
    cout<<"kode yang anda masukan salah!!, silakan ulangi lagi, terimakasih";
    }
  }
getch();
}

//**disini tempat saya mendefinisikan fungsi**//

//fungsi menu *********************************************
void menu()
{
cout<<"Menu Pilihan: \n";
cout<<"1. Entry Nilai Mahasiswa \n";
cout<<"2. Tampil Nilai Mahasiswa \n";
cout<<"3. Exit \n";
cout<<"\n";
cin>>pilihan;
cout<<endl<<endl;
}

//*********************************************************
//fungsi entri data****************************************

void entrydata12131294()
{
cout<<"Mahasiswa \n";
cout<<"----------------------------------\n";
cout<<"NIM "<<setw(12)<<": ";cin>>nim;
cout<<"Nama"<<setw(12)<<": ";cin>>nm;
cout<<"Jurusan"<<setw(9)<<": ";cin>>jurusan;
cout<<"Semester "<<setw(7)<<": ";cin>>smstr;
cout<<endl<<endl;
}

void entrynilai12131294()
{
cout<<"Matakuliah dan Nilai \n";
cout<<"--------------------------------------\n";
cout<<"Kode "<<setw(15 )<<": ";cin>>kode[i][1];
cout<<"Nama Matakuliah "<<setw(4)<<": ";cin>>nmatakul[i][1];
cout<<"SKS "<<setw(4)<<": ";cin>>sks[i][1];
cout<<"Nilai (Huruf) "<<setw(4)<<": ";cin>>nilai[i][1];
cout<<"Input Nilai Lagi (y/t) "<<setw(6)<<": ";cin>>inputlg;
cout<<endl<<endl;
}

//-----------------bobot------------------
int habot12131294(int bobot)
{
int j;
 if (nilai[j][1]=='a' || nilai[j][1]=='A')
   {
 bobot = 4;
   }
 else  if (nilai[j][1]=='b' || nilai[j][1]=='B')
   {
   bobot = 3;
   }
 else  if (nilai[j][1]=='c' || nilai[j][1]=='C')
   {
   bobot = 2;
   }
   else  if (nilai[j][1]=='d' || nilai[j][1]=='D')
   {
   bobot = 1;
   }
 else
   {
 bobot = 0;
   }
return (bobot);
}

//---------------------tampil--------------------
muncul12131294()
{
cout<<"NIM "<<setw(12)<<": "<<nim<<endl;
cout<<"Nama"<<setw(12)<<": "<<nm<<endl;
cout<<"Jurusan"<<setw(9)<<": "<<jurusan<<endl;
cout<<"Semester "<<setw(7)<<": "<<smstr<<endl;

gotoxy(1,7); cout<<"--------------------------------------------------------------------------------";
gotoxy(1,9); cout<<"--------------------------------------------------------------------------------";
gotoxy(1,8); cout<<"|";
gotoxy(6,8); cout<<"|";
gotoxy(20,8); cout<<"|";
gotoxy(45,8); cout<<"|";
gotoxy(57,8); cout<<"|";
gotoxy(68,8); cout<<"|";
gotoxy(80,8); cout<<"|";
gotoxy(3,8); cout<<"No";
gotoxy(8,8); cout<<"Kode";
gotoxy(22,8); cout<<"Nama Matakuliah";
gotoxy(47,8); cout<<"SKS";
gotoxy(59,8); cout<<"Nilai";
gotoxy(70,8); cout<<"Bobot";

for (int j=1; j<i; j++)
{
gotoxy(3,10+j); cout<<j<<".";
gotoxy(8,10+j); cout<<kode[j][1];
gotoxy(22,10+j); cout<<nmatakul[j][1];
gotoxy(47,10+j); cout<<sks[j][1];
gotoxy(59,10+j); cout<<nilai[j][1];
gotoxy(70,10+j); cout<<habot12131294(bot);
}

}

//******************************************************************************
//fungsi author display sebelum exit********************************************
bye12131294()//mendeklarasikan array dengan pointer(*) untuk fungsi cetak12131294
 {
   clrscr();
 cetak12131294(1,"RESPONSI");
   cetak12131294(2,"INPUT NILAI MAHASISWA");
   cetak12131294(3,"PRAKTIKUM PEMROGRAMAN SYSTEM");
   cetak12131294(4,"AUTHOR : WAWAN CHAHYO NUGROHO / 12131294");
   cetak12131294(5,"PRODI  : S1, TEKNIK INFORMATIKA");
   cetak12131294(6,"STMIK ELRAHMA YOGYAKARTA ");
   cetak12131294(7,"Please Sabar broo...");
 }
//********************************************************************************
//fungsi cetak12131294 tengah***********************************************************
void cetak12131294(int row, char *text)
 {
 gotoxy(40-strlen(text)/2,row); cout<<text;//strlen utk mghtung pjg char // dalam layar monitor terdiri dari 25 baris dan 80 kolom
 }
//********************************************************************************
//fungsi timmer gaya gue :D ****************************************************
int bom12131294()
{
int x;
for(int n=3555;n>=1;n--)
{
 for(int m=n;m>=1;m--)
 {
    for(int o=m;o>=1;o--)
  {
    x=o;
    x--;
 }
   x=m;
   x--;
 }
   x=n;
   bye12131294();
   cout<<x;
 }
return 0;
}
//********************************************************************************
//fungsi back to menu setelah list***********************************************
back()
{
do{
cout<<"Silakan Tekan 0 untuk kembali ke menu";cin>>w;
if (w==0)
 {
   clrscr();
   menu();
   }
   else
   {
   cout<<"angka yang anda masukan tidak benar"<<endl;
   }
}
while(w != 0);
}
//*******************************************************************************

Variation 4:

C++ Simple Student Grade Calculation v4
C++ Simple Student Grade Calculation v4

Source Code:

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>

/**
*bundet.com
*C++ Menghitung Nilai Mahasiswa - Variasi 4
*/

main()
{
char nama[20][30],grade[20];
int i,j,tgs[20],uts[20],uas[20],akhir[20];
clrscr();
cout<<" PROGRAM HITUNG NILAI AKHIR "<<endl;
cout<<" MATERI PEMROGRAMAN C++ "<<endl<<endl;
cout<<" Masukan Jumlah Mahasiswa : ";cin>>j;
cout<<endl;

for(i=1;i<=j;i++)
{
cout<<" Mahasiswa Ke - "<<i<<endl;
cout<<" Nama Mahasiswa : ";gets(nama[i]);
cout<<" Nilai Tugas : ";cin>>tgs[i];
cout<<" Nilai UTS : ";cin>>uts[i];
cout<<" Nilai UAS : ";cin>>uas[i];
akhir[i]=(tgs[i]*0.3)+(uas[i]*0.3)+(uas[i]*0.4);
if(akhir[i]>=80)
grade[i]='A';
else if(akhir[i]>=70&&akhir[i]<80)
grade[i]='B';
else if(akhir[i]>=59&&akhir[i]<70)
grade[i]='C';
else if(akhir[i]>=50&&akhir[i]<59)
grade[i]='D';
else
grade[i]='E';
cout<<endl;
}
clrscr();
cout<<" DAFTAR NILAI "<<endl;
cout<<" MATERI : PEMROGRAMAN C++ "<<endl;
cout<<"--------------------------------------------------------- "<<endl;
cout<<"No.  Nama                     Nilai "<<endl;
cout<<"     Mahasiswa     -----------------------------    Grade "<<endl;
cout<<"                   Tugas   UTS     UAS     Akhir "<<endl;
cout<<"--------------------------------------------------------- "<<endl;
for(i=1;i<=j;i++)
{
cout<<setiosflags(ios::left)<<setw(5)<<i;
cout<<setiosflags(ios::left)<<setw(14)<<nama[i];
cout<<setiosflags(ios::left)<<setw(8)<<tgs[i];
cout<<setiosflags(ios::left)<<setw(8)<<uts[i];
cout<<setiosflags(ios::left)<<setw(8)<<uas[i];
cout<<setiosflags(ios::left)<<setw(10)<<akhir[i];
cout<<setiosflags(ios::left)<<setw(8)<<grade[i]<<endl;
}
cout<<"--------------------------------------------------------- "<<endl;
getch();
}

Variation 5:

C++ Calculating Student Grades Using Struct
C++ Calculating Student Grades Using Struct

Source Code:

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

/**
*bundet.com
*C++ Menghitung Nilai Mahasiswa Menggunakan Struct
*/

//deklarasi fungsi grade//
char*grade(int hasil)
{
if (hasil>=80)
return"A";
else
if(hasil>=70)
return"B";
else if (hasil>=56)
return"C";
else if (hasil>=47)
return"D";
else if (hasil<70)
return"E";
}
main()
{
//deklarasi structure//
struct
{
char nama[20],grade[2];
int uts,uas,hasil;
}data[5];

int i,j;
char x;
atas:
clrscr();
cout<<"\t DAFTAR NILAI MAHASISWA "<<endl;
cout<<"\t=============================="<<endl;
cout<<"\tMasukkan jumlah data : ";cin>>j;
cout<<endl;
for(i=1;i<=j;i++)
{
cout<<"data ke : "<<i<<endl;
cout<<"Nama : ";cin>>data[i].nama;
cout<<"Nilai Uts : ";cin>>data[i].uts;
cout<<"Nilai Uas : ";cin>>data[i].uas;
cout<<endl;
data[i].hasil=(data[i].uts*0.4)+(data[i].uas*0.6);
}
clrscr();
cout<<"\t DAFTAR NILAI MAHASISWA "<<endl;
cout<<"====================================="<<endl;
cout<<"No. Nama  Nilai Nilai Nilai Grade"<<endl;
cout<<"    Siswa Uts   Uas   Akhir "<<endl;
cout<<"====================================="<<endl;
for(i=1;i<=j;i++)
{
printf("%d %3s %5d %5d %6d %4s\n",i,data[i].nama,data[i].uts,data[i].uas,data[i].hasil,grade(data[i].hasil));
}
cout<<"====================================="<<endl;
printf("Apa ingin input lagi[Y/N] : ");
x=getche();
if(x=='y'||x=='Y')
goto atas;
else
goto keluar;
getch();
keluar:
}

Variations - ULTIMATE:

C++ Student Grade Program - Ultimate Version
C++ Student Grade Program - Ultimate Version

Source Code:

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

/**
*bundet.com
*Wawan Beneran
*C++ Program Nilai Mahasiswa - Ultimate
*/

void main()
{
int a,b,c,d,e;
float uts[50], tugas[50], uas[50];
int absen[50],G,H,I,J,K[50],L,M,N;
char f,mutu,nama[100];
awal:
clrscr();
cout<<"SELAMAT DATANG DI PROGRAM PENILAIAN MAHASISWA - VERSI ULTIMATE\n";
cout<<"===============================================================\n\n";
cout<<"Masukkan Standard Nilai Anda !!! (0-100%) \n";
cout<<"Masukkan Persentase Kehadiran : ";cin>>a;
cout<<"Masukkan Persentase TUGAS     : ";cin>>b;
cout<<"Masukkan Persentase UTS       : ";cin>>c;
cout<<"Masukkan Persentase UAS       : ";cin>>d;
e=a+b+c+d;

 if(e>100)
 {cout<<"Maaf,Standard Nilai Yang Anda Masukkan Lebih dari 100%\n";
 cout<<"Apakah Anda Ingin Mengulangi (Y/N) ??? ";cin>>f;
 if(f=='Y'||'y')
 goto awal;
 else exit;}
 {if (e<=100)
 cout<<"Standard Nilai Anda Sudah Mencapai "<<e<<" %"<<endl;}
cout<<"====================================================\n";
cout<<"Masukkan Total Pertemuan Dalam Satu Semester : ";cin>>L;
cout<<"====================================================\n";
cout<<"Masukkan Jumlah Mahasiswa yang Ingin Di Input : ";cin>>M;
cout<<endl;
cout<<"|====|===================|=======|=======|======|=====|=====|=======|\n";
cout<<"| No.|  Nama Mahasiswa   | Absen | Tugas | UTS  | UAS |  NA | Grade |\n";
cout<<"|====|===================|=======|=======|======|=====|=====|=======|\n";
for(N=1;N<=M;N++)
{
gotoxy(1,17+N);cout<<"|"<<N<<"   |"<<endl;
gotoxy(8,17+N);cin>>nama;cout<<endl;
gotoxy(28,17+N);cin>>absen[N];
gotoxy(36,17+N);cin>>tugas[N];
gotoxy(44,17+N);cin>>uts[N];
gotoxy(51,17+N);cin>>uas[N];

  G=(absen[N]/L)*a;
  H=(tugas[N]/100)*b;
  I=(uts[N]/100)*c;
  J=(uas[N]/100)*d;
  K[N]=G+H+I+J;
  {if(K[N]>=80)
  mutu='A';
  else if(K[N]>=67)
  mutu='B';
  else if(K[N]>=55)
  mutu='C';
  else if(K[N]>=45)
  mutu='D';
  else
 mutu='E';
 gotoxy(65,17+N);cout<<mutu<<"   |";}
gotoxy(57,17+N);cout<<K[N]<<endl;
}
cout<<"|====|===================|=======|=======|======|=====|=====|=======|\n";
getch();}

Hope this is useful & happy learning!

Netizens

Member Question 1

UNKNOWN May 27, 2016, 22:07:00 very helpful

ANONYMOUS Jun 20 2016, 09:55:00

| %-3s | %-4s | %-4i | %3i | %3i | %11f | %5c |\n

Excuse me sir, I want to ask what is the meaning of the statement above? from the meaning of %-3s, %-4s and so on thx b4

ANONYMOUS 20 Jun 2016, 14:16:00 what is the % for, bro?

ANONYMOUS 21 Jun 2016, 15:19:00 sorry sir, I want to ask again, why is fflush(stdin) only used for names and student IDs, does it not apply to integer data types?

DEFRYAN TRI GUSMAN12 Dec 2017, 09:41:00 What compiler do you use, bro?

KEVIN CHRISTE Apr 23, 2018, 09:31:00 How do I make it into pseudocode?

Our Response 1

thank goodness for that

All of these are default parameters of the printf function. The choice of arguments is embedded in the "format specifier" in the future we will review specifically for this problem, because there are so many choices of arguments.

  1. %-3s >> is a statement used to print a string, marked with a letter(s) with a minimum of 3 characters marked with a number(3), if the characters are less than 3 they will automatically be replaced with a "space", while the (-) sign is used to place the "space" at the end of the character, if the (-) sign is removed, then the "space" will be placed at the beginning of the character.
  2. %-4i >> is a statement used to print integers, marked (i) or (d), the rest of the concept is the same.
  3. %11f >> is a statement used to print float, marked (f), the rest is the same. Note!: for example, using precision behind the comma of 2 digits, then it is written as %11.2f but the number of characters remains at least 11 including the back comma, the dot is not included.
  4. %5c >> is a statement used to print a char, marked(c), the rest is the same.

That is indeed the rule, bro, for the specifier writing format it must start with %, thank you.

fflush(stdin) is a function available in the library  #include <stdio.h> used to clear the contents of a buffer. A buffer is a block of memory created to bridge the transfer of data before it is finally placed in the final destination memory.

In the example case above, the buffer is  mhs[i] the initialization of the array  struct(dibuat tipe array struct). Meanwhile, the final destination memory is the NIM and/or Name variables.

When the buffer is used for NIM input, it still contains the NIM value, so it is cleaned and used again for Name input. And vice versa, and so on.

Pointer (stdin) is a standard input stream used to take input data via the keyboard. Meanwhile, "Stream" is an abstraction that represents an input/output device (keyboard, monitor, mouse, console, etc.), by default it functions as a source or destination of "characters", therefore, the header must also include the library "iostream.h"

So it can be concluded that  fflush(stdin) it cannot be used for integer data types, even if you want to use that data type, you must first convert it using the "atoi" function.

Most of my references are taken from cplusplus.com. Please bro, maybe you want to deepen this material. That's all and thank you

Hi DEFRYAN TRI GUSMAN, using Borland C++

Member Question 2

So that the name can use spaces (for example, Elivia Crissia), how do you do it, bro?

Our Response 2

Hii elivia crissia, you can create separate name variables, such as "firstName" and "lastName", of course this is also balanced with the input method, if previously only once input full name, now create an input form for first & last name, the filling mechanism is alternate. Then just display it with the addition of a space string.

How do you make the index in multicharacter form? For example, what was originally "A" becomes "Very Good"?

Hi  YahyaRahul,  pay attention to your variable  mutu='A'; , just change its value to be  mutu='Sangat Baik'; the same as the value of other qualities if you want to change it to multi-character.


Post a Comment

Previous Next

نموذج الاتصال