main


History


A Simple C Program


The Structure Of a C Program

Designed by:Dario Holgate

The Structure of a C program


Most C programs have a few common elements: Header files, variables, and functions.

Header files- Files used to include functions from the C standard library which will be used in a program. The extension for header files is ".h". The most common header file in the C language is called "stdio.h", meaning standard input/output. This header file contains functions for accepting input from a user and outputing information on screen. To make our programs print data to your computer's screen, we use the "printf()" function. To accept user input, we using the "scanf()" function.

Variables- An indentifier in a program that is used to store some type of information. Types of information you may want to store are integers, characters, or strings. To store any data, variables must be declared with their specific type before use.

Functions- The purpose of a function is to perform a specific task and/or return a value after performing its operations. To call a function, we specify the function's name followed by open and closed parenthesis, "()". Inside the parenthesis, we may include arguments; variables which allow the function to accept data.

Below is a sample showing these elements: