CS235 Introduction

Hello World

#include <iostream>

int main(){
	std::cout << "Hello world!" << std::endl;
}

You can also do this, but don't do it:

#include <iostream>

using namespace std;

int main(){
	cout << "Hello world!" << endl;
}

Do this instead;

#include <iostream>

using std::cout;
using std::endl;

int main(){
	cout << "Hello world!" << endl;
}

Printing Numbers

#include <iostream>
using std::cout, std:: endl, std::cin;

int main(){
	int a;
	int b;
	cout << "Enter a single number: ";
	cin >> a;
	cout << "Enter another number";
	cin >> b;
	cout << "The sum of " << a << " + " << b << " is " << a + b << endl;
}