Skip to content

Instantly share code, notes, and snippets.

@TanmayChakrabarty
Last active August 26, 2019 20:51
Show Gist options
  • Save TanmayChakrabarty/05491fb3ffb912bd561a17db6d027f8c to your computer and use it in GitHub Desktop.
Save TanmayChakrabarty/05491fb3ffb912bd561a17db6d027f8c to your computer and use it in GitHub Desktop.
Explain the Basic Structure of a C Program with an Example.
/*
* 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);
}
@TanmayChakrabarty
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment