c++

0 Arira joseph · May 18, 2015
How do I cout a Cin value dat stop a particular program and assign that same value into a particular variable in another funtion

Post a Reply

Replies

Oldest  Newest  Rating
0 Sengngy Kouch · May 18, 2015
Man, as long as I use << in the code, I ignore my comment.

So here is the code that is missing.
=========================================


Note: I use ..........................

int num;
cout <.< "Please enter a number" <.<;  
cin >.> num;

cout <.< "Your number is" <.< num;

2. Now, make.......................................
0 Sengngy Kouch · May 18, 2015
Hi Arira, I am not about your question, but let me try to answer.


1. How do we print out an Input from a user?
2. Assign the Input to another function?

========================================
Answer:

1. you can use the following: 

Note: I use <.< because this site doesn't allow <<
int num;
cout

2. Now, make sure your particular function have a parameter that allow the value type you want to assign to.

void doSomething ( int num) // notice I have "int num" in the (). this is called parameter.
{
// do something here;
}

Note that your Input from user is INT, and if you want to another function to get that Input, that function need to have a parameter have accept INT as well. 

I hope this might help and answer your question.
  • 1

C++

107,018 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator