Thursday 16 May 2013

Extension .cxx for ?

.c for c programs
.cpp for c++ programs
.cxx for ?


Answer: That too for C++. ".CXX" is an old-style extension for C++ source files the X is supposed to represent plus signs turned 45 degree.

Source: http://stackoverflow.com/questions/5171502/c-vs-cc-vs-cpp-vs-hpp-vs-h-vs-cxx

Wednesday 8 May 2013

Recursion (Recursive Function) :


Recursion (Recursive Function) :
When a function of body calls the same function then it is called as 'recursive function.'

Example:

Recursion()
{
        printf("Recursion !");
        Recursion();
}

Program :


#include <stdio.h>
#include <conio.h>
 
Recursion()
{
        int no;
        printf("\nRecursion... ");
        printf("\n\n Enter Number : ");
        scanf("%d",&no);
        if (no==3)
               exit(0);
        else
               Recursion();
}
void main()
{
        clrscr();
        Recursion();
}

Output :



 
Recursion...
 
 Enter Number : 2
 
Recursion...
 
 Enter Number : 1
 
Recursion...
 
 Enter Number : 3_



Features :

·         There should be at least one if statement used to terminate recursion.
·         It does not contain any looping statements.

Advantages :

·         It is easy to use.
·         It represents compact programming strctures.

Disadvantages :

·         It is slower than that of looping statements because each time function is called.

Note :

·         It can be applied to calculate factorial of a number, fibonancci series.