Wednesday, 6 January 2016

Variable Declaration

Usually Variables are declared before use either at the start of a block of code after the opening { and before any other statements or outside a function.

--------------------------

int a,b; /* global variables */
main()
{
float a; /* local variables */
}
--------------------------


Local variables can only accessed within that function only whereas Global variables can access in whole program.

Variable Types


There are many 'built-in' data types in C.


  • short int -128 to 127 (1 byte)

  • unsigned short int 0 to 255 (1 byte)

  • char 0 to 255 or -128 to +127 (1 byte)

  • unsigned char 0 to 255 (1 byte)

  • signed char -128 to 127 (1 byte)

  • int -32,768 to +32,767 (2 bytes)

  • unsigned int 0 to +65,535 (2 bytes)

  • long int -2,147,483,648 to +2,147,483,647 (4 bytes)

  • unsigned long int 0 to 4,294,967,295 (4 bytes)

  • float single precision floating point (4 bytes)

  • double double precision floating point (8 bytes)

  • long double extended precision floating point (10 bytes)


Variable Names

we can use any combination of letters and numbers for Variable and function names but it must start with a letter.
We can use Underscore (_) as a letter in variable name and can begin with an underscore But Identifiers beginning with an underscore are reserved, And identifiers beginning with an underscore followed by a lower case letter are reserved for file scope identifiers Therefore using underscore as starting letter is not desirable.

Neeraj and neeraj are different identifiers because upper and lower case letters are treated as different identifiers 


Continue reading

/* This program prints Hello World on screen */

-----------------------------
#include <stdio.h>
Void main()
{
   printf(''Hello World\n'');
}
-----------------------------

Structure of C program



  •  /* This program ... */

The symbols /* and */ used for comment. This Comments are ignored by the compiler, and are used to provide useful information about program to humans who use it.


  • #include<stdio.h>


This is a pre-processor command which tells compiler to include stdio.h file.


  •  main()


C programs consist of one or more functions. There must be one and only one function called main. The brackets following the word main indicate that it is a function and not a variable.


  • { }


braces surround the body of the function, which may have one or more instructions/statements.


  • printf()


it is a library function that is used to print data on the user screen.


  • ''Hello World\n'' 


It is a string that will be displayed on user screen \n is the newline character.


  • ;

 A semicolon ends a statement.


  • return 0;

 return the value zero to the Operating system.


C is case sensitive language, so the names of the functions must be typed in lower case as above.

we can use white spaces, tabs & new line characters to make our code easy to read. 
Continue reading

Introduction

C Programming tutorial
The C programming language is a general-purpose, Mid-level language (generally denoted as structured language). C programming language was at first developed by Dennis M. Ritchie at At&T Bell Labs.

C is one of the most commonly used programming languages. It is simple and efficient therefore it become best among all. It is used in all extents of application, mainly in the software development.

Many software's & applications as well as the compilers for other programming languages are written in C also Operating Systems like Unix, DOS and Windows are written in C.

C has many powers, it is simple, stretchy and portable, and it can control System Hardware easily. It is also one of the few languages to have an international standard, ANSI C.

Advantages of C


  •  Fast, Powerful & efficient
  •  Easy to learn.
  •  It is portable
  •  ''Mid-level'' Language
  •  Widely accepted language
  •  Supports modular programming style
  •  Useful for all applications
  •  C is the native language of UNIX
  •  Easy to connect with system devices/assembly routines

Conclusions - This is the short and Fresh information about 
"What is C Programming & its Advantages 

Continue reading