
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What Happens When a Function is Called Before Its Declaration in C
If we do not use some function prototypes, and the function body is declared in some section which is present after the calling statement of that function. In such a case, the compiler thinks that the default return type is an integer. But if the function returns some other type of value, it returns an error. If the return type is also an integer, then it will work fine, sometimes this may generate some warnings.
Example Code
#include<stdio.h> main() { printf("The returned value: %d
", function); } char function() { return 'T'; //return T as character }
Output
[Error] conflicting types for 'function' [Note] previous implicit declaration of 'function' was here
Now if the return type is an integer, then it will work.
Example Code
#include<stdio.h> main() { printf("The returned value: %d
", function()); } int function() { return 86; //return an integer value }
Output
The returned value: 86
Advertisements