Search Header Logo
C++ User Input

C++ User Input

Assessment

Presentation

Computers

University

Hard

Created by

Kittisay SENGTHONG

FREE Resource

5 Slides • 5 Questions

1

C++ User Input

ຄຳສັ່ງຮັບຂໍ້ມູນຈາກແປ້ນພິມ

Slide image

2

C++ User Input

You have already learned that cout is used to output (print) values. Now we will use cin to get user input.


cin is a predefined variable that reads data from the keyboard with the extraction operator (>>).


In the following example, the user can input a number, which is stored in the variable x. Then we print the value of x:

3

Fill in the Blank

ຈົ່ງຂຽນຄຳສັ່ງຮັບຂໍ້ມູນຈາກແປ້ນພິມຂອງພາສາ C++

4

Example

C++ User Input

Slide image

5

Good To Know

  • cout is pronounced "see-out". Used for output, and uses the insertion operator (<<)

  • cin is pronounced "see-in". Used for input, and uses the extraction operator (>>)

6

Fill in the Blank

ຈົ່ງຂຽນຄຳສັ່ງສະແດງຜົນ output ຂອງພາສາ C++

7

Fill in the Blank

ຈົ່ງຂຽນ operator (ຕົວນຳເນີນການ) output ຂອງພາສາ C++

8

Fill in the Blank

ຈົ່ງຂຽນ operator (ຕົວນຳເນີນການ) input ຂອງພາສາ C++

9

Creating a Simple Calculator

In this example, the user must input two numbers. Then we print the sum by calculating (adding) the two numbers:

Slide image

10

Poll

ໃຫ້ຄະແນນຄວາມຍາກຂອງຫົວຂໍ້ User Input

ງ່າຍ

ທຳມະດາ

ຍາກ

ຍາກຫຼາຍ

C++ User Input

ຄຳສັ່ງຮັບຂໍ້ມູນຈາກແປ້ນພິມ

Slide image

Show answer

Auto Play

Slide 1 / 10

SLIDE