#include<stdio.h>
#include<conio.h>
void pass(int);
void main()
{
int a=23;
int c;
clrscr();
pass(a);
printf(" %d ",c);
getch();
}
void pass( i)
{
//int i;
if(i>40)
return 1;
else
return 0;
}
bhallarahul
-4
Light Poster
Recommended Answers
Jump to PostThat depends on what arun means.
Jump to PostI think "arun" means invoke undefined behavior. Because that's what the program does.
Jump to Postfirst, the declaration and definition of the function anthet should match.
#include<stdio.h> #include<conio.h> void pass(int); void main() { int a=23; int c; clrscr(); pass(a); printf(" %d ",c); getch(); } void pass( i) { //int i; if(i>40) return 1; else return 0; }
Jump to Post1. change the definition of function pass to
int pass(int i); //- first int specifies the return type
return type cannot be void since you return 1 or return 0;
in the declaration of the function copy the definition, that is to say
Jump to PostI want to how and why given program run?
Why don't you keep reading the standard? It has the answers:
A return statement with an expression shall not appear in a function whose return type is void.
Violation of a "shall" constraint invokes undefined behavior, which is defined as:
behavior, …
All 17 Replies
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Narue
5,707
Bad Cop
Team Colleague
Kiss_and
0
Newbie Poster
bhallarahul
-4
Light Poster
Narue
commented:
That's obvious.
-4
Kiss_and
0
Newbie Poster
\007
7
Junior Poster in Training
bhallarahul
-4
Light Poster
bhallarahul
-4
Light Poster
Kiss_and
0
Newbie Poster
\007
7
Junior Poster in Training
bhallarahul
-4
Light Poster
Narue
5,707
Bad Cop
Team Colleague
\007
7
Junior Poster in Training
bajishareef
-7
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
bhallarahul
-4
Light Poster
Narue
5,707
Bad Cop
Team Colleague
Salem
commented:
Well said
+17
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.