Tugas pertama di perkuliah kedua dalam matakuliah Algoritma dan pemrograman 1, yaitu program harus memiliki tipe data sebagai berikut:
- Int
- Float
- Char
- Sting
Source code
//Preprocessor directive #include <iostream> using namespace std; main(){ //Deklarasi variabel int semester,nim; float ipk; char NilaiHuruf; string nama; //Judul program cout<<"================================"<<endl; cout<<" "<<endl; cout<<" Input Data Mahasiswa "<<endl; cout<<" "<<endl; cout<<"================================"<<endl; //Input data cout<<"Nama Anda : ";cin>>nama; cout<<"NIM : ";cin>>nim; cout<<"Semester : ";cin>>semester; cout<<"IPK : ";cin>>ipk; cout<<"Rata-rata Nilai Huruf: ";cin>>NilaiHuruf; //menambah baris baru cout<<endl<<endl; //Output data cout<<"------------Data Anda-----------"<<endl; cout<<"Nama Anda : ";cout<<nama<<endl; cout<<"NIM : ";cout<<nim<<endl; cout<<"Semester : ";cout<<semester<<endl; cout<<"IPK : ";cout<<ipk<<endl; cout<<"Rata-rata Nilai Huruf: ";cout<<NilaiHuruf<<endl; cout<<"--------------------------------"<<endl; }