392 views
0 votes
0 votes

CASE A:
 

CASE A:
 ‪#‎include‬<stdio.h> 
int divide( int a, b) 
{ return 7; }
 int main() { 
int a=divide(8,3); 
printf("%d",a);
 return 0; 
} 

CASE B :

CASE B :
 #include<stdio.h> 
int divide( a, b) 
{ return 7; 
}
 int main() 
{ int a=divide(8,3);
 printf("%d",a); 
return 0; } 

why is CASE A an error and CASE B error free , in CASE B acc to c99 standard it assumes the variables to be of type int but then why not in case A , why is the type of b not considered to be of type int ?


why is CASE A an error and CASE B error free , 

in CASE B acc to c99 standard it assumes the variables to be of type int but then why not in case A , why is the type of b not considered to be of type int ?

1 Answer

0 votes
0 votes

One of the major changes in C99 standard is the removal of implicit 'int' and 'implicit function declaration'. 

Ref: http://stackoverflow.com/questions/8220463/c-function-calls-understanding-the-implicit-int-rule

Try compiling your code with two standards as follows


gcc -Wall -std=c99 code.c
gcc -Wall -std=c89 code.c

I could not get the exact rule for implicit int, but the following isn't the place where 'implicit' works as clear from the error. Why worry about some stuff outdated in 1999? Currently we have to write declaration for all identifiers in C. 

int divide( int a, b) 

Related questions

0 votes
0 votes
1 answer
1
1 votes
1 votes
1 answer
2
radha gogia asked Jul 29, 2015
644 views
#include<stdio.h int main(){ int test=0; float a = 3424.34; printf("hello \n %d",(test? a: 3)); return 0; }It is giving output as hello 0 ,I am unable to understand the l...
2 votes
2 votes
3 answers
3
Laahithyaa VS asked Sep 9, 2023
892 views
. What will be the value returned by the following function, when it is called with 11?recur (int num){if ((num / 2)! = 0 ) return (recur (num/2) *10+num%2);else return 1...
1 votes
1 votes
2 answers
4
shekhar chauhan asked Jun 5, 2016
979 views
Either L attribute or S attributed .What kind of SDT it is ?S ->E# Out('#')E - E+E Out('+')E ->TT - T#F Out('*)T - FF - (E)F - a Out ('a')For the sentence...