Wednesday, March 18, 2015

Design or Program for XOR gate in data flow (signal) type using VHDL Code

beh; Internal connections are made using signals.
Signals are defined inside the architecture.

library IEEE;
use IEEE.std_logic_1164.all;
entity my_exor is
port (ip1 : in std_logic;
ip2 : in std_logic;
op1 : out std_logic
);
end my_exor;
architecture exor_w_sig of my_exor is
signal temp1, temp2 : std_logic;
begin
temp1 <= ip1 and (not ip2);
temp2 <= ip2 and (not ip1);
op1 <= temp1 or temp2;
end exor_w_sig;

Design or Program for XOR gate in data flow type using VHDL Code

library IEEE;
use IEEE.std_logic_1164.all;
entity my_exor is
port (ip1 : in std_logic;
ip2 : in std_logic;
op1 : out std_logic
);
end my_exor;

architecture my_exor_beh of my_exor is
begin
op1 <= (ip1 and (not ip2)) or
(ip2 and (not ip1));
end my_exor_beh;

Tuesday, March 17, 2015

program to demonstrate the use of function template. (C plusplus or C++)

Aim: Write a program to demonstrate the use of function template.
Ans:

#include<iostream.h>
#include<conio.h>
template<class T>
void  out(T x[])
{
            int i;
            for( i=0;i<5;i++)
                        cout<<x[i];
                        cout<<"\n";
}
void  main()
{
            int n[10],x;
            char  o[10];
            float  m[10];
            clrscr();
            cout<<"Enter 5 integers values:\n";
            for(int  i=0;i<5;i++)
            {
                        cin>>n[i];
            }
            cout<<"Enter 5 float values:\n";
            for(int j=0;j<5;j++)
            {
                        cin>>m[j];
            }
            cout<<"Enter 5 charcter values:\n";
            for(int k=0;k<5;k++)
            {
                        cin>>o[k];
            }
            cout<<"The output is:\n";
            out(n);
            out(m);
            out(o);
            getch();
}



program to demonstrate the runtime polymorphism. (C plusplus or C++)

Aim: Write a program to demonstrate the runtime polymorphism.
Ans:

#include<iostream.h>
#include<conio.h>
#include<string.h>
class  category
{
char  animal[10],human_being[10];
public:
virtual  void task()
{
cout<<"Enter name of animal:";
cin>>animal;
cout<<"\n";
cout<<"Enter name of human being:";
cin>>human_being;
cout<<"\n";
cout<<"Enter name of animal:";
cin>>animal;
cout<<"\n";
cout<<"Enter name of human being:";
cin>>human_being;
cout<<"\n";
}
};
class  derived :public category
{
char  color[10],body_parts[10],i;
public:
void  task()
{
cout<<"Enter color:";
cin>>color;
cout<<"\n";
cout<<"Enter body parts:";
cin>>body_parts;
cout<<"\n";
cout<<"Enter color:";
cin>>color;
cout<<"\n";
cout<<"Enter body parts:";
cin>>body_parts;
cout<<"\n";
}
};
void  main()
{
clrscr();
category  *p,o;
derived  o1;
p=&o;
p->task();
p=&o1;
p->task();
getch();

}

program to demonstrate the virtual derivation of a class. (C plusplus or C++)

Aim: Write a program to demonstrate the virtual derivation of a class.
Ans:

#include<iostream.h>
#include<conio.h>
class  A
{
protected:
            int x;
public:
            void  a1()
            {
                        clrscr();
                        cout<<"Enter any value\n";
                        cin>>x;
                        cout<<"Double value is  "<<x+x<<"\n\n";
            }
};
class  B:virtual public A
{
public:
            void  b1()
            {
                        cout<<"Enter any value\n";
                        cin>>x;
                        cout<<"Square of number is\n"<<x*x<<"\n\n";
             }
};
class  C:virtual public A
{
public:int y;
            void  c1()
            {
                        y=10;
                        cout<<"Enter any number\n";
                        cin>>x;
                        cout<<"new value after increment is\n"<<x+y<<"\n\n";
            }
};
class  D:public B,public C
{
public:int z;
            void  d1()
            {
                        z=2;
                        cout<<"Enter value\n";
                        cin>>x;
                        cout<<"new value is "<<x-z;
            }
}o1;
void  main()
{
o1.a1();
o1.b1();
o1.c1();
o1.d1();
getch();
}



program to demonstrate the use of multiple inheritance. (C plusplus or C++)

Aim: Write a program to demonstrate the use of multiple inheritance.
Ans:

#include<iostream.h>
#include<conio.h>
class A
{
protected:
            int a;
public:
            void enter()
            {
                        clrscr();
                        cout<<"Enter english marks: \n";
                        cin>>a;
            }
};
class B
{
protected:
            int b;
public:
            void enter1()
            {
                        cout<<"Enter maths marks: \n";
                        cin>>b;
            }
};
class C
{
protected:
            int c;
public:
            void enter2()
            {
                        cout<<"Enter computer marks: \n";
                        cin>>c;
            }
};
class get:public A,public B,public C
{
public:
            int d;
            float e;
            void get1()
            {
                        d=a+b+c;
                        e=d/3;
                        cout<<"Total marks="<<d<<"\n";
                        cout<<"Percentage is="<<e;
            }
}o1;
void main()
{
o1.enter();
o1.enter1();
o1.enter2();
o1.get1();
getch();
}


program to demonstrate the use of multi-level inheritance. (C plusplus or C++)

Aim: Write a program to demonstrate the use of multi-level inheritance.
Ans:

#include<iostream.h>
#include<conio.h>
class  get
{
protected:
            int a,b,c,d,e,f,g;
public:
            void  z()
            {
                        clrscr();
                        cout<<"Enter 5 values:\n";
                        cin>>a>>b>>c>>d>>e;
            }
};
class  addition:public get
{
public:
            void y()
            {
                        f=a+b+c+d+e;
            }
};
class  multiply:public addition
{
public:
            void x()
            {
                        g=a*b*c*d*e;
            }
};
class  display:public multiply
{
public:
            void v()
            {
            cout<<"Addition of values are:\n"<<f<<"\n";
            cout<<"Multiply is:\n"<<g;
            }
}o1;
void  main()
{
o1.z();
o1.y();
o1.x();
o1.v();
getch();
}


program to demonstrate the typecasting of class type to class type. (C plusplus or C++)

 Aim: Write a program to demonstrate the typecasting of class type to class type.
Ans:
#include<iostream.h>
#include<conio.h>
class SUM
{
int a,b,sum;
public:
int get()
{
cout<<"enter values of a&b:";
cin>>a>>b;
sum=a+b;
return(sum);
}
}obj1;

class SUME
{
int sum;
public:
SUME()
{
}
SUME(SUM obj)
{
sum=obj.get();
}
void s()
{
cout<<"sum of no.s is="<<sum;
}
}obj2;
void main()
{
obj2=obj1;
obj2.s();
}


program to demonstrate the typecasting of class type to basic type. (C plusplus or C++)

Aim: Write a program to demonstrate the typecasting  of class type to basic type.
Ans:

#include<iostream.h>
#include<conio.h>
class  A
{
int x,y;
public:
            A()
            {
                        cout<<"Enter the values which you want to add:\n";
                        cin>>x>>y;
            }
operator  int()
            {
                        int z;
                        z=x+y;
                        return(z);
            }
};
void  main()
{
clrscr();
A o;
int k=o;
cout<<"Sum is:"<<k;
getch();
}


program to demonstrate the typecasting of basic to class type . (C plusplus or C++)

 Aim: Write a program to demonstrate the typecasting  of basic to class type .
Ans:
#include<iostream.h>
#include<conio.h>
class  A
{
public:
int z;
A (int sum)
{
            z=sum;
}
void  show()
{
            cout<<"Sum is:"<<z;
}
};
void  main()
{
int  a,b,sum;
clrscr();
cout<<"Enter the values you want to add:\n";
cin>>a>>b;
sum=a+b;
A o1=sum;
o1.show();
getch();

}

program to demonstrate the overloading of binary memory management operator. (C plusplus or C++)

Aim: Write a program to demonstrate the overloading of binary memory management operator.
Ans:
#include<iostream.h>
#include<conio.h>
void main()
{
//Allocates using new operator eory space in meory for storing a integer datatype
clrscr();
int*a=new int;
*a=100;
cout<<"The Output is:a="<<*a;
//Memory Released using delete operator
delete a;
getch();
}



program to demonstrate the overloading of binary arithmetic operator. (C plusplus or C++)

Aim: Write a program to demonstrate the overloading of binary arithmetic operator.
Ans:

#include<iostream.h>
#include<conio.h>
class  A
{
int x,y;
public:
            void  in()
            {

                        cout<<"Enter real and imaginary parts\n";
                        cin>>x>>y;
            }
A operator  +(A obj)
{
            A T;
            T.x=x +obj.x;
            T.y=y +obj.y;
            return(T);
}
void  show()
{
            cout<<"RESULT IS  "<<x<<"+i"<<y;
}
};
void  main()
{
clrscr();
A o1,o2,o3;
o1.in();
o2.in();
o3=o1+o2;
o3.show();
getch();
}



program to demonstrate the overloading of increment and decrement operator. (C plusplus or C++)

Aim: Write a program to demonstrate the overloading of increment and decrement operator.
Ans:

#include<iostream.h>
#include<conio.h>
class  A
{
int x;
public:
            A()
            {
                        x=40;

            }
            void  operator ++()
            {
            x++;
            }
            void  output()
            {
            cout<<x<<"\n";
            }
            };
void  main()
{
clrscr();
cout<<"Initial value of x=40\n\n";
cout<<"New value of x after using operator overloading is:\n";
A o1,o2;
o1++;
o2++;
o2++;
o1.output();
o2.output();
getch();
}




program to demonstrate the use of initializer list? (C plusplus or C++)

Aim: Write a program to demonstrate the use of initializer list ?
Ans.

#include<iostream.h>
#include<conio.h>
class A
{
const int a,b;
public:
            A(int x,int y):a(x),b(y)
            {

            }
            void d()
            {
            cout<<"a="<<a<<"\n"<<"b="<<b;
            }
}obj(10,34);
void main()
{
            clrscr();
            obj.d();
            getch();
}