answersLogoWhite

0


Best Answer

The cin and cout entities (they are not statements) are C++ iostream library objects that allows access to "standard input" and "standard output". In C++, the statement cout << "Hello World!"; is similar to the C statement printf("Hello World!\n"); Similarly, cin >> variable; allows reading from standard input to a variable.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

To use these you must use:

#include <iostream>

then define a variable, doesn't matter what type, could be anything (int, char, char*) like so:

int a;

int b;

To get the values for these you must use cin:

cin >> a;

cin >> b;

The to output them once they have been allocated a value:

cout >> a;

cout >> b;

or you could do math with them such as:

cout << (((a+b)b)/a)b To use these you must use:

#include <iostream>

then define a variable, doesn't matter what type, could be anything (int, char, char*) like so:

int a;

int b;

To get the values for these you must use cin:

cin >> a;

cin >> b;

The to output them once they have been allocated a value:

cout >> a;

cout >> b;

or you could do math with them such as:

cout << (((a+b)b)/a)b

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Yes. In actual fact that is the only place you can use them, period.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can cin and cout be used in the function definition of user defined functions in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is function Explain the user define function with example?

Function is a logically grouped piece of code allowing perform certain types of operations. Function can return value (int, double etc) or be void type - meaning they do not return value. Functions allow to make code cleaner by moving out chunks of code of main body. For instance you want to write a function that finds area of rectangular. #include &lt;iostream&gt; using std cin; using std cout; using std endl; using std get; int main() { double sideA = 0.0; cout &lt;&lt; "Enter side a of rectagular: "; cin &gt;&gt; sideA; double sideB = 0.0; cout &lt;&lt; endl &lt;&lt; "Enter side b of rectangular: "; cin &gt;&gt; sideB; //This part passes sides a and b to user defined function "Square" cout &lt;&lt; endl &lt;&lt; "Area of rectangular is: " &lt;&lt; Square(a, b); cin.get(); return 0; } //definition of user defined function Square double Square(double a, double b) { return (a * b); }


How you can add a user define function in c library?

user defined functions r d functions whch user declare before the main functn in c program... for eg. double min( doub;le x,double y); int factorial( ,) int square(int) etc


What is namespace in c plus plus program?

A namespace is similar to a class in object oriented programming. A namespace contains functions defined by the programmer. for example namespace std contains functions like cout and cin.namespaces can be globaly declared like so: "using namespace std;"which includes all the functions located in the namespace std.if you only need to use cout you can globaly declare only cout like this "using std::cout;"orstd::cout


What are predefined codes?

Predefined codes or the predefined functions are the codes small or large codes which are predefined by the maker of the language. In C++ the predefined codes can be included in the program by the header files. These codes are placed in files and functions could be used to access them. Like a simple console Code to output "Hello World" uses a predefined code cout


What is a library function in C plus plus?

This are the predefined functions in c, which are already write.Examples : printf(),scanf().

Related questions

What is the definition of cout?

COUT is an inbuilt function in c++ language. Cout is used to print something on to the standard output.


What is function Explain the user define function with example?

Function is a logically grouped piece of code allowing perform certain types of operations. Function can return value (int, double etc) or be void type - meaning they do not return value. Functions allow to make code cleaner by moving out chunks of code of main body. For instance you want to write a function that finds area of rectangular. #include &lt;iostream&gt; using std cin; using std cout; using std endl; using std get; int main() { double sideA = 0.0; cout &lt;&lt; "Enter side a of rectagular: "; cin &gt;&gt; sideA; double sideB = 0.0; cout &lt;&lt; endl &lt;&lt; "Enter side b of rectangular: "; cin &gt;&gt; sideB; //This part passes sides a and b to user defined function "Square" cout &lt;&lt; endl &lt;&lt; "Area of rectangular is: " &lt;&lt; Square(a, b); cin.get(); return 0; } //definition of user defined function Square double Square(double a, double b) { return (a * b); }


How you can add a user define function in c library?

user defined functions r d functions whch user declare before the main functn in c program... for eg. double min( doub;le x,double y); int factorial( ,) int square(int) etc


Define functions in c?

type function_name (type1 arg,...){//function body}void finc(int arg0){cout


What is namespace in c plus plus program?

A namespace is similar to a class in object oriented programming. A namespace contains functions defined by the programmer. for example namespace std contains functions like cout and cin.namespaces can be globaly declared like so: "using namespace std;"which includes all the functions located in the namespace std.if you only need to use cout you can globaly declare only cout like this "using std::cout;"orstd::cout


What are predefined codes?

Predefined codes or the predefined functions are the codes small or large codes which are predefined by the maker of the language. In C++ the predefined codes can be included in the program by the header files. These codes are placed in files and functions could be used to access them. Like a simple console Code to output "Hello World" uses a predefined code cout


What is the function of the cin and cout statements?

cin and cout are synonymous with stdin and stdout, implementing console input and output respectively.


What is a library function in C plus plus?

This are the predefined functions in c, which are already write.Examples : printf(),scanf().


Is cout a function or object?

It's an object of the class ostream.


How do you use pow function in c?

Either you can use the pre defined function "pow" in the &lt;math.h&gt; header file OR you can make a user defined function to do the same operation. 1.Using the pre defined function in &lt;math.h&gt; : The function is a of datatype double and accepts only values in double. So, prototype declaration is: double pow(double x,double y); Pass the values to the function and it'll return the value of xy. In the calling function it can be declared as: double power=pow(x,y); 2.USER DEFINED FUNCTION: double power(double x,int y); int main() { double x,result; int y; cout&lt;&lt;"\nEnter the base: "&lt;&lt;; cin&gt;&gt;x; cout&lt;&lt;"\nEnter the exponential power: "; cin&gt;&gt;y; result=power(x,y); cout&lt;&lt;"The result of x to the power y is: "&lt;&lt;result; return 0; } double power(double x,int y) { for(int i=0;i&lt;=y;i++) { x*=x; } return x; }


What are C plus plus intrinsic functions?

Most functions are available from libraries, however some functions are built-in to the compiler itself. A built-in function is therefore an intrinsic function. Some intrinsics are only available as built-in functions while others also have standard function equivalents. You can choose to use some or all intrinsics either by using the #pragma compiler directive or via a compiler optimisation switch, such as /Oi in MSVC++, or indeed both. Intrinsic functions are typically inline expanded to eliminate the overhead of a function call, and some will also provide information back to the compiler in order to better optimise the emitted code. Intrinsics affect the portability of code but are generally more portable than inline assembler. Indeed, some architectures do not support inline assembler, thus intrinsics are nothing if not essential where optimal code is a requirement. Your compiler's documentation should provide a complete list of the intrinsic functions available for each platform it supports, along with the standard function equivalents.


How do you make a calculator using switch statement?

In C++: #include &lt;iostream&gt; using namespace std; int main() { int x, y; char func; cout &lt;&lt; "Enter a number: "; cin &gt;&gt; x; cout &lt;&lt; "Choose Function: "; cin &gt;&gt; func; cout &lt;&lt; "Enter another number: "; cin &gt;&gt; y; switch(func) { case '+': cout &lt;&lt; x + y &lt;&lt; endl; break; case '-': cout &lt;&lt; x - y &lt;&lt; endl; break; case '*': cout &lt;&lt; x * y &lt;&lt; endl; break; case '/': cout &lt;&lt; x / y &lt;&lt; endl; break; default: cout &lt;&lt; "Invalid Function!" &lt;&lt; endl; break; } char wait; cin &gt;&gt; wait; return 0; }