Showing posts with label c programming. Show all posts
Showing posts with label c programming. Show all posts

Saturday, November 19, 2011

C Program With Recursion: Find Factorial Using Recursion in C Programming

It is a sample program example which demonstrate recursion in C programming. It is a factorial program with recursion. Accept number from the user and generate factorial of accepted number using recursion.

Program Code
#include"stdio.h"
#include"conio.h"
fact(int n);
void main()
{
 int n,r;
 clrscr();
 printf("************* Find Factorial of Number Using Recursion *************");
 printf("\n enter a number ");
 scanf("%d",&n);
 r=fact(n);
 printf("\n Factorial of %d is =  %2d\t",n,r);
 getch();
}

fact(int n)
{
 int f;
 if((n==0)||(n==1))
  return(1);
 else
  f=n*fact(n-1);
 return(f);
}



Output

Saturday, September 10, 2011

Difference Between C and C++ Programming

Difference Between C and C++ Programming


difference C and C++















C ProgrammingC++ Programming
C follows the procedural programming paradigmC++ is a multi-paradigm language(procedural as well as object oriented)
In C language focus on procedure and steps.C++ focuses on the data rather than the process
In C data hiding and data security is not possible.Data hiding and data security is present.
C uses Top-Down approchC++ uses Bottom-Up approach
C is a function driven programming languageC++ is a object driven programming language
C does not support overloading conceptC++ supports overloading concepts like operator overloading and function overloading
C does not support namespaces conceptCPP supports Namespaces concept.
C not support exception handlingC++ supports Exception Handling
C is structured programming languageC++ is object oriented programming language.
C does not support inheritance, reusability, polymorphism, data abstractionCPP supports inheritance, reusability, polymorphism, data abstraction.
C language only support Early bindingCPP supports both Early and Late binding
C uses standard input, output functions like scanf and printf.C++ uses input function cin and output function is cout.
There are all data is available to end user. No data securityThere is data abstraction. Not complete data is available to End user

C and C++