Search & Find out

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

Monday, November 26, 2012

Basic of C Program

Basics of C

  Format :
                  
     #include  "stdio.h"                           \* Header files*/
    #include  "conio.h "
   
     void main()                \* Main function, the execution of the program       
    {                       starts from here */
      
                     --------------------
        --------------------                 \*  statements or body of the programe */
        --------------------
                 
                 }

   
    The body of the programe include declaration of variables, statements &....many more..

      Declaration of  variable :
                              Declaring the variable means declaring the datatype for that variable,
       in which the variable to be stored.
       (A variable is an identifier that is used to represent some specified type of information with in a
         designated portion of the program.) 

    int a;     -->   Interger value, a is a variable which is used to store the integer value.

    char b;    -->   Character , b is a variable which is used to store the character.

    float c;     -->   Real constant value, c is a variable which is used to store the real constant
               value or float value.

     Here we can initialise the values to the variables
    i.e
        int a=10;   
        char b={z};
        float c=10.205;

      Statements of the program :
            Statements or body of the program include lot of functions, like
       printf(), scanf(), arrays[], user defined functions, pointers, structures, ... and many more..


     printf() :
      This function is used to printing the statements, values, etc..
             E.g :
             printf("Hello, world");

    O/p:  Hello, world

             E.g :
             printf("The value is %d",a);

    O/p:  10                   /* Here the value of the "a" is printed */


    \n     -->     uses to break the line
    \t      -->     uses to give a tab space i.e. space of 8 characters

     scanf() :
      This function is used to accepting the values , etc..
             E.g :
             scanf("%d",&a);

    O/p:  _                                  /* The program is waiting for accepting a integer value */

   
    %d    -->   It accepts only integer values.

    %c    -->   It accepts only a single character.

    %f            -->   It accepts only real constant values.

    We can accept one or more values at a samr time.

     E.g :
             scanf("%d%c%d",&a,&b,&c);

    O/p:  _       (enter)        /* The program is waiting for accepting a integer value */
             _    (enter)        /* The program is waiting for accepting a character */
             _    (enter)           /* The program is waiting for accepting a real constant value */
   
  
      CONDITIONAL STATEMENT:

        This statements are depend upon the conditions
      There are two types:
http://www.brothersoft.com/d.php?soft_id=182798&url=http%3A%2F%2Flfiles3.brothersoft.com%2Fdevelopment%2Fc_c%2Ftc3.zip
       1) if else:
       
    syntax:        
        if(condition)
        {
            ----------------
            ----------------
        }
        else
        {
            ----------------
            ----------------
        }
   
    Here if condition is true then the ' if ' part is execute. if the condition is false then the ' else '
      part is execute.

         2)  switch :
   
    syntax :
        switch(expression \ variable)
        {
              case 1:           
            ----------------
            break;

              case 2:
            ----------------
            break;   

              default :
            ----------------
            break;
        }

        Here if the expresion or condition is declared.
        If condition is true the the case 1 : be execute,
        If condition is false the the case 2 : be execute.

        Here if the variable is declared, then the matching case would be executed.


           LOOP STATEMENTS :
            Loop means continue.... It means the execution of the loop
    statements are stop if and only if the condition in false.
           
    C has provided three types of iteration statements:

    1) for loop.
    2) while loop.
    3) do...while loop.

    1) for loop :
        For loop is a loop statement, In this first the condition is checked, and then the execution will be start.
        If the condition is false then the loop does not execute
        In which the statements are executes till the condition is false.
        In this loop, we can initialise & increment the variables.

        syntax :
            for(initialize; condition ; increment )
            {
                 ----------------------
            }
    E.g :  
       
    #include
    #include
   
    void main()
    {
            int i;

        for(i=0;i<100;i++)
        {
              printf("The value of i is %d",i);   
        }

        getch();
    }

     
         2 ) while loop :
        It is same as for loop, but the formate is different, means
     For loop is a loop statement, In this first the condition is checked, and then the execution will be start.
     If the condition is false then the loop does not execute
     In which the statements are executes till the condition is false.
   
        syntax :
            while (condition)
            {
                  -----------------
                  -----------------
            }

        E.g :
       
                #include
                #include
   
              void main()
             {
                 int i;

        while(i<100 )
        {                                  
                    printf("The value of i is %d",i);   
          }

        getch();
        }

        ...
   
          3) do .. while loop :
        In this loop, first the statements are executed before checking the condition.
    Means if the condition is false then only it will execute atleast one time.

    syntax :
        do
        {   
            ------------
        }
        while(condition);

    E.g :        
   
        do
    {
        printf("The value of i is %d",i);
    }
    while (i<100);
    ...
    ...


 Arrays:
                    An array is data type that uses subscripted variables to make the representation of a large number of homogeneous values possible.

    E.g: 
              int a[3];
              float c[5];

     Types of Arrays:

       1)  Single Dimensional Array:
               It uses only single dimensional ..
    E.g:   a[3]
             b[100]
             c[10]
       
       2) Multi Dimensional Array :
              It uses two or more dimensional i.e it uses two or morw seperate square
          brackets.

    E.g :  
        a[10][10]              -->    It is two dimensional Array.
        b[10][5][14]       -->    It is three dimensional Array.

       3)  Character Array or String :
               A group of characters can be stored in a character array.
           Character array are known as String.
          
    E.g:
                        char a[3]
           char b[100]
           char c[10]   
   
    In this String '\0' is used to indicate the last position of a word or sentence.

    i.e               a[0]  a[1]  a[2]  a[3]  a[4]
            T      E       J       A     \0

      POINTERS:
                Pointers is a variable which contains the address of the another variable.
         Basically it is used to store the memory location.
         Pointer itself might be another pionter.

    E.g:
              int *p;    /*p is declared as a pointer */


    E.g:
               int *p;   
               int a=10;
               p=&a;    /* It is a address operator, here p is stored the addres of the variable a */

                            int **k;            /* k is a pinters pointer , it points address of the pointer which points the address of a variable*/
               int *p;       
              int a=10;
              p=&a;
              k=&p;

           i.e
          a     p      k     /* the variable name */
                                  10           35084          48451        /* the value of the variable contains */
                  35084        48451          52101        /* the location of the variable */
             lets see how it works

    printf("%d",a);    -->    10
    printf("%d",*p);    -->    10
    printf("%d",p);    -->    35084
    printf("%d",*k);    -->    35084
    printf("%d",**k);    -->    10
    printf("%d",k);    -->    48451


          STRUCTURE :
        A structure is a user defined datatype. Structure is a data structure,
            whose individual elements can differ in type.
            It is a combination of several different previously data types, including othere structures.

    E.g:
           #include
           #include

          struct demo    /* "demo" is a name of the structure, we can take any name */
          {
              int a;    /* Here we can only declare & that would be only one variables in one line statement */
              int b;
             float c;
          };   
       
      void main()
     {
          struct demo s,s1;          /* s & s1 are variables, we uses this variable with the variable which are
                      declared in the struct demo */
        s.a=1;
        s.b=15;
        s.c=12.25;
   
        printf("%d\n%d\n%f",s.a,s.b,s.c);
    o/p:  1
            15
            12.25           

  

Read rest of entry

Sunday, December 6, 2009

Diomand By Asterix Symbols

#include "stdio.h"
#include "conio.h"

void main()
{
  int a,b,c,d,n,m,x;
  clrscr();

  printf("Welcome to astrick Diomand\n\n");
  printf("Enter a number  ");
  scanf("%d",&n);

   m=n-1;
   d=1;x=1;


   for(a=1; a<=n; a++)
   {
     for(b=1; b<=m; b++)
     {
       printf("   ");
     }

     for(c=1; c<=d; c++)
     {
       printf("*  ");
     }

     printf("\n");
     m--;
     d+=2;
   }

   m=(n*2)-3;

   for(a=1; a
   {
     for(b=1; b<=x; b++)
     {
       printf("   ");
     }

     for(c=1; c<=m; c++)
     {
       printf("*  ");
     }

     printf("\n");
     x++;
     m=m-2;
   }

   getch();
 }



Get the executable ( .exe ) file for this program..
Download
Read rest of entry

multiplation of two matrix

#include "stdio.h"
#include "conio.h"

void main()
{
  int a[3][3], b[3][3], c[3][3],i,j,k;
  clrscr();
  printf("Welcome to Mulpilation of two matrix\n\n");
  for(i=1; i<=3; i++)
  {
   for(j=1; j<=3; j++)
   {
     printf("Enter the valuf of A[%d][%d]:  ",i,j);
     scanf("%d",&a[i][j]);
   }
  }

  printf("\n\n");

  for(i=1; i<=3; i++)
  {
   for(j=1; j<=3; j++)
   {
     printf("Enter the valuf of B[%d][%d]:  ",i,j);
     scanf("%d",&b[i][j]);
   }
  }

  for(i=1; i<=3; i++)
  {
    for(j=1; j<=3; j++)
    {
      for(k=1,c[i][j]=0; k<=3; k++)
      {
    c[i][j]=c[i][j] + ( a[i][k] * b[k][j] );
      }
    }
  }

  printf("\n\n");

  for(i=1; i<=3; i++)
  {
    for(j=1; j<=3; j++)
    {
      printf("%d\t",c[i][j]);
    }
    printf("\n");
  }

  getch();
}



Get the executable ( .exe ) file for this program..
Download
Read rest of entry

Design By Asterix symbols

#include "stdio.h"
#include "conio.h"

void main()
{
  int i,a,b,c,d,n,m,x,y;
  clrscr();

  printf("Enter a number");
  scanf("%d",&n);

   m=n-1;
   d=1;x=1;
   y=n+2;



   for(a=1; a<=n; a++)
   {
     for(b=1; b<=m; b++)
     {
       printf("  ");
     }

     for(c=1; c<=d; c=c+2)
     {
       printf("*");
     }

     printf("\n\n");
     m--;
     d+=2;
   }

   y=d-4;

   for(a=1; a<=n; a++)
   {
     for(b=1; b<=x; b++)
     {
      if(b
       printf("  ");
     }

     for(c=1; c<=y; c=c+2)
     {
       printf("*");
     }

     printf("\n\n");
     x++;
     y-=2;
   }

   getch();
 }



Get the executable ( .exe ) file for this program..
Download
Read rest of entry

pyramids by asterix symbols

#include "stdio.h"
#include "conio.h"

void main()
{
  int a,b,c,d,n,m,x,y;
  clrscr();
  printf("Welcome to Astrick Phyramid\n\n");
  printf("Enter a number  ");
  scanf("%d",&n);

   m=n-1;
   d=1;

   for(a=1; a<=n; a++)
   {
     for(b=1; b<=m; b++)
     {
       printf("   ");
     }

     for(c=1; c<=d; c++)
     {
       printf("*  ");
     }

     printf("\n\n");
     m--;
     d+=2;
   }

     getch();
 }



Get the executable ( .exe ) file for this program..
Download
Read rest of entry

Thursday, December 3, 2009

Rotation of circle



#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "math.h"
void main ()
{
    int gd,gm,maxx,maxy;
    float x,y,x1,y1,r,theta;
    clrscr ();
    printf ("Enter the coordinates: ");
    scanf ("%f%f",&x,&y);
    printf ("Enter the radius: ");
    scanf ("%f",&r);
    printf ("Enter angle: ");
    scanf ("%f",&theta);
    theta = theta * 3.14/180;
    detectgraph (&gd,&gm);
    initgraph (&gd,&gm,"c:\\TC\\BGI");
    maxx = getmaxx ();
    maxy = getmaxy ();
    line (0,maxy/2,maxx,maxy/2);
    line (maxx/2,0,maxx/2,maxy);
    circle (x+maxx/2,y+maxy/2,r);
    x1 = x * cos(theta) - y * sin(theta);
    y1 = x * sin(theta) + y * cos(theta);
    setcolor (14);
    circle (x1+maxx/2,y1+maxy/2,r);
getch ();
closegraph ();
}



Download the executable (.exe)  file for this program..
download
Read rest of entry

Reflection of circle

#include "stdio.h"
#include "conio.h"
#include "graphics.h"
void main()
{
    int gd,gm;
    int maxx,maxy,x,y,r;
    clrscr ();
    printf ("Enter the coordinates: ");
    scanf ("%d%d",&x,&y);
    printf ("Enter the radius: ");
    scanf ("%d",&r);
    detectgraph (&gd,&gm);
    initgraph (&gd,&gm,"c:\\TC\\BGI");
    maxx = getmaxx();
    maxy = getmaxy();
    line (0,maxy/2,maxx,maxy/2);
    line (maxx/2,0,maxx/2,maxy);
    circle (x+maxx/2,y+maxy/2,r);
    setcolor (2);
    circle (x+maxx/2,-y+maxy/2,r);
    setcolor (11);
    circle (-x+maxx/2,y+maxy/2,r);
    setcolor (14);
    circle (-x+maxx/2,-y+maxy/2,r);
getch ();
closegraph ();
}


Download the executable (.exe)  file for this program..
download



Read rest of entry

line drawing Program



#include "stdio.h"
#include "conio.h"
#include "graphics.h"

void main()
{
int  gd,gm,x,x1,x2,y,y1,y2,ax,ay,dx,dy,l,i,a[1000],b[1000];
float bx,by;

detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
printf("Welcome to Line Drawing program \n\n");

printf("Enter the starting & ending points of x & y \n");
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
clrscr();

if(x1>x2)
{
  x=x2;
  dx=x1;
}
else
{
  x=x1;
  dx=x2;
}

if(y1>y2)
{
  y=y2;
  dy=y1;
}
else
{
  y=y1;
  dy=y2;
}

ax=dx-x;
ay=dy-y;
bx=1;
by=1;

if(ax>ay)
{
 by=ay/ax;
 }
 else if(ax
 {
 bx=ax/ay;
 }

 if(ax
 {
 l=ax;
 }
 else
 {
 l=ay;
 }

 for(i=1;i<=l;i++)
 {
   a[i]=x+bx;
   x=a[i];

   b[i]=y+by;
   y=b[i];
  }

  putpixel(x1,y1,1);

  for(i=1;i<=l;i++)
  {
    putpixel(a[i],b[i],1);
  }

getch();
closegraph();
}


Download the executable (.exe)  file for this program..
download




Read rest of entry

Mobile diagram graphic

#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "dos.h"
void main()
{
int gd,gm;
detectgraph(&gd,&gm) ;
initgraph(&gd,&gm,"c:\\tc\\bgi") ;
printf("\n\n\n\n\n\n\n\t\t\b\b NEW \n\t\t\b\b \bMOBILE") ;
line(100,100,100,250);
line(165,100,165,250);
line(100,100,165,100);
line(100,250,165,250);

line(105,105,105,150);
line(160,105,160,150);
line(105,105,160,105);
line(105,150,160,150);
circle(132,170,15);
line(130,160,128,163);
line(130,160,132,163) ;
line(128,163,132,163);
line(130,175,128,178);
line(130,175,132,178);
line(128,178,132,178);
line(123,169,123,172);
line(123,169,120,170);
line(123,172,120,170);
line(138,169,138,172);
line(138,169,140,171);
line(138,172,140,171);
line(106,184, 113,184);
arc(110,182,355,190,5);


line(150,184,157,184);
arc(154,182,355,190,5);
circle(109,195,4);
circle(109,209,4);
circle(109,223,4);
circle(109,237,4);

circle(132,195,4);
circle(132,209,4);
circle(132,223,4);
circle(132,237,4);

circle(155,195,4);
circle(155,209,4);
circle(155,223,4);
circle(155,237,4);

line(100,188,165,188);
line(100,201,165,201);
line(100,215,165,215);
line(100,229,165,229);
line(120,188,120,250);
line(145,188,145,250);
getch();
closegraph();
}



Download the executable (.exe)  file for this program..
download
Read rest of entry

mickey mouse graphic

#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "dos.h" 

void main ()
{
    int gd,gm;
    clrscr ();
    detectgraph (&gd,&gm);
    initgraph (&gd,&gm,"c:\\TC\\BGI");
    fillellipse (200,200,50,50);
    fillellipse (400,200,50,50);
    fillellipse (300,300,100,100);
    setfillpattern (EMPTY_FILL,0);
    fillellipse (300,300,90,90);
    circle (265,260,25);
    circle (335,260,25);
    fillellipse (265,265,5,5);
    fillellipse (335,265,5,5);
    circle (300,320,10);
    arc (300,282,220,320,70);
    arc (300,340,180,0,40);
    delay (5000);
closegraph ();
getch ();
}



Download the executable (.exe)  file for this program..
download
Read rest of entry

dda line drawing Program



#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "math.h"
void dda (float x1,float y1,float x2,float y2)
{
    float delx,dely,length;
    int x,y,i;
    if (x1==x2 && y1==y2)
    {
        printf ("The line cannot be drawn");
        return;
    }
    else
    {
        delx = fabs (x2-x1);
        dely = fabs (y2-y1);
    }
    if (delx >= dely)
    {
        length = delx;
    }
    else
    {
        length = dely;
    }
    delx = (x2-x1)/length;
    dely = (y2-y1)/length;
    x = x1 + 0.5;
    y = x2 + 0.5;
    i=1;
    while (i <= length)
    {
        putpixel (x,y,14);
        x = x + delx;
        y = y + dely;
        i = i + 1;
    }
}
void main ()
{
    int gd,gm;
    float x1,y1,x2,y2;
    clrscr ();
    printf ("Enter the starting points: ");
    scanf ("%f%f",&x1,&y1);
    printf ("Enter the ending points: ");
    scanf ("%f%f",&x2,&y2);
    detectgraph (&gd,&gm);
    initgraph (&gd,&gm,"c:\\TC\\BGI");
    dda (x1,y1,x2,y2);
getch ();
closegraph ();
}


Download the executable (.exe)  file for this program..
download





Read rest of entry

bresenham circle drawing Program



#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "math.h"

#include "dos.h"


void brsc (int cx,int cy, int r)
{
    int x,y,d;
    d = 3 - 2 * r;
    x = 0;
    y = r;
    do
    {
        putpixel (x+cx,y+cy,15);
        putpixel (y+cx,x+cy,2);
        putpixel (y+cx,-x+cy,4);
        putpixel (x+cx,-y+cy,6);
        putpixel (-x+cx,-y+cy,8);
        putpixel (-y+cx,-x+cy,10);
        putpixel (-y+cx,x+cy,12);
        putpixel (-x+cx,y+cy,14);
        delay (100);
        if (d < 0)
        {
            d = d + 4 * x + 6;
        }
        else
        {
            d = d + 4 * (x-y) + 10;
            y = y - 1;
        }
        x = x + 1;
    }
    while (x < y);
}
void main ()
{
    int gd,gm;
    int x,y,r;
    clrscr ();
    printf ("Enter the coordinates: ");
    scanf ("%d%d",&x,&y);
    printf ("Enter the radius: ");
    scanf ("%d",&r);
    detectgraph (&gd,&gm);
    initgraph (&gd,&gm,"c:\\TC\\BGI");
    brsc (x,y,r);
getch ();
closegraph ();
}



Download the executable (.exe)  file for this program..
download












Read rest of entry

bresenham line drawing Program


#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "math.h"
void brs (int x1,int y1,int x2,int y2)
{
    int delx,dely,x,y,e,i;
    if (x1==x2 && y1==y2)
    {
        printf ("The line cannot be drawn");
        return;
    }
    else
    {
        delx = abs (x2-x1);
        dely = abs (y2-y1);
        x = x1;
        y = y1;
        e = 2 * dely - delx;
        i = 1;
    }
    abc:
    putpixel (x,y,15);
    while (e >= 0)
    {
        y = y + 1;
        e = e - 2 * delx;
    }
    x = x + 1;
    e = e + 2 * dely;
    i = i + 1;
    if (i <= delx)
    {
        goto abc;
    }
}
void main ()
{
    int gd,gm;
    int x1,y1,x2,y2;
    clrscr ();
    printf ("Enter the starting points: ");
    scanf ("%d%d",&x1,&y1);
    printf ("Enter the ending points:");
    scanf ("%d%d",&x2,&y2);
    detectgraph (&gd,&gm);
    initgraph (&gd,&gm,"c:\\TC\\BGI");
    brs (x1,y1,x2,y2);
getch ();
closegraph ();
}



Download the executable (.exe)  file for this program..
download
Read rest of entry

Tree search ( inorder, preorder & postorder )

 The tree is pre-determined , it shows In order , Pre order & Post order  tree search..........

 

#include
#include
struct node
{
    struct node *left;
    struct node *right;
    char data;
};
struct node *buildtree(int);
void inorder(struct node *);
void preorder(struct node *);
void postorder(struct node *);
char arr[]={'A', 'B', 'C', 'D', 'E', 'F', 'G','/0', '/0', 'H'  };
int lc[]={1, 3, 5, -1, 9, -1, -1, -1, -1, -1};
int rc[]={2, 4, 6, -1, -1, -1, -1, -1, -1, -1, -1};
void main()
{
    struct node *root;
    clrscr();
    root=buildtree(0);
    printf("Inorder Travesal\n");
    inorder(root);
    printf("\nPostorder Traversal\n");
    postorder(root);
    printf("\nPreorder Traversal\n");
    preorder(root);
    getch();
}
struct node *buildtree(int index)
{
    struct node *temp=NULL;
    if(index!=-1)
    {
        temp=(struct node *)malloc(sizeof(struct node));
        temp->left=buildtree(lc[index]);
        temp->data=arr[index];
        temp->right=buildtree(rc[index]);
    }
    return(temp);
}
void inorder(struct node *root)
{
    if(root!=NULL)
    {
        inorder(root->left);
        printf("%c\t", root->data);
        inorder(root->right);
    }
}
void postorder(struct node *root)
{
    if(root!=NULL)
    {
        postorder(root->left);
        postorder(root->right);
        printf("%c\t", root->data);
    }
}
void preorder(struct node *root)
{
    if(root!=NULL)
    {
        printf("%c\t", root->data);
        preorder(root->left);
        preorder(root->right);
    }
}



Download the executable (.exe)  file for this program..
download
Read rest of entry

Binary search

#include "stdio.h"
#include "conio.h"
void main ()
{
    int LA[6]={2,4,6,8,10,12},i,j,beg=0,mid,end=5;
    clrscr ();
    mid=((beg+end)/2);
    printf("2,4,6,8,10,12\n\n");
    printf ("Entr the number to be searched: ");
    scanf ("%d",&j);
    for (;beg<=end && j!=LA[mid];)
    {
        if (j
            end=mid-1;
        else
            beg=mid+1;
        mid=((beg+end)/2);
    }
    if (LA[mid]==j)
        printf ("The location is: %d",(mid+1));
    else
        printf ("The location does not exist!");
getch ();
}



Download the executable (.exe)  file for this program..
download
Read rest of entry

Sum of prime numbers

#include "stdio.h"
#include "conio.h"
void main ()
{
    int i,n,R,m;
    clrscr ();

    printf("Enter a no. to find out all Prime no.: ");
    scanf("%d",&m);

    for (n=1;n<=m;n++)
    {
        for (R=2;R
        {
            if (n%R==0)
            {
                break;
            }
        }
        if (R==n)
        {
            printf ("%d\t",n);
        }
    }
getch ();
}



Download the executable (.exe)  file for this program..
download
Read rest of entry

character to it's ASCII value

#include "stdio.h"
#include "conio.h"
void main()

{
  char n;
  clrscr();

  printf("Enter a character to get ASCII value \n\n");
  scanf("%c",&n);
 
  printf("\nThe ASCII value for the charcter %c is %d",n,n);

    getch();
 }



Download the executable (.exe)  file for this program..
download
Read rest of entry

ASCII value to a character


#include "stdio.h"
#include "conio.h"
void main()

{
  int n;
  clrscr();

  printf("Enter a ASCII value to get the character \n\n");
  scanf("%d",&n);

  printf("\nThe ASCII value for the charcter %d is %c",n,n);

    getch();
 }



Download the executable (.exe)  file for this program..
download
Read rest of entry

Ascending Order


#include "stdio.h"
#include "conio.h"
void main ()
{
    int n[100],i,j,k,no;
    clrscr ();
    printf("Welcome to Ascending order \n\n");
    printf("Enter the number of no.s do u want to give ? : ");
    scanf("%d",&no);

    for (i=0;i
    {
        printf ("\nEnter a number: ");
        scanf ("%d",&n[i]);
    }
    for (i=0;i
    {
        for (j=i+1;j
        {
            if (n[i]>n[j])
            {
                k=n[j];
                n[j]=n[i];
                n[i]=k;
            }
        }
    }
    for (i=0;i
    {
        printf ("%d\n",n[i]);
    }
getch ();
}



Download the executable (.exe)  file for this program..
download
Read rest of entry

Addition, subtraction, multiplication, division & modulus

#include "stdio.h"
#include "conio.h"
void main()
{
int addition;
int a1,b1;
int subtraction;
int a2,b2;
int multiplication;
int a3,b3;
float division;
float a4,b4;
int modulus;
int a5,b5;
clrscr();
    printf("\n\nenter the values a1,b1:\n");
    scanf("%d%d",&a1,&b1);
    addition=a1+b1;
    printf("\naddition:\t%d",addition);
    printf("\n\nenter the values a2,b2:\n");
    scanf("%d%d",&a2,&b2);
    subtraction=a2-b2;
    printf("\nsubtraction:\t%d",subtraction);
    printf("\n\nenter the values a3,b3:\n");
    scanf("%d%d",&a3,&b3);
    multiplication=a3*b3;
    printf("\nmultiplication:\t%d",multiplication);
    printf("\n\nenter the values a4,b4:\n");
    scanf("%f%f",&a4,&b4);
    division=a4/b4;
    printf("\ndivision:\t%f",division);
    printf("\n\nenter the values a5,b5:\n");
    scanf("%d%d",&a5,&b5);
    modulus=a5%b5;
    printf("\nmodulus:\t%d",modulus);
    getch();
}



Download the executable (.exe)  file for this program..
download
Read rest of entry
 

My Blog List

Term of Use