Contoh Kode Program C++
==========================================
1. Hello World
==========================================
#include <iostream>
int main (){
std::cout <<"hello world"<<std::endl;
std::cin.get();
return 0;
}
=============================================
2. Penjumlahan
=============================================
#include <iostream>
using namespace std;
int main(){
int a, b, c;
cout << "Inputkan nilai a: ";
cin >> a;
cout << "Inputkan nilai b: ";
cin >> b;
c = a + b;
cout << "Hasil a + b = " << c << endl;
return 0;
}
=============================================
3. Kode Pertanyaan
=============================================
#include <iostream>
#include <string>
int main()
{
std::string name;
std::cout << "What is your name? ";
getline (std::cin, name);
std::cout << "Hello, " << name << "!\n";
}
====================================================
1 Comments
Oke pak makasih ini razan
ReplyDelete