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
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 1 of 4.
Klp; said:
1 decade ago
Why 0 is there beside return ?
Balasubramanian.p said:
1 decade ago
What is return function? how to understant that easily?
Sundar said:
1 decade ago
@Klp
The return 0 in the main function transfers the control back to OS (DOS), and denotes that program exits successfully.
It may return 0 for successful completion, -1 to denote error occurred.
From your c program you can call another c program.
Example:
system("mypro.exe") - This function will return 0 on successful completion and -1 on error situation.
The return 0 in the main function transfers the control back to OS (DOS), and denotes that program exits successfully.
It may return 0 for successful completion, -1 to denote error occurred.
From your c program you can call another c program.
Example:
system("mypro.exe") - This function will return 0 on successful completion and -1 on error situation.
Sujatha said:
1 decade ago
What is prototype? Explain in detail please.
Vishal said:
1 decade ago
If any declearation is not persent in the original pattern then prototype error will occur.
Ex: If you type only print in turboc then it will show you print is a prototype or not specified the header file then also it will come such as if you use getch() without use of the #include<conio.h> header file (in turboc) then it will come getch() is a prototype.
Ex: If you type only print in turboc then it will show you print is a prototype or not specified the header file then also it will come such as if you use getch() without use of the #include<conio.h> header file (in turboc) then it will come getch() is a prototype.
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.
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();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a=1;
printf("\n %d %d %d",a,a++,++a);
getch();
}
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
a=1
a++=1 //it increment the value after execute the exp
++a=3 //it increment the value before execute the exp
Kruthi said:
1 decade ago
How goto works?
Vasavi said:
1 decade ago
Goto leads to an unconditional jump in the execution flow of a program's code.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers