Вы находитесь на странице: 1из 1

POO Handout – Lab 1

First Name: Andreea Raluca Last Name: Mazilu (Recuperare anul 3, grupa 1061, recuperat la 1033)

C++ Lab 1 – Data types & pointers

Learning goals: (1) hands-on experience using C++ in Visual Studio; (2) understand C++ types, expressions,
mathematical operators and variables.

Data types

Statement/Command Expected Value Printed Value Explain the difference


printf("\n Size: %d",sizeof(char)); 1 byte 1 byte

printf("\n Size: %d", sizeof(int)); 4 bytes 4 bytes

printf("\n Size: %d", sizeof(unsigned int)); 4 bytes 4 bytes

printf("\n Size: %d", sizeof(short int)); 2 bytes 2 bytes

printf("\n Size: %d", sizeof(float)); 4 bytes 4 bytes

printf("\n Size: %d", sizeof(double)); 8 bytes 8 bytes

char c = 'a'; Value=a Value=a


printf("\n Value = %c", c);
char c = 'a'; Value=97 Value=97 A in cod ASCII
printf("\n Value = %d", c);
char c = 'a'; Value=61 Value=61
printf("\n Value = %x", c);
short int value = 0x011A; Value=282 Value=282
printf("\n Value = %d", value);

Pointers

Statement/Command Expected Value Printed Value Explain the difference


int* pointer_int; Size=8 Size=8 Un pointer ocupa 8 bytes
printf("\n Size = %d", sizeof(pointer_int));
char* pointer_char; Size=8 Size=8 Un pointer ocupa 8 bytes
printf("\n Size = %d", sizeof(pointer_int));
printf("\n Size = %x", pointer_int); Size=8 Size=8 Un pointer ocupa 8 bytes

pointer_int = new int[10];


printf("\n Size = %d", sizeof(pointer_int));
int values[10]; Size=40 Size=40 10 x 4 bytes
printf("\n Size = %d", sizeof(values));
printf("\n %d",values[0]); 124

printf("\n %x", values[0]); 7c

printf("\n %x", values[9]); 7ffe

printf("\n %x", values[10]); 0


printf("\n %x", values[11]); 0
printf("\n %x", values[11000]); x