0% found this document useful (0 votes)
642 views2 pages

CODE: CPP - Assignment01.Opt1: Assignment Topic Assignment Duration

The document provides instructions for a coding assignment on variables and data types in C++. It includes 3 exercises: 1) declaring and assigning values to different variable types, 2) adding the correct data types to variable declarations, and 3) writing a program to output a name, age, and score to the console on separate lines. The duration of the assignment is 180 minutes.

Uploaded by

đạt tiêu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
642 views2 pages

CODE: CPP - Assignment01.Opt1: Assignment Topic Assignment Duration

The document provides instructions for a coding assignment on variables and data types in C++. It includes 3 exercises: 1) declaring and assigning values to different variable types, 2) adding the correct data types to variable declarations, and 3) writing a program to output a name, age, and score to the console on separate lines. The duration of the assignment is 180 minutes.

Uploaded by

đạt tiêu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CODE: CPP.Assignment01.

Opt1 FRESHER
Assignment topic : Variables and Data Types
ACADEMY
Assignment duration : 180 minutes

Bài 1: Thực hiện các bước sau:

- Create a variable named myNum and assign the value 50 to it

int myNum = 50;

- Create a variable named myNum1, assign the value 19 to it and add it to MyNum

int myNum1 =19;

int MyNum;

MyNum += myNum1;

- Create two variables named numX and numY, assign the value X to it and add it to MyNum such
that MyNum equal to maximum range of Short Int and assign the value Y to it and add it to
MyNum1 such that MyNum1 equal to minimum range of Short Int. Find X, Y

int numX,numY,sumXY;

short int MyNum,MyNum1;

numX=numY=X;

sumXY = numX+numY;

MyNum += sumXY;

MyNum = Y;

MyNum1 += MyNum;

Bài 2: Add the correct data type for the following variables:

_int__ myNum = 1;

_short__ myNum1 = 10001;

__long_ myNum2 = 100000001;

_unsigned long__ myNum3 = 10000000000001;

_long long__ myNum4 = -10000000000001;

_double__ myDoubleNum = 1.001;


_long double__ myDoubleNum1 = 100000000000001.100001;

_long double__ myDoubleNum2 = -1000000001.100001;

_char__ myLetter = 'A';

_string__ myLetter1 = "c";

_string__ myText = "Hello World";

_bool__ myBool = false;

Bài 3: Tạo file Exercise.cpp: Viết chương trình in ra màn hình console tên, tuổi, điểm tổng kết (float,
double) của bản thân trên mỗi dòng riêng biệt.

#include <iostream>

#include <string>

using namespace std;

string yourname;

int main(){

yourname = "Tieu Van Dat";

int age;

age=12;

float point;

point = 1.74;

cout<<"Ten cua ban: "<<yourname<<endl;

cout <<"Tuoi: " << age <<endl ;

cout<<"Diem: "<< point <<endl;

return 0;

}}

You might also like