Winter 2020

PIC 10A: Introduction to Programming

Discussion Section 3A

Wonjun Lee



Week1

Tuesday

Creating a new project

Thursday

HelloWorld.cpp
#include < iostream >
using namespace std;

int main()
{
	cout<<"hello world"<< endl;
	return 0;
}
    	
Sizes of variables
#include < iostream >

using namespace std;

int main()
{
    cout << "int size = " << sizeof(int)<< endl;
    return 0;
}
	

Problem

Print out the size of short, long, char, float, double, bool


Solution

/*

	short, long, char, float, double, bool

*/

#include < iostream >

using namespace std;

int main()
{
	cout << "the size of int is " << sizeof(int) << endl;
	cout << "the size of short is " << sizeof(short) << endl;
	cout << "the size of long is " << sizeof(long) << endl;
	cout << "the size of char is " << sizeof(char) << endl;
	cout << "the size of float is " << sizeof(float) << endl;
	cout << "the size of double is " << sizeof(double) << endl;
	cout << "the size of bool is " << sizeof(bool) << endl;	
	return 0;
}