0% found this document useful (0 votes)
9 views2 pages

Essential Information C

The document discusses some essential C programming concepts including variables and data types, operators, decision statements, loop control statements, and arrays. It provides details on each concept such as common data types and their sizes/ranges, examples of different operators, syntax of if/if-else statements and for/while loops, and how arrays are stored contiguously in memory with elements accessed using indexes.

Uploaded by

cba.pluto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Essential Information C

The document discusses some essential C programming concepts including variables and data types, operators, decision statements, loop control statements, and arrays. It provides details on each concept such as common data types and their sizes/ranges, examples of different operators, syntax of if/if-else statements and for/while loops, and how arrays are stored contiguously in memory with elements accessed using indexes.

Uploaded by

cba.pluto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Some essential information of C programing you will need to refer when you do practicals.

1. Variables and data types


2. Operators
3. Decision statements
4. Loop control statements
5. Arrays

1. Variables and data types


It is a data name used for storing a data value. Its value may be changed during the program
execution. The value of variables keeps on changing during the execution of a program. Data types
of variables are given in figure 1.

Data type Size (bytes) Range Format Specifiers


char 1 -128 to 127 %c
Unsigned char 1 0 to 255 %c
Short or int 2 -32,768 to 32,767 %i or %d
Unsigned int 2 0 to 655355 %u
float 4 3.4e-38 to +3.4e+38 %f or %g
Long 4 = 2147483648 to 2147483647 %ld
Unsigned long 4 0 to 4294967295 %lu
Double 8 1.7e – 308 to 1.7e+308 %lf
Long double 10 3.4e – 4932 to 1.1e+4932 %lf
Figure 1

2. Operators: Types of operators are listed in figure 2.


Type of Operator Symbolic representation
Arithmetic operators +, -, *, /, %
Relational operators >, <, ==, >=, <=, !=
Logical operators &&, ||, !=
Increment and decrement operator ++ and --
Assignment operator =
Bitwise operator &, |, ^, >>, <<, ~
Figure 2

3. Decision statements:
It checks the given condition and then executes its sub-block. The decision statement decides the
statement to be executed after the success or failure of a given condition.
Types:
1. If statement
2. If-else statement

Statements, syntaxes and examples of If statement and if else statement are shown in figure
3.

1
statement syntax example operators
If statement if(condition) if(a>b) > (relational)
Statement; {
s=a; = (assignment)
}
If-else if (condition) if(a>b) > (relational)
statement { {
Statements; s=a; = (assignment)
} }
else else
{ {
Statements; s=b;
} }
Figure 3
4. Loop control statements
Loop is a block of statements which are repeatedly executed for certain number of times.
Description of for loop and while loop are shown in figure 4.
Types:
1. For loop
2. While loop
statement syntax example
for loop for(initialize counter; test condition; re-evaluation parameter) for(i=0;i<=10;i++)
{ {
Statement; s=i+1;
Statement; }
}
while loop While (test condition) while(a==b)
{ {
Body of the loop a=a+1;
} }
Figure 4
5. Arrays
In C, an array is formed by laying out all the elements contiguously in memory. The square
bracket syntax can be used to refer to the elements in the array. The array as a whole is referred to
by the address of the first element which is also known as the "base address" of the whole array.
Graphical representation of array is shown in figure 5.
{
int arr[6];
int sum = 0;
sum += array[0] + array[1];
}

arr

arr[0] arr[1] arr[2] arr[3] arr[4] arr[5]


Figure 5

You might also like