0% found this document useful (0 votes)
42 views

Basics of C Language: by Chinnu Edwin A M.Tech. CS

C is a general-purpose programming language developed in the 1970s. A C program consists of preprocessor commands, functions, variables, statements, expressions, and comments. It has a basic syntax that uses semicolons, comments that begin with /* and end with */, and keywords like if, else, int etc. The document discusses C program structure, parts of a C program like main function, data types in C and their sizes, variables and how they are declared.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Basics of C Language: by Chinnu Edwin A M.Tech. CS

C is a general-purpose programming language developed in the 1970s. A C program consists of preprocessor commands, functions, variables, statements, expressions, and comments. It has a basic syntax that uses semicolons, comments that begin with /* and end with */, and keywords like if, else, int etc. The document discusses C program structure, parts of a C program like main function, data types in C and their sizes, variables and how they are declared.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Basics of C language

By
Chinnu Edwin A
M.Tech. CS
                   CONTENTS
• Introduction
• C Program structure
• Parts of C Program
• C – Basic Syntax
                       INTRODUCTION
• Programming language
• Developed by Dennis Ritchie in 1972
• Structured language
• Easy to learn
• Produces efficient programs
       SAMPLE C PROGRAM
STRUCTURE
#include <stdio.h>
int main()
{
   /* printf function displays the content present in
double quotes. */
   
   printf("Hello World");
   return 0;
•}
              PARTS OF C PROGRAM
• A  C program basically consists of the following parts −
• Preprocessor Commands
• Functions
• Variables
• Statements & Expressions
• Comments
         

                   C BASIC SYNTAX
                      C LANGUAGE TOKENS

• Smallest individual units in C program


•  A keyword, an identifier, a constant, a string literal, or a symbol
               C LANGUAGE TOKENS
(contd..)
                       SEMICOLONS
   
• In a C program, the semicolon is a statement terminator.
•  That is, each individual statement must be ended with a semicolon.
•  Given below are two different statements −
•       printf("Hello, World! \n");
      return 0;
                         COMMENTS
• Comments are like helping text in your C program 
• They are ignored by the compiler. 
• They start with /* and terminate with the characters */ as shown
below −
• /* my first program in C */
                          IDENTIFIERS
• A C identifier is a name used to identify a variable, function, or any other
user-defined item. 
• An identifier starts with a letter A to Z, a to z, or an underscore '_' followed
by zero or more letters, underscores, and digits (0 to 9).
• C does not allow punctuation characters such as @, $, and % within
identifiers.
•  C is a case-sensitive programming language.
• Some examples of acceptable identifiers −
• mohd       zara    abc   move_name  a_123
• myname50   _temp   j     a23b9      retVal
                                  KEYWORDS
• The reserved words may not be used as constants or variables or any
other identifier names.
auto else long switch
break enum register typedef
case extern return union
char float short unsigned
const for signed void
continue goto sizeof volatile
default if static while
do int struct _Packed
double
                        C – DATA TYPES
• Data types is used for declaring variables or functions of different
types. 
• The type of a variable determines how much space it occupies in
storage
                    C – DATA TYPES (contd..)
                C – DATA TYPES (contd..)

Data type Size(in bytes) Range

 character 1 -128 to 127

 integer 2 -32,768 to 32,767

 floating 4 -3.4e-38 to 3.4e+38


                        C – VARIABLES 
• A variable is a name given to a storage area that our programs can
manipulate.
• It is a data name that is used to store any data value.
• The name of a variable can be composed of letters, digits, and the
underscore character. 
• It must begin with either a letter or an underscore. 
• Upper and lowercase letters are distinct because C is case-sensitive.
          Variable Definition in C

• It tells the compiler where and how much storage to create for the variable. 

• A variable definition specifies a data type and contains a list of one or more variables of that type
as follows −
       type variable_list;

Some valid declarations are shown here −


int    i, j, k;
char   c, ch;
float  f, salary;
double d;

You might also like