You are on page 1of 6

NO Exercise Keterangan Tugas

1
#include <iostream>
using namespace std;

int main() {

cout << "Hello World!";


return 0;
}

Excerscise 1 (C++ Syntax)

No Excercise Keterangan Tugas


2 #include <iostream>
using namespace std;

int main() {
cout << "Hello World! \n";
cout << "I am learning C++";
return 0;
}
No Excersise Keterangqan Tugas
3 //This is a single-line
comment
/*This is a multi-line
comment */

#include <iostream>
using namespace std;

int main() {
/* The code below will
print the words Hello
World!
to the screen, and it is
amazing */
cout << "Hello World!";
return 0;
}

Exercise 2 (C++Variable)

No Exercise Keterangan Tugas


1 Int myNum= 50;

#include <iostream>
using namespace std;

int main() {
int myNum = 50 ;
cout << myNum ;
}

2 int x 5
= ;
int y = 10;
cout << x + y;
#include <iostream>
using namespace std;

int main() {

int x = 5;
int y = 10;
cout << x + y;
}

3.
int x = 5;
int y = 10;
int z = x + y;
cout << z;

#include <iostream>
using namespace std;

int main() {
int x = 5;
int y = 10;
int z = x + y;
cout << z;
}
4.
int main() {

int x = 5,y = 6,z = 50;


cout << x + y + z;

#include <iostream>
using namespace std;

int main() {
int x = 5,y = 6,z = 50;
cout << x + y + z;
}

C++ User Input

N Exercise Keterangan Tugas


o
1 int x;
cout << "Type a number:";
cin >> x;

#include <iostream>
using namespace std;

int main() {

int x;
cout << "Type a number: ";
cin >> x ;
}
2. int x, y;
int sum;
cout << "Type a number: ";
cin>> x;
cout << "Type another number: ";
cin >> y;
sum = x + y;
cout << "Sum is: " << sum;
#include <iostream>
using namespace std;

int main() {
int x, y;
int sum;
cout << "Type a number: ";
cin>> x;
cout << "Type another number: ";
cin >> y;
sum = x + y;
cout << "Sum is: " << sum;
}
C++ DATA TYPES

No Excercise Keterangan Tugas


1 int myNum = 9;
double myDoubleNum = 8.99;
char myLetter = 'A';
bool myBool = false;
string myText = "Hello World";

#include <iostream>
using namespace std;

int main() {
int myNum = 9;
double myDoubleNum = 8.99;
char myLetter = 'A';
bool myBool = false;
string myText = "Hello World";
}

2. Bool yay = true;


Bool nay = false;

#include <iostream>
using namespace std;

int main() {
bool yay = true;
bool nay = false;
cout << yay << "\n";
cout << nay ;
return 0;
}

3 String greeting= "Hello";


cout << greeting;
#include <iostream>
using namespace std;

int main() {

string greeting= "Hello";


cout << greeting;
}

You might also like