answersLogoWhite

0

void is used by functions that do not return a value. For example:

// This function returns an integer, which you can use in other functions

int addTwoNumbers(int a, int b)

{

return(a + b);

}

// This function does not return a value, so we declare it as a void

void printSum(int a, int b)

{

cout << a << " + " << b << " = " << addTwoNumbers(a, b) << endl;

// Note that attempting to return a value here will cause an error.

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How does the use of the 'void' keyword differ in C plus plus vs. C?

It doesn't. Void has the same meaning in both.


Difference between void and devoid in c plus plus?

There is no such thing as devoid in C++.


Purpose of void database in c plus plus?

There is no such term in C++. You probably meant void datatype. Void simply means "no type" and is primarily used as a place-holder for functions that do not return a value, since all functions must return something even when they return nothing at all. Not to be confused with void* which is a pointer to any type which, if non-null, must be cast to the correct type before being dereferenced.


What use of void data type in c plus plus?

doesn't return the value.


What is meant by println in c plus plus?

println is not a C++ keyword.


Which Program that will run in C but not in C plus plus?

void main() { int *x = malloc(sizeof(int) * 10); }


C plus plus program that will count?

#include int main (void) { puts ("1 2 3"); }


How do you use call by reference in c plus plus?

Call by reference means calling a function using a reference to a variable or a pointer. You call a function by passing refrences to a variable. For eg: void x(int &amp;a) { a=2; } void main() { int s=3; x(s); } OR void a(int &amp;c) { c=5;}void main(){ int *p; *p=2a(*p);}


What is CPU usage small programm c plus plus?

Example: int main (void) { LOOP: goto LOOP; }


How do you check Address of integer in c plus plus?

void myfun (int *pi){if (i==NULL) printf ("check failed");}


Show the simple c plus plus program?

int main (void) { puts ("Hello, world"); return 0; }


How do you rectify the waring is function should return a value in turbo c plus plus?

By returning a value. Or using type 'void'.