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 2 of 4.

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

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

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

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

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

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

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();

}

Vinny said:   1 decade ago
What is difference between goto, return, go back and switch?

Raji said:   1 decade ago
printf function can be used for print the statement and return keyword can be used for return the routine from called function to calling function declaration.

Vignesh said:   1 decade ago
Function prototyping is nothing but we are declaring that we have a function in a specific name to the compiler.

Keerthana said:   1 decade ago
What is notation?

Shiva kumar kella said:   1 decade ago
@Ritika.
Answer is 1 and 1 and 3.

Explanation is :
Here is we have a command on post and pre increments.
Post increment :

1. First print the given number, and
2. Now increment itself by 1.

Pre increment :

1. First increment it self by 1, and
2. Now it's print what it have.

So ans ;1.a=1=> printed 1;

a++ => here printed 1 and incremented it self by 1 i.e. a=2;

++a => printed 3, because before a printing a will incremented by 1 ;


Post your comments here:

Your comments will be displayed after verification.