PPC Notes
PPC Notes
History of C
Cwas developed by Dennis Ritchie in 1972 at Bell Laboratories of AT&T. It is the
successor to the language B and was built to construct the utilities of Unix.
Features of C Language
Cis a simple, fast, and efficient language that is hardware independent
and general-purpose.
Applications of C Language
" Android OS, Linux kernel, Unix kernel are built using C.
Creating web brovwsers like Google Chrome.
Developing databases like MySQL.
Scripting programs and drivers of embedded systems.
Building applications like Adobe Photoshop.
" Development of video games.
Structure of C Language
Preprocessor Statements
Preprocessor statements are used to include header files.
" #include<stdio. h>; includes the standard input/output header file.
Global Declaration
Global declarations provide information about variables.
" int numl=10;: declares an integer variable numl with a value of 10.
int 2 bytes
char 1byte
sizeof Function
The sizeof () function is used to find the exact memory space allocated
for each data type.
#include<stdio. h>
#include<conio . h>
void main ()
clrscr0:
printf ("\n Storage size of integer is %d", sizeo f(int) ) ;
printf("\n Storage size of char is %d", sizeof (char) );
getch();
Constant Variables
The value of constant variables remains the same once assigned.
Type Casting
Type casting is changing a variable from one data type to another.
Implicit conversion: the compiler automatically converts one data type to
another.
Explicit conversion: the user performs the conversion using the following
syntax: (data type) expression;
#include <stdio.h>
int main ( )
int x=65;
printf("%C", x) ;
return 0;
}
Operators
Arithmetic Operators
Arithmetic operators are used to perform mathematical operations.
+, -
Assignment Operators
Assignment operators are used to assign values to variables.
#include <stdio. h>
#include<conio .h>
void main()
int num2;
clrscr):
printf("0riginal value is %d", num);
num+=2;
printf("Current value is %d", num) ;
num-=2;
printf("Current value is %d", num);
num*=2;
printf ("Current value is %d", num);
getch( );
)
Relational Operators
Relational operators are used to find the relation between two variables.
Logical Operators
Logical operators are used to perform logical operations.
#include <stdio . h>
#include<conio. h>
void main ()
(num2>num1)TIr
intf("IS num 2 gr than numl or num3? %d", result) ;
result=(num3>num2 )&&(num3>numl) ;
printf ("Is num 3 thegreatest number? %d", result) ;
getch() ;
Variable Declaration
Variables are capable of storing temporary data within a program.
" int age;: declares an integer variable age.
" float salary;:declares a float variable salary.
Variable Initialization
Block Structure
Block Structure
#include<stdio.h>
lude<conio . h>
#inc
void main ()
int num=l;
clrscr(0:
if (num>0)
printf("%d",num);
}
getch();
)
#include<s tdio.h>
#include<conio.h>
void main ( )
Macros
Macros
A macro is a piece of code in a program that is replaced by the value of
the macro.
#include<stdio.h>
#include<conio .h>
int main()
clrscr();
printf("The value of PI is %f", PI);
getch():
return 0;
Flow Chart Symbols
Operator Precedence
Operator Precedence
Operator precedence determines which operation is performed first in an
expression with more than one operator with different precedence.