10/05/2016

C program



About C language
C is a general-purpose, high-level language.It was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs.

 The first publicly available description of C is produced by Brian Kernighan and Dennis Ritchie which is recently known as the K&R standard.
Characteristics of C
  • It is a highly structured language.
  • It uses features of high lavel laguage.
  • It can handle bit-level operation.
  • C is a machine independent language.
  • It supports dynamic memory management (using pointer).
Keywords
Keywords(reserved words),are the special words reserved by C.The number of keywords supported by C varies depending on the version of C.Generally 32 keywords are supported by C which are as follows:

auto             else             long            switch
break           else if         char            const
extern          float            for               goto
if                  default       double         do
continue     Return       register        int
signed        sizeof         static           Short
unsigned    struct         typedef       then
union          volatile       while           void
C Programs
A C program can vary from 3 lines to thausands-millions of lines It should be written into one or more text files.C programming extension is ".c".For example, hello.c. We can use "vi", "vim" or any other text editor to write C program into a file.

FORMATE
#include<stdio.h>
#include<conio.h>
void main()
{
--------
--------
----------
getch()
     }
data types
int    float    double    char
Size of data types
Following program shows the memory size of data types:
#include<stdio.h>
#include<limits.h>
int main()
{
   printf("Storage size for int : %d \n", sizeof(int));
    printf("Storage size for float : %d \n", sizeof(float));
    printf("Storage size for char : %d \n", sizeof(char));
    printf("Storage size for double : %d \n", sizeof(double));
   return 0;
    }
Output:
Storage size for int : 4
Storage size for float : 4 
Storage size for char : 1
Storage size for double : 8

4 comments: