Try Yourself:
[Link] strings
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
[Link] string
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
cout << "I am learning C++";
return 0;
}
[Link] of two numbers:
#include <iostream>
using namespace std;
int main() {
int x = 5;
int y = 6;
int sum = x + y;
cout << sum;
return 0;
}
#include <iostream>
using namespace std;
int main() {
int x = 5, y = 6, z = 50;
cout << x + y + z;
return 0;
}
#include <iostream>
using namespace std;
int main() {
int first_number, second_number, sum;
cout << "Enter two integers: ";
cin >> first_number >> second_number;
// sum of two numbers in stored in variable sumOfTwoNumbers
sum = first_number + second_number;
// prints sum
cout << first_number << " + " << second_number << " = " << sum;
return 0;
}
include <iostream>
using namespace std;
// declaring a function
void greet() {
cout << "Hello there!";
}
int main() {
// calling the function
greet();
return 0;
}