Do you want to learn Programming Languages?
Are you excited to know about programming logics & stuff?
Today we are going to discuss about the core programming language called “C Programming”.
As we all know that C programming is the starting of programming world. All high level languages (like Python, Java, etc.) are inspired from C programming.
Most of the experienced programmers has suggested to learn Programming logics through C Programming because it is easy to understand.
Now the first question arises is What is C Programming?
Contents
Introduction to C Programming
C is a programming language developed at Bell telephone laboratories in 1972 by Dennis Ritchie. It is one of the oldest and finest programming language.
C programming language is reliable simple and easy to use structured programming language.
Major parts of popular operating system like windows, Unix, Linux, etc are written in C. It is the most appropriate language for learning computer programming.
Some Important Facts about C
- C is invented to Write Linux operating system.
- C is a successor of B language which was introduced around 1970.
- C was formalized in 1988 by the American National standard Institute (ANSI).
- Today’s most popular Linux OS and RDBMS MySQL have been written in C
- C was originally first implemented on the DEC PDP-11 computer in 1972.
Why to use or learn C Programming?
we learn or use C Programming Because of Some Features and Advantages of C :-
Basics of C Programming
When we talk about the basics of C programming, three main terms are important which are Variables, Constants, & Keywords. There are not basic of C programming for interview but are the fundamentals or base of C Programming.
Let’s talk about these three terms one by one:
Variables, Constants, & Keywords in C
Variables
Variables are the storage place where we can store n number of Values. We can store Data in computer through Variables.
To store any value in computer we need to help variables. Through variables we can easily Store values in computer and also accessing them easily.
C Variables are also called “Identifiers”, used to store data in computer memory for mathematical operations and manipulations.
Ex.=> a=2, b=’a’, c=2.5
Rules for Declaring or Naming Variables in C programming :-
- The first character must be an alphabet or underscore(_).
- No commas, blanks allow.
- No special symbol other than underscore is allowed.
- Variable names are case sensitive
Constant
In C programming, an entity whose value doesn’t change is called a constant. If we change value of constant during execution of program then we get Compilation error.
Constants are the values which are storaged in Computer thought Variables. Means variables holds constant values in them.
Types of constant:
Primarily there are 3 types of constant :-
- Integer constant = -1,6,7,9
- Real constant = -322.1,2.5,7.0
- Character constant = ‘a’,’$’,’@’(must be enclosed within single inverted commas)
Keywords
keywords are predefined reserved words in a programming language. these keywords help us to use the functionality of C programming.
Due to their special meaning we cannot be used them for other purpose.
There are 32 keywords available in C programming:
auto | double | int | struct |
break | else | long | switch |
case | enum | register | typedef |
char | extern | return | union |
const | for | short | void |
continue | float | signed | while |
default | goto | sizeof | volatile |
do | if | static | unsigned |
we will discuss about each of the C programming keyword in detail in another post.
Basic Structure or Syntax of a C Program
All c programs have to follow a basic structure. A c program starts with the mainf functionand executes instructions presents inside it.
Each instruction terminated with a semicolon(;).
There are some basic rules which are applicable to all the c programs :-
- Every program’s execution starts from the main function.
- All the statements are terminated with a semi-colon.
- Instructions are case sensitive.
- Instructions are executed in the same order in which they are written.
- For printing output of any C Program we Need to use predefined function of stdio.h header file Called printf( ).
- For taking input there is one more predefined function of stdio.h header file is used called scanf().
C Program to add Two numbers :-
/* Program to add two Numbers (Comment) */
#include<stdio.h> /*Header File with Preprocessor*/
void main() /*Main Function*/
{ /* Function Body Starting */
int a,b,c; /* Variable Declaration */
printf(“\n Enter two Numbers”); /* Output Statement for Taking Input */
scanf(“%d%d“,&a,&b); /* Input Statement */
c=a+b; /* Arithmetic Operation / Processing */
printf(“\nSum= %d“,c); /* Output Statement for Output Printing */
} /* Function Body End */
Flow of C Program in computer
Step 1: C program (source code) is sent to preprocessor first. The preprocessor generates an expanded source code.
Step 2: Expanded source code is sent to compiler which compiles the code and converts it into assembly code.
Step 3: The assembly code is sent to assembler which assembles the code and
converts it into object code. (.o or .obj).
Step 4: The object code is sent to linker which links it to the library such as
header files. Then it is converted into executable code. (.exe)
Step 5: The executable code is sent to loader which loads it into memory and
then it is executed. After execution, output is sent to console.
Advantages of C programming
- Powerful and efficient language
- Portable language
- Easy to understand & learn
- Comparatively fast execution
- Quality to extend itself
- Open source
- Dynamic memory allocation
- Widely used in algorithm time & space calculation
- Used to program any hardware
Disadvantages of C Programming
- There is no concept of OOP
- Predefined functions are in limited amount
- Error handling is tough
- C does not have any constructor or destructor.
- C is a small and core machine language that has minimum data hiding and exclusive visibility that affects the security of this language.
- C does not implement the concept of namespaces
People also ask
What is C Programming?
C is a powerful general-purpose programming language. It is can be used to develop standalone software like operating systems, databases, compilers, and so on.
Who Invented C Programming?
C programming language developed in the early 1970s by American computer scientist Dennis M. Ritchie at Bell Laboratories (formerly AT&T Bell Laboratories).
What are the features of the C language?
- Simple
- Portable
- Mid level
- Structured
- Fast Speed
- Memory Management
- Extensible
Conclusion
This is all about the basic of C Programming. This is only a short and quick overview of C Programming for beginners.
You will get all the advance level of aspects of C Programming in future posts. So keep in touch with me via social media profiles to get the latest notification of new posts or updates in existing posts.
I hope you have got the useful information from this article.
Thanks for visit!
< Previous Post
Next Post >