Last active
August 26, 2019 20:51
-
-
Save TanmayChakrabarty/05491fb3ffb912bd561a17db6d027f8c to your computer and use it in GitHub Desktop.
Explain the Basic Structure of a C Program with an Example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Name: Sample Program | |
* Author: OnlineClassNotes.COM | |
* Create Date: 26/11/2016 | |
* Last Modified: 27/11/2016 | |
* Tested at https://www.onlinegdb.com/online_c++_compiler using Language: C | |
*/ | |
//Linking required library | |
#include <stdio.h> | |
//defining a constant | |
#define MAX_ARRAY_LENGTH 20 | |
//defining a global variable | |
int max_input_length = 15; | |
//declaring an user defined function which has been defined later | |
float addNumbers(float a, float b); | |
int main(){ | |
//declaring a local variable for main() | |
int localVariable = 50; | |
//Accessing a defined constant | |
printf("Max array length is %d\n", MAX_ARRAY_LENGTH); | |
//Accessing a global variable | |
printf("Max input length is %d\n", max_input_length); | |
//Accessing an user defined function, declared in gloabl declaration section | |
printf("Summation of 5.5 and 8.3 = %f\n",addNumbers(5.5,8.3)); | |
return 0; | |
} | |
//defining an user defined function which has been declared earlier. | |
float addNumbers(float a, float b){ | |
return (a+b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read the blog post on this at
https://www.onlineclassnotes.com/2016/11/explain-basic-structure-of-c-program-with-an-example.html