C is a general-purpose language which has been closely associated with the UNIX operating system for which it was developed by Dennis Ritchie at AT & T's Bell Laboratories of USA in 1972. It is compiler based programme and set of logical instructions which are sequentially accessible.
Feature of C Program:
|
Rules for Writing, Compiling and Executing the C program
* In C all keywords are lowercased.
* Keywords cannot be used for any other purpose (like variable names).
* Every C statement must end with a ; (Semi-column) for terminator.
* First character must be an alphabet or underscore, no special symbol other than an underscore, no commas or blank spaces are allowed with in a variable, constant or keyword.
* No blank spaces are allowed within a variable, constant or keyword.
* Variable must be declared before it is used in the program.
* File should be have the extension .c
* Program need to be compiled before execution.
* Each and every program must has a main() function.Data
type in C:
Data type determines the type of data a variable will hold. C language supports 2 different type of data types.
1. Primary data types:
These are fundamental data types in C. These are: Integer (int
), floating point(float
), character(char
), void
etc.
2. Derived or user define data types:
Derived data types are grouped together like array, stucture, union and pointer.
Integer type: Integers are used to store whole numbers.
Storing capacity and range of Integer type on 16-bit machine:
Type | Storing capacity(bytes) | Range |
---|---|---|
int or signed int | 2 | -32,768 to 32767 |
unsigned int | 2 | 0 to 65535 |
short int or signed short int | 1 | -128 to 127 |
unsigned short int | 1 | 0 to 255 |
long int or signed long int | 4 | -2,147,483,648 to 2,147,483,647 |
unsigned long int | 4 | 0 to 4,294,967,295 |
Floating point type
Floating types are used to store real numbers, that means with float point value.
Storing capacity and range of float type on 16-bit machine
Type | Storing capacity(bytes) | Range |
---|---|---|
Float | 4 | 3.4E-38 to 3.4E+38 |
double | 8 | 1.7E-308 to 1.7E+308 |
long double | 10 | 3.4E-4932 to 1.1E+4932 |
Character type
Character types are used to store characters value.
Storing capacity and range of character type on 16-bit machine
Type | Size(bytes) | Range |
---|---|---|
char or signed char | 1 | -128 to 127 |
unsigned char | 1 | 0 to 255 |
void typevoid
type means no value. This is usually used to specify the type of functions which returns 0 value.
Header file in C:
A header file is a file with extension .h which contains C function declarations and macro. We must include the particular header file in our program when we use its function.
Example#include<stdio.h>
, #include<conio.h>
, #include<math.h>
etc.
0 Comments