Friday 19 April 2013

SIMPLE DATE AND TIME FUNCTION IN C++

     /*
     THIS PROGRAMM DISPLAY DATE AND TIME
     */
     #include <iostream.h>
     #include <time.h>
     #include<conio.h>
     void main( )
     {
      int i=0;
      char dateStr [9];
      char timeStr [9];
      for(i=0;;i++)
      {
        clrscr();

        // FATCH DATE USING BELOW FUNCTION
         _strdate( dateStr);
        cout<<"\n\t\tDATE::"<<dateStr;

        // FATCH TIME USING BELOW FUNCTION

        _strtime( timeStr );
       cout<<"\n\t\tTIME::"<<timeStr;
       }
       getch();
      }

- OPERATOR LOADING IN C++

/*
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::: THIS PROGRAMM EXPLAIN THE CONCEPT OF OPERATOR OVERLOADING  ::::
    :::: IN C++ PROGRAMM DEVLOPED BY DX PANCHAL AT MCA LAB          ::::
    :::: ON DATED 18/04/2013                                        ::::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*/
//HEADER FILES DECLARATION
#include<iostream.h>
#include<conio.h>

//BEGIN CLASS DECLARATION
class temp
{
   int a,b,ans;

  public:
     void getdata(int x,int y)
     {
       a=x;b=y;

     };
     void display()
     {

      cout<<"\n\t\tVALUE OF A=>"<<a<<"B=>"<<b;

     };
     void operator-();



};
void temp::operator-()
{
  a=-a;b=-b;

};
//END OF TEMP CLASS

//MAIN FUNCTION MAIN
void main()
{
 clrscr();

 temp t;
 t.getdata(10,20);
 cout<<"\n\n\t\tDEACTIVE OPERATOR ::> ";
    t.display();
 cout<<"\n\n\t\tACTIVE OPERATOR ::> ";
    -t;

    t.display();



 getch();
}

+ OPERATOER OVERLOADING IN C++


OPERATOR OVERLOADING IN C++

-/*
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :::: THIS PROGRAMM EXPLAIN THE CONCEPT OF OPERATOR OVERLOADING  ::::
    :::: IN C++ PROGRAMM DEVLOPED BY DX PANCHAL AT MCA LAB                        ::::
    :::: ON DATED 18/04/2013                                                                   ::::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*/
//HEADER FILES DECLARATION
#include<iostream.h>
#include<conio.h>

//BEGIN CLASS DECLARATION
class temp
{
   int a,b,ans;

  public:
     void getdata(int x,int y)
     {
       a=x;b=y;

     };
     void display()
     {

      cout<<"\n\t\tVALUE OF A=>"<<a<<"B=>"<<b;

     };
     void operator-();



};
void temp::operator-()
{
  a=-a;b=-b;

};
//END OF TEMP CLASS

//MAIN FUNCTION MAIN
void main()
{
 clrscr();

 temp t;
 t.getdata(10,20);
 cout<<"\n\n\t\tDEACTIVE OPERATOR ::> ";
    t.display();
 cout<<"\n\n\t\tACTIVE OPERATOR ::> ";
    -t;

    t.display();



 getch();
}

Tuesday 16 April 2013

COPY CONSTRUCTOR

#include<iostream.h>
#include<conio.h>

class code
{
  int id;
  public:
  code()
  {

  }
  code(int a)
  {
   id=a;
  }
  code(code & x)
  {
   id=x.id;
  }
  void display(void)
  {
    cout<<id;
  }
};
int main()
{
  clrscr();
  code a(10);

  code b(a);
  code c=a;
  code d;
  d=c;

  cout<<"\n\n\t Id Of A ";
  a.display();

  cout<<"\n\n\t Id Of A ";
  b.display();

  cout<<"\n\n\t Id Of A ";
  c.display();

  cout<<"\n\n\t Id Of A ";
  d.display();

  getch();
}

Sunday 14 April 2013

CONSTRUCTOR IN INHERITANCE

#include<iostream.h>
#include<conio.h>
#include<dos.h>
class tmp
{

  public:
     int d,c;
     tmp::tmp(int i,int q)
     {
      d=i;
      c=q;
     };

     int sum2()
     {
       return(d+c);

     };

};

class temp:public tmp
{
  public:
      int a,b,sum;
      temp(int m,int n,int x,int y):tmp(m,n)
      {
    a=x;
    b=y;

      };
      int sum1()
      {
       sum=a+b;
       return(sum);
      };

};

void main()
{
 int ans;
 clrscr();
 temp t1(10,20,30,40);

 ans=t1.sum1();
 cout<<"\n\t\tYOUR ANSWER FROM TEMP CLASS::>"<<ans;
 ans=t1.sum2();
 cout<<"\n\t\tYOUR ANSWER FROM TMP CLASS::>"<<ans;

 getch();
}

DEFAULT ARTGUMENTS IN MEMBER FUNCTION C++ PROGRAMMING LANGUAGE

/*
  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  :::: THIS PROGRAMM EVALUTE THE CONCEPT OF DEFAULT ARTGUMENTS       ::::
  :::: IN MEMBER FUNCTION    C++ PROGRAMMING LANGUAGE                ::::
  :::: DEVLOPED BY DX PANCHAL AT GROW MORE M.C.A. LAB                ::::
  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*/
// HEADER FILE DECLARATION
#include<iostream.h>
#include<conio.h>
#include<dos.h>

//CLASS TEST DECLARATION
class test
{

  int a,b,ans;

  public:
     void setcode(int m,int n=10)
     {
       a=m;
       b=n;
       ans=a+b;
       cout<<"\n\n\t\tVALUE OF A+B = "<<ans;
     };


};
// END OF CLASS TEST

// MAIN FUNCTION SECTION

void main()
{
  clrscr();
  test t1;
  t1.setcode(15); //TAKES DEFAULT VALUE
  t1.setcode(20); //TAKES DEFAULT VALUE
  t1.setcode(25,5);//GIVES VALUE TO THE FUNCTION




 getch();
}

STATIC MEMBER FUNCTION AND STATIC VARIBLE IN C++ PROGRAMMING LANGUAGE

/*
  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  :::: THIS PROGRAMM EVALUTE THE CONCEPT OF STATIC MEMBER FUNCTION   ::::
  :::: AND STATIC VARIBLE IN C++ PROGRAMMING LANGUAGE                ::::
  :::: DEVLOPED BY DX PANCHAL AT GROW MORE M.C.A. LAB                ::::
  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*/
// HEADER FILE DECLARATION
#include<iostream.h>
#include<conio.h>
#include<dos.h>

//CLASS TEST DECLARATION
class test
{

  int code;
  static int count;
  public:
     void setcode(int m)
     {
       code=m;
       count++;
       cout<<"\n\n\t\tVALUE OF CODE::>"<<code;
     };
     static void check()
    {

       cout<<"\n\n\t\tVALUE OF COUNT::>"<<count;

     };

};
int test::count;
// END OF CLASS TEST

// MAIN FUNCTION SECTION

void main()
{
  clrscr();
  test t1,t2;
  t1.setcode(1);
  t1.setcode(1);
  t2.setcode(1);
  t2.setcode(1);
  test::check();



 getch();

}

Friday 12 April 2013

NEWTONS INVERS INTERPLIATION IN C

#include<stdio.h>
#include<conio.h>
#define MAX 10

void main()
{
    FILE *fp;
    int number,i,j;
    float xvalue[MAX],yvalue[MAX],search,product;
    float sum=0;
    //
    j1fp=fopen("lgrninv.dat","w");
    clrscr();
    printf("\n\n");
    fprintf(fp,"\n\n");
    printf("How many numbers you want to enter for x  : ");
    fprintf(fp,"How many numbers you want to enter for x  : ");
    scanf("%d",&number);
    fprintf(fp,"%d",number);
    for(i=0;i<number;i++)
    {
        printf("\nEnter value for x(%d)  : ",i);
        fprintf(fp,"\nEnter value for x(%d)  : ",i);
        scanf("%f",&xvalue[i]);
        fprintf(fp,"%f",xvalue[i]);
        printf("\nEnter value for y(%d)  : ",i);
        fprintf(fp,"\nEnter value for y(%d)  : ",i);
        scanf("%f",&yvalue[i]);
        fprintf(fp,"%f",yvalue[i]);
    }
    printf("\nEnter any value of y for which you want to find x : ");
    fprintf(fp,"\nEnter any value of y for which you want to find x : ");
    scanf("%f",&search);
    fprintf(fp,"%f",search);
    for(i=0;i<number;i++)
    {
        product=1;
        for(j=0;j<number;j++)
        {
            if(i!=j)
            {
                product=product*(search-yvalue[j])/(yvalue[i]-yvalue[j]);
            }
        }
        sum=sum+xvalue[i]*product;
    }
    clrscr();
    printf("\n\n\n\n");
    fprintf(fp,"\n\n\n\n");
    printf("LAGRANGE'S INVERSE INTERPOLATION METHOD  ");
    fprintf(fp,"LAGRANGE'S INVERSE INTERPOLATION METHOD  ");
    printf("\n\n");
    fprintf(fp,"\n\n");
    printf("  X      Y   ");
    fprintf(fp,"  X      Y   ");
    printf("\n\n");
    fprintf(fp,"\n\n");
    for(i=0;i<number;i++)
    {
        printf("  %.2f   %.2f   ",xvalue[i],yvalue[i]);
        fprintf(fp,"  %.2f   %.2f   ",xvalue[i],yvalue[i]);
        printf("\n");
        fprintf(fp,"\n");
    }
    printf("\n\n");
    fprintf(fp,"\n\n");
    printf("Interpolated value is  :   %.4f  ",sum);
    fprintf(fp,"Interpolated value is  :   %.4f  ",sum);
    fclose(fp);
    getch();
}

Thursday 11 April 2013

INLINE FUNCLTION IN C++

/*
   ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   :::::  THIS PROGRAM ELOBRATE THE CONCEPT OF INLINE FUNCTION  :::::
   :::::  IN C++ LANGUAGE PUBLIC BY DX PANCHAL AT MCA LAB       :::::
   :::::  ON DATE >11/04/2013                                   :::::
   ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*/
// HEADER FILE DECLATION
#include<iostream.h>
#include<conio.h>
#include<dos.h>
// CLASS DECLARATION

class temp
{
  public:
     int a,b;
     inline int sum(int x,int y)
     {
      a=x;
      b=y;
      return(a+b);
     };


};
// END OF CLASS
void main()
{
   clrscr();
    temp t1;
    cout<<"\n\t\tVALUE FROM INLINR FUNCTION\n\t\t"<<t1.sum(10,20);


   getch();


}

Sunday 7 April 2013

Example of Object as arguments in C++

#include<iostream.h>
#include<conio.h>
#include<dos.h>
class temp
{
  public:
      int a,b,sum;
      void getdata(int x,int y)
      {
       a=x;
       b=y;

      };

      int sum1()
      {
       sum=a+b;
       return(sum);
      };
      void sumobj(temp t1,temp t2);
};

void temp::sumobj(temp t1,temp t2)
{

     int ans1;
     ans1=t1.a+t2.b;
     cout<<"\nt\t\tANSWER FROM OBJECT::>"<<ans1;
};

void main()
{
 int ans;
 clrscr();
 temp t1,t2,t3;
 t1.getdata(10,20);
 t2.getdata(20,10);
 ans=t1.sum1();
 cout<<"\n\t\tYOUR ANSWER::>"<<ans;
 ans=t2.sum1();
 cout<<"\n\t\tYOUR ANSWER::>"<<ans;
 t3.sumobj(t1,t2);

 getch();
}

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...