C Programming Basics
1.
C PROGRAMMING BASICS TO WRITE A C PROGRAM:
Below
are few commands and syntax used in C programming to write a simple C program.
Let’s see all the sections of a simple C program line by line.
|
C Basic commands |
Explanation |
|
#include <stdio.h> |
This is a preprocessor command that includes
standard input output header file(stdio.h) from the C library before
compiling a C program |
|
int main() |
This is the main function from where execution of
any C program begins. |
|
{ |
This indicates the beginning of the main function. |
|
/*_some_comments_*/ |
whatever is given inside the command
“/* */” in any C program, won’t be considered for compilation and
execution. |
|
printf(“Hello_World!“); |
printf command prints the output onto the screen. |
|
getch(); |
This command waits for any character input from
keyboard. |
|
return 0; |
This command
terminates C program (main function) and returns 0. |
|
} |
This indicates
the end of the main function. |
2.
A SIMPLE C PROGRAM:
Below C
program is a very simple and basic program in C programming language. This C
program displays “Hello World!” in the output window. And, all syntax and
commands in C programming are case sensitive. Also, each statement should be
ended with semicolon (;) which is a statement terminator.
#include <stdio.h>
int main()
{
/* Our first
simple C basic program */
printf("Hello
World! ");
getch();
return 0;
}
Output
Hello World!
3. STEPS TO WRITE C PROGRAMS AND GET THE OUTPUT:
Below are the steps to be followed for any C
program to create and get the output. This is common to all C program and there
is no exception whether its a very small C program or very large C program.
1.
Create
2.
Compile
3.
Execute or Run
4.
Get the Output
4.
CREATION, COMPILATION AND EXECUTION OF A C PROGRAM:
Prerequisite:
·
If
you want to create, compile and execute C programs by your own, you have
to install C compiler in your machine. Then, you can start to execute your own
C programs in your machine.
·
You can
refer below link for how to install C compiler and compile and execute C
programs in your machine.
· Once C compiler is installed in your machine, you can create, compile and execute C programs.
· If you don’t want to install C/C++ compilers in your machine, you can refer online compilers which will compile and execute C/C++ and many other programming languages online and display outputs on the screen
Comments
Post a Comment