Pages

Basic of c

Before starting programing in c language .it is better to learn some Basic concet like:--

1.Important logics that will be used in common 'C' programs
2 Character set of  'C' Language
3 Constants
4 Variables
5 Keywords
6 Data Types
7 Operands
8 Operators
9 Step to install  C in computer

1 Basic Logics [FORMULAES]:-


Area of Rectangle
A=L*B
Area of Circle
A=3.14*R*R
Volume of Box
V=L*B*H
Average of 3 Numbers
AVG=(A+B+C)/3
Area of Square
A=L*L
Area of Triangle
A=(L*B)/2
Swap  A and B
T=A
A=B
B=T

Character Set:-A  Character represent alphabet,digit or special symbol that we can use in ‘C’ Language .In ‘C’ we can type mainly three type of characters.
1)      Alphabets –A to Z and a to z
2)      Numeric -0,1,2,3,4,5,6,7,8,9………..
3)      Special Symbols –{},[],+,-,&,*,?,=,!,#


Constant:  Constant means fix value and cannot change during run time . ANSI C allows you to declare constants. When you declare a constant it is a bit like a variable declaration except the value cannot be changed.for example

Const int  a =30;

Constant divided into two type :
a)Primary Constants

·        Integer Constants
·        Real  Constants
·        Character  Constants
 b) Secondary Constants:
·        Array
·        Pointer
·        Structure
·        Union
·        Enum

Programe :

#include <sdtio.h>
#include<conio.h>
main ()
{
Const int a=10;
Const float b=3.14;
printf(“the value of a :%d “, a); 
printf(“the value of a :%f“, b);
}

Output :
The value of a :10
The value of b=3.14

Variable : variable is used to store the value and change during run time each variable as data type and each varible has some unique name .variable has two type :
                              
                           Local variable
                           Global variable
    
 syntax  :     int  a =5;


Keyword   keywords are the reserved words with some specified fuction .the meanings of keywords are already defined in C compiler .We cannot use keyword as variable names .In C there are 32 Keywords 

Auto
Double
Int
Struct
Break
Else
Long
Switch
Case
Enum
Register
Typedef
Char
Extern
Return
Union
Const
Float
short
Continue
For
Signed
Void
Default
Goto
Sizeof
Volatile
Do
If
Static
While
unsigned


 Data Type : the value stored in variable or constant depends upon data type or we can say that data type represent what type of data will stored in the variable in C Language we have  two  basic data type .

                 Inbuilt Data Type 
                 User define Data Type

        Inbuilt Data Type
      TYPE
       SIZE (bits)
    FORMAT
RANGE
     Char
8
%c
-128 to 127
     Int
16
%d
-32768 to 32767
     Unsigned int
16
%u
0 to 65535
     Long Int
32
%ld
-2147483648 to 2147483647
     Float
32
%f
3.4 e-38 to 3.4e+38
      Double
64
%lf
1.7e-308 to 1.7e+308
      Long Double
80
%lf
3.4e-4932 to 3.4 e+4932

     User define data type :

    Array
    structure
    union

Operands

this is used to store the value .each  operand has name .c=a+b in this expression a,b,c are operands these are variable that store any values

Operator

this is special symbol used to performe the operation on the operand such as
    c=a+b;
Types of operator are given below :

Arithmatic operator :                   (  +, -, *, / ,%)
Assignment operator:                 ( =, +=, -=, /=,*=)
Logical operator:                       (&&,  || ,!)
Conditional operator:                 (? :)
Relational  operator:                   (< ,> ,<=,>= ,==)
Bitwise operator:                       (& ,| ,^,  <<, >> , ~)



Steps of install  C  into your  computer

1)First of all find turboc.exe file

2)Copy this file and paste it on c drive (  c:   )

3)Now open Dos prompt (  Start -->Run -->Cmd-->ok)

4)Type cd\ press Enter .

5) C:\turbo .exe -d .it will extract all directories from turbos to c drive of your computer

0 comments: