What will be the output of the following C program?
#include <stdio.h> int main() { int f1(int,int); int x = 9,n = 3; printf("%d", f1(x, n)); } int f1(int x, int n) { int y = 1,i = 1; for(i = 1;i <= n; i++) y = y * x; return(y); }
x = 9, n = 3; int f1(int x, int n) { int y = 1,i = 1; for(i = 1;i <= n; i++) y = y * x; return(y); } i = 1, y = 1, x = 9, n = 3, y = 1*9 = 9 i = 2, y = 9, x = 9, n = 3, y = 9*9 = 81 i = 3, y = 81, x = 9, n = 3, y = 81*9 = 729 return (y) i.e. 729
@air1 I first declare the function inside the main function. Then after some code. I define that function inside the main function. I got this error: "error: a function-definition is not allowed here before '{' token {"
function declaration inside main().
http://qa.geeksforgeeks.org/2839/qa.geeksforgeeks.org/2839/declaration-of-a-function-inside-main.html
64.3k questions
77.9k answers
244k comments
80.0k users