English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
2

1.what does VOID in "c" means??
2.If a Function is declared as void then why they have the
"return" statement??
3."int salary(void)" --> the meaning of this statement??
4. "void int salary" --> is this true,if yes then what does it mean??

2006-11-20 17:40:32 · 7 answers · asked by rohit k 3 in Computers & Internet Programming & Design

7 answers

1. void in C can be used in 2 ways, first to specify the return type of a function & second to specify the parameter list of a function
Now, if the function doesn't return any value then use "void" also if it doesn't take any parameter then use "void" for eg:
void displayHello(void)
{
printf("\n\t Hello");
}

2. if a function has void return type , even then it can use a return statement to stop the execution of the function & return the control back to that point from where this function was called.

3. int salary(void) is a function prototype or in simple words a function declaration, which means that the function "salary()" returns an "int" value & accepts zero/no parameters indicated by the "void" keyword.

4. void int salary is not true, it is an illegal statement, because u can't specify 2 datatypes at the same time i.e void int is not allowable.

2006-11-21 00:37:11 · answer #1 · answered by Anonymous · 0 0

1. void actually means an empty space. in it's meaning is no data type. there can be void functions, pointers etc. in c. void pointers can point any data type variable.
2. the function declared as void may or may not have the return statemen t. it basically depends upon the programmer.
3.it declares a function with no arguments and integer return value.
4. void int salary is an invalid statement.

2006-11-20 22:36:24 · answer #2 · answered by Kshitij 1 · 0 0

1. Void generally means "nothing" or "absence". It's commonly used to specify that a function has no arguments, or that it has no return value.
2. A function that is declared void means that it has no resulting value at the end of the function. The function can still stop its execution at any particular step by 'returning' - it just means it wont be returning any value.
3. That's declaring a function with a return type of an integer and no parameters.
4. That's not really valid syntax on its own.

I highly recommend picking up a copy of C for Dummies. It's an excellent book and I used it myself a very long time ago to learn.

2006-11-20 17:46:28 · answer #3 · answered by romdles 1 · 2 0

void means function does not return any value. It doesnt mean that there should not be any "return" statement.
When a "void" is given as a parameter then it means function does not take any parameter.
Its equivalent to,
int salary();

Your 4th statement is wrong. void and int should not occur next to each other. It doesnt make sense at all.
How can a function return int as well as a function wont return a value. Think in this manner.
I think this ll help u.
bye...

2006-11-22 04:21:29 · answer #4 · answered by Sudha P 2 · 0 0

answer to ur 2nd question:

void simply means that the fuction will not return anything. But in my experience I've got compilation errors using the return statement with in a function declared as void.

2006-11-21 02:52:06 · answer #5 · answered by deostroll 3 · 0 0

1. void means that there is nothing or empty in the sense.
It is called as "return type" technically.....ie it need not(may or may not) return a value.
2. we have a return statement in functions declared as void when
............a function must return a value or pass a value back to the main function .
for eg,........swapping of two numbers a and b
void main()
{
int a=5,b=10;
void swap(); //calling of swap function
printf("a=%d",a);
printf("b=%d",b);
}
void swap(int a,int b)
{
t=a;
a=b;
b=a;
return (a,b);
}

3. this statement is same as "int salary()"......it means that it is a function with return type as "int" and no argument.
the general syntax is
return_type function_name ( arguments)

4.this is not a valid syntax

2006-11-20 19:57:11 · answer #6 · answered by rose 1 · 0 2

VOID IN C MEANS IT DOES NOT RETURN ANYTHING

2006-11-20 18:36:02 · answer #7 · answered by sai 1 · 0 1

fedest.com, questions and answers