Basic Structure of C Program

Basic Structure of C Program

Here you will learn the basic structure of c program with example code.

Explain Basic Structure of C program

If you want to learn C programing and want to know about the Basic structure of C Program, then you are at the right place. Read the full article and get the basic knowledge of c programming.

 

Basic structure of c program with example

 

 

What is C programming?

C programming is a structured programming language, that is widely used today. Dennis Ritchie was developed it in the early 1970s. C programming is a powerful and versatile language that can be used for a wide variety of applications.  

Its design allows C to accurately show CPU’s based on the target processor. This technology is being found lasting in software, device drivers and protocol stacks, but decreases significantly in applications.

C is commonly used for computing architecture that combines the biggest supercomputer and microcomputers. The C language was developed by Ritchie in Bell Lab’s Bell Labs from 1972 until 1973 for building utilities for Linux.

 

 

Structure of c program with example

Let’s break down this structure so that we can understand it better.

  • The first line, #include <stdio.h>, is called a preprocessor directive. This directive tells the preprocessor to include the contents of the stdio.h header file in the program. The stdio.h header file contains the declarations of the standard input/output library functions.
  • Next, we have the main() function. This is the entry point of every C program. All the code in a C program is written inside the main() function.

 

Sample Program in C

 

 

Explanation of C program

// My first program in C

For Commenting a line can be done in C programs by adding the “//” (double slash) in front of line.

for exam.

// My first program

Note:- For commenting multi-line in c programming use

 /* in front of line and at last use /*

for exam.

/*This is my first  program in C programming

This is my first program in c

Here i am using turbo c compiler */

#include<stdio.h> 

This is header file exists in includes library. It allows you to use functions that are declared in it. For example we are using printf in this program and stdio.h header file contains it’s declaration. 

int main() 

main() is the system declared function. It is the first function that tells to the compiler to execute your program. Program’s execution starts from here. 

int is a return type of the function, which returns an integer value after the execution of the program to the operating system. 

 {..}

{ and }, these two braces are the starting and ending braces of the function region, these defines the block of a function. 

printf(“Welcome to the C programming”); 

printf is a library function that is used to display formatted output on screen. It is declared in stdio.h 

return 0; 

return 0 means that the function in which it is written doesn’t return any value.

 

 

How to run C program?

● Open the Turbo C++ Compiler( If you haven’t it, download it from the internet).

Click of file menu, open new file.

Type the program and save it with the .c extension.  

Press Ctrl + F9 to compile and Run the program.  

If there any errors occur, check the errors and recompile(Ctrl+F9) the program.  

If there are no errors, then the output will appear on the screen.

If you want to view output screen again, Then press Alt + F5

 

 

Conclusion

Here we understood that how to run first program in c programming and, the basic structure of first c program with explanation.

 

 

Check out our  C programming Examples

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top