We assume you are well aware of English Language, which is a well-known Human Interface Language. English has a predefined grammar, which needs to be followed to write English statements in a correct way. Likewise, most of the Human Interface Languages (Hindi, English, Spanish, French, etc.) are made of several elements like verbs, nouns, adjectives, adverbs, propositions, and conjunctions, etc.
Similar to Human Interface Languages, Computer Programming Languages are also made of several elements. We will take you through the basics of those elements and make you comfortable to use them in various programming languages. These basic elements include −
- Programming Environment
- Basic Syntax
- Data Types
- Variables
- Keywords
- Basic Operators
- Decision Making
- Loops
- Numbers
- Characters
- Arrays
- Strings
- Functions
- File I/O
We will explain all these elements in subsequent chapters with examples using different programming languages. First, we will try to understand the meaning of all these terms in general and then, we will see how these terms can be used in different programming languages.
This tutorial has been designed to give you an idea about the following most popular programming languages −
- C Programming
- Java Programming
- Python Programming
A major part of the tutorial has been explained by taking C as programming language and then we have shown how similar concepts work in Java and Python. So after completion of this tutorial, you will be quite familiar with these popular programming languages.
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.
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;
}
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.
|
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.
Create
Compile
Execute or Run
Get the Output
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 as shown in below link.
- 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. Please search for online C/C++ compilers in Google for more details.
KEY POINTS TO REMEMBER IN C PROGRAMMING BASICS:
- C programming is a case sensitive programming language.
- Each C programming statement is ended with semicolon (;) which are referred as statement terminator.
- printf() command is used to print the output onto the screen.
- C programs are compiled using C compilers and displays output when executed.
No comments:
Post a Comment