Answer to Question #286222 in C for Jessa

Question #286222

Create a simple C program and use a comment to identify the five basic structures of the c programming language.

1
Expert's answer
2022-01-10T00:24:43-0500

Documentation section: It is expected frm programmers to put comments in between the coding sections so as to understand and get the algorithm idea what the code is doing. A c-program allows to add or insert comments using (//) for single line commenting and (/* */) for multiple lines commenting. The commented lines are not compiled during program compilation.

Link section: Header files (library files) included at the top of the programs are linked using the linker section of C-compiler..

Definition section: #define directive is used tom define MACROS in C-program. MACROS are replaced as it is in the entire C-program..

Global declaration section: The variables that are required globally through out the C-program and various functions are called global variables. Each and every program and function can access these variables.

Local variable declaration: Variables that are declared inside the main function or a function has their scope within their respective function only.

Main function section: Any C-program has primarily two parts: decleration part and executable part. Decleration part consists of variable decleration and executrable part includes the instructions or logic implemented using looping instructions and other commands.

 

A simple C-program to get the sum of first 10 natural numbers is given below:

//Linker Section

# include<stdio.h>

#include<stdlib.h>

//Macros definition

#define N 10

//Main Part

int main()

{

         //Decleration

         int n,Sum=0;       

         //Executable Part

         for(n=0;n<+N;n++) Sum = Sum + n;

         printf("\n\tSum of first %d Natural Numbers = %d",N,Sum);

         return(0);

}








Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS