Home > Blockchain >  Function not giving normal output
Function not giving normal output

Time:03-10

Im a beiginer in c language , and trying too compile my practice on functions,i tied many times to compile this and i bumped into this issue : here below is my code:

#include <stdio.h>
int displayFlow();
int main(){
    int displayFlow();
   
}
int displayFlow(){

int try1,try2,try3;
printf("enter any given number...\n");
scanf("%d", &try1);
printf("if u entered above 10, ur out\n...please enter another guess...\n");
scanf("%d", &try2);
printf("if u entered below 5 then u won! !");


}

and this is the output i got:

function.c:22:5: note: declared here
 int test(){

please help me fix it. thanks in advanced.

CodePudding user response:

You declared your function again inside main. Remove int from infront of displayFlow.

#include <stdio.h>
int displayFlow();
int main(){
    displayFlow();

}
int displayFlow(){

int try1,try2,try3;
printf("enter any given number...\n");
scanf("%d", &try1);
printf("if u entered above 10, ur out\n...please enter another guess...\n");
scanf("%d", &try2);
printf("if u entered below 5 then u won! !");


}

CodePudding user response:

just set return in method main bcuz he has to return int

int main(){
return displayFlow();

}
  • Related