

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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\n", 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\n", function()); } int function() { return 86; //return an integer value }
Output
The returned value: 86
- Related Questions & Answers
- What happens when a virtual function is called inside a non-virtual function in C++
- When is copy constructor called in C++?
- When are Constructors Called in C++?
- What happens when we type a URL?
- When can I use a forward declaration C/C++?
- When can I use a forward declaration in C/C++?
- What happens when a String is accepted or rejected by NPDA?
- What Happens When You Quit Smoking?
- What happens when you download a Fake App?
- What happens when more restrictive access is given to a derived class method in C++
- What happens when JDialog is set with Modality type APPLICATION_MODAL
- What happens when a negative value is inserted to UNSIGNED column in MySQL?
- What happens when a subclass object is assigned to a superclass object in Java?
- What happens when you control your mind?
- What happens when serum calcium level drops?
Advertisements