click on this link......

LinkGrand.com

Saturday 22 December 2012

Write a program to find ascii code of a given character

#include<stdio.h>
#include<conio.h>
/* To find ASCII code of a character */

Void main()
{
                char ch;
                clrscr();
               printf("Enter a character:");
               scanf("%c",&ch);
               printf("ASCII code: %d",ch);
              getch();
 }
 

Tuesday 18 December 2012

Meaning of different colors in C

In C program different colours are indicated for different meanings:
  1. White: These words  which belong to C langauge they appear in which, are called as keywords or reversed words. They are directly understood by compiler.
  2. Green: They are called as  Identifiers. They are not understood directly by compiler. But their defination is in header file. A header file is a file which contains defination of different functions. eg. stdio.h - standard input and output header files (printf and scanf). conio.h - Console input and output header files (getch(), return 0, clrscr()).
  3. Red: These are called as message. They are not understood by compiler. They are enclosed in double quotes.
  4. Yellow: These are called as seperators. eg. ; } )

Operators and Operations

The priority of precedence in which the operations in an arithmetic statement are performed is called hierarchy of operations.

priority operations Description
1st * / % Multiplication, division,modular division
2nd + - Addition, subtraction
3rd = Assignment

Opeartors and expressions:

  1. Arithmetic Operation: 

    • + -> Addition
    • - -> Subtraction
    • * -> Multiplication
    • / -> Division
    • % -> Modulus (used only in integers)



  2. Relational Operation: 

    • ==> Equal to
    • != -> Not equal to
    • > -> Greater than
    • < -> Less than
    • >= -> Greater than equal to
    • <= -> Less than equal to



  3. Logical Operation: 

    • && > logical AND
    • || -> logical OR
    • | > -> logical NOT



  4. Assignment Operator (=) : 
  • assigns entity to its right to its left.


Friday 14 December 2012

Compilation and Execution

  • To convert the program into machine understandable language, compiler is used.
  • Compiler vendors provide an (IDE) Integrated Development Environment which consists of an editor as well as compiler.
  • Examples of compilers :
    • Turbo C, Turbo C++ and microsoft C are compilers that work under MS DOS.
    • Visual C++ and Borland C++ are the compilers that work under windows.
    • gcc compiler works under linux.
    • printf() outputs the values to the screen whereas scanf() receives them from the keyboard.
C Instructions:
There are basically three types of instructions in C:
  • Type Declaration instruction
  • Arithmetic Instruction
  • Control Instruction
 Purpose of each instructions is given below:
  1. Type Declaration Instruction : To declare the type of variables used in C program.
  2. Arithmetic Instruction :  To perform arithmetic operations between constants and variables.
  3. Control Instruction : To control the sequences of execution of various statements in C programs.
 Commands used in TC:
  1. To create a new file.
    1. Alt + (F) File -> New   
  2.  To open an existing file.
    1. Alt + (F) File -> Open
  3.  To save a  file.
    1. Alt + (F) File -> Save   
  4.  To compile file. 
    1. Ctrl + F9 
 

Functions in C

  1. Main() :
    • Main () is a collective name given to a set of statements. It is a function. Every function has a pair of parenthesis () associated with it.
  2. Void :
    • If we want that the main() function should not return any value then we should preceed it with the keyword void.
    • Void main(). 
     3. printf :
    • This function is used to display the output.

variables and keywords

C variables :
  • an entity that may vary during program execution is called a variable.
Rules for constructing variable names :
  • A variable name is any combination of alphabets and can contain upto 31 characters. 
  • The first character must be an alphabet or underscore.
  • No commas or blanks are allowed.
  • No special symbol other than underscore can be used.
  • eg. si_intel, m_hrs, rms895.
C Keywords :
  • Keywords are the words whose naming has already been explained to the C Compiler.
  • Keywords are also called Reserved words.
  • There are 32 keywords available in C.
  • These keywords are as follows.


auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while

C programming language is also called a free form language.
Every C statement must end with a semicolon (;) Thus semicolon acts as a terminator.
Comment about the program should be enclosed within /* */ A comment can split over more than oneline as in, /* This is a jazzy comment */ Such a comment is often called a multi line comment.

Friday 7 December 2012

Introduction to C language

  • C is a programming language developed at AT & T's Bell Laboratories of USA in 1972.
  • It was designed & written by Dennis Ritchie.
Computer program: 
A computer program is a set of instructions given to the computer to solve a problem.


Computer programming Language:
It is a language in which a computer program is written. 
eg. C, C++, Java.

Compiler:
A compiler is a ready made computer program written in a computer programming language into the language that computer understands.
i.e. ON (1) and OFF  (0)

Turbo C Compiler:
TC is also called an Integrated Development Environment (IDE). Since TC compiler not only converts a program written in C language into MLL (Machine level language) but also provides an environment to :
  • Create new files
  • Open existing files
  • Save the files
  • Make changes in files.  
Steps to start TC:
  1. Start your computer
  2. Switch from windows OS to DOS (Disk Operating System).
  3. Change to the TC directory. CD/TC/BIN
  4. Stary TC. TC
  5. Maximize the window. Alt + enter.
steps to exit from TC:
  1. From the menu, select File -> Quit
  2. To exit from window type 'exit'.
    
Steps in learning English language:-

Alphabets -> words -> sentences -> paragraphs

Steps in learning C language:-

Alphabets         Constants         
Digits          ->  Variables   -> Instructions -> Program
Special               Keywords
Symbols
C Constants:-
  1. primary constants:
    1. Integer constants
    2. Real Constant
    3. Character constants
  2. Secondary Constants:
    1. Arrays
    2. pointer
    3. structure
    4. union
    5. Enum
* Integer constants-
  • It must not have a decimal point.
  • It may be positive or negative.
  • eg. 426, 782, -8000,-7605.

* Real constants-
  • Real constants are often called floating point constants.
  • It must have a decimal point.
  • It may be positive or negative.
  • Eg. +325.34, 426.0, -48.5792
  • Real constants can be expressed in two forms i.e. fractional or exponential.
* Exponential form-
  • Real constants is expressed in two parts.
  • The part appearing before e is called mantissa, whereas the part following e is called exponent.
  • Thus 0.000342 can be expressed in exponential form as 3.24 e-4.
  • Eg. +3.2 e-5
  • we may use e or E.
* Character constants-
  • Eg. 'A','I','5','='
  • The inverted commas should point towards left.