Getting Started with C

In this article, we will be getting started with C programming language and dive deeper into its fundamentals.

We will cover the following topic:-

  • What is a language
  • Steps in learning languages
  • Tokens
    • Keywords
    • Identifiers
    • Literals
    • Punctuators
    • Operators

So please do not skip the content otherwise you may not understand the concepts fully.

Also, the points which we will discuss here is not only for ‘C’ language or any other programming language but the basics of every language.

So, let’s getting started with C without any delay by answering some easy questions.

Q-1 Try to read the following words and check whether you can read them or not?

Привет

你好

Dia dhuit

Answer: Actually you can’t read the above words if you are from India or not familiar with the words.
So, why can’t you read the above words?
Are you illiterate?
Definitely not because you can read and write English and other languages with which you are familiar. The reason you are not able to read the above words is that you are not familiar with the alphabet.

Remember “Taare Zameen Par” movie where the father was not able to read Chinese or Japanese words written at the box.

idea

I got it.
We need to learn alphabets first

So one thing is clear that if we have to learn a language then first we have to learn its alphabets

Alphabets

Alphabets are the smallest individual characters of any language.

Steps involved in learning a language.

Let’s see the steps involved in learning the English language for example.

Steps in learning a language
Steps in learning a language

Steps in learning C language

Steps in learning C language

Now, let’s learn the alphabets of the C language.

Tokens

  • Tokens are the smallest individual element of programming language.
  • Tokens are of 5 types
    • Keywords
    • Identifiers
    • Literals
    • Punctuators
    • Operators

Let’s discuss all these one by one.

Keywords

  • There are some predefined /reserved words that convey a special meaning to the compiler.
  • These words provides the proper functionality of C programming.
  • There are total 32 keywords in C langauge.
chardoubleintfloat
breakelsestructswitch
caseenumregistertypedef
autoexternreturnunion
continueforconstvoid
doifstaticwhile
defaultgotosizeofvolatile
shortlongsignedunsigned
Keywords

Identifiers

  • Identifiers are the name given to variables, functions, array, class, etc.
  • These are user defined names.
  • Can have alphabets (A-Z or a-z), digits(0-9) or underscore(_).
  • Rules for creating identifiers
    • Must start with either alphabets or underscore only.
    • Must not start with numbers.
    • keywords cannot be used as identifiers
    • Length must be less than or equal to 31 characters.
    • Identifiers should be short and meaningful so that anyone can understand.
    • C language is case sensitive i.e., Aa (upper case letters are different from lower case letters)
  • Example of valid identifiers
    • mybook, total_1, sum, _abc_, Sum_1.
  • Example of invalid identifiers
    • my book, 1sum, if, etc.. 

Literals

  • Literals are the constants values.

  • These are assigned to constant variables.

  • As we know constant means fixed so literals values cannot be changed.

  • Eg:- const int num=10;

Types of Literals

Types of Literals

Integer Literals

  • Integer literals contain only integer type numbers.
  • Have no fractional or exponential parts.
  • Can be divided into three categories
    • Decimal number
      • Contains numbers from 0-9
      • Represented in base 10.
      • eg: 85, 75, 123 etc
    • Octal number
      • Contains number from 0-7
      • Represented by base 8
      • eg 77, 12, 126 etc.
    • Hexadecimal
      • Contains number from 0-9, A(10), B(11), C(12), D(13), E(14), F(15)
      • Represented by base 16
      • eg 12C, BABA, FFFF, FACE etc.

Float Literals

  • Floatin point literals or in short float literals contains real numbers.
  • Real number is made up of integer part + real part + exponential part + fractional part.
  • Must be represented in decimal form or exponentials form.
  • Decimal Form
    • It may contains decimal point, exponential part or both.
    • Eg:- +5.0, 7.0, 3.2, -0.5 etc
  • Exponential Form
    • This form contains two parts i.e., mantissa and exponent.
    • This form is used to express long magnitude numbers
    • Eg:- 5200000000000 can be represented as 5.2e12.

Character Literals

  • Contains single character enclosed within single quotes. eg ‘a’, ‘x’, ‘z’ etc
  • There some non-graphical character which can used with ‘\’ called escape sequence. eg– ‘\n’, ‘\a’, ‘\t’ for new line, audible bell and horizontal tab respectively.
  • ASCII value can be used. eg:- 97 is ‘a’.

String Literals

  • Multiple character enclosed within double quotes.
  • Contains an additional character called null character(‘\0’).
  • Null character get inserted automatically at the end of string specifying the termination of string.
  • eg:- str1=”aditya” str2= “pandey”

Punctuators

Punctuators or separators are used to separate two characters, words, sentences etc.

Following is the list of the punctuators

Punctuator Use Example 
< > Header name #include <limits.h>  
[ ] Array delimiter char a[7];  
{ } Initializer list, function body, or compound statement delimiter char x[4] = {'H', 'i', '!', '\0' };  
( ) Function parameter list delimiter; also used in expression grouping int f (x,y)  
Pointer declaration int *x;  
Argument list separator char x[4] = { 'H', 'i', '!', '\0'};  
Statement label labela: if (x == 0) x += 1;  
Declaration initializer char x[4] = { "Hi!" };  
Statement end x += 1;  
… Variable-length argument list int f ( int y, ...)  
Preprocessor directive #include "limits.h"  
‘ ‘ Character constant char x = 'x';  
” ” String literal or header name char x[] = "Hi!";  

Operators

Types of Operators
Types of Operators

Watch my full video on the very same topic in the Hindi language.

I hope my article will help you in getting started with C programming language.

5 thoughts on “Getting Started with C”

Leave a Comment

Ads Blocker Image Powered by Code Help Pro
Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Please Reload After Disabling Ad\'s