C Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 1)
1.
The keyword used to transfer control from a function back to the calling function is
switch
goto
go back
return
Answer: Option
Explanation:

The keyword return is used to transfer control from a function back to the calling function.

Example:


#include<stdio.h>
int add(int, int); /* Function prototype */

int main()
{
    int a = 4, b = 3, c;
    c = add(a, b);
    printf("c = %d\n", c);
    return 0;
}
int add(int a, int b)
{
/* returns the value and control back to main() function */
   return (a+b);
}

Output:
c = 7

Discussion:
35 comments Page 3 of 4.

Mahesh said:   1 decade ago
I think the answer is also may be relating to functions..
and finally what is the out put;
main(){
printf("Mahesh @ SVM");
main();

}

R@M said:   1 decade ago
Relation between main function and called function is called "PROTOTYPE".

EX:- int add(int, int); /* Function prototype */

Robot said:   1 decade ago
Tell me the difference between printf (predefined function) and return (keyword).

Tarun said:   1 decade ago
We cannot write two arguments in the return statements

ex:
return(x,y);
it will take only 3

Mahesh Kharvi said:   1 decade ago
0 is beside return because the function is integer type it should return integer value.

Vasavi said:   1 decade ago
Goto leads to an unconditional jump in the execution flow of a program's code.

Kruthi said:   1 decade ago
How goto works?

Santhosh kumar said:   1 decade ago
@Rathika
a=1
a++=1 //it increment the value after execute the exp
++a=3 //it increment the value before execute the exp

Rathika.b said:   1 decade ago
Please say what is the output of this program?

#include<stdio.h>
#include<conio.h>
void main()
{
int a=1;
printf("\n %d %d %d",a,a++,++a);
getch();
}

Devdas said:   1 decade ago
In simple way, return is a c-keyword used to transfer the control from called function to calling function. It can also use for return a single value.


Post your comments here:

Your comments will be displayed after verification.