Wednesday, September 21, 2016

C++&Java Programming

    Program No : 21

        Constructor and Destructot use:


#include
//#include
class Student
{
    private:
    char*Name;
    int Roll;
    float Marks;
    public:
    Student(Student &S);
    Student(char*,int,float);
    void Show();
};
void Student::Student(char*N,int R,float M)
{
    Name=N;
    Roll=R;
    Marks=M;
}
Student::Student (Student &S)
{
    Name=S.Name;
    Roll=S.Roll;
    Marks=S.Marks;
}
void Student::Show()
{
    cout<<"your name is : "<    cout<<"your Roll is : "<    cout<<"your Marks is : "<}
int main()
{
    Student S1("MD.AL AMIN",766855,88.5);
    cout<<"Record of S1 : "<    S1.Show();
    Student S2=S1;
    cout<<"Record S2 : "<    S2.Show();
    return 0;
}

        Programm No:22


//Overridden Method.

class SuperClass
{
int n;
SuperClass()
n++;
}
public void GetData()
{
System.out.println("It is SuperClass");
System.out.println("n="+n);
}
}

class SubClass extends SuperClass
{
int n;
SubClass()
{
n++;
}
public void GetData()
{
System.out.println("It is SubClass");
System.out.println("n= "+n);
}
}
public class overr
{
public static void main(String args[])
{
SuperClass sp=new SubClss();
sp.GetData();
SubClass sb=new SubClass();
sb.GetData();
}
}



    Programm No: 23




//Overridden Method.

class SuperClass
{
int n;
SuperClass()
n++;
}
public void GetData()
{
System.out.println("It is SuperClass");
System.out.println("n="+n);
}
}

class SubClass extends SuperClass
{
int n;
SubClass()
{
n++;
}
public void GetData()
{
System.out.println("It is SubClass");
System.out.println("n= "+n);
}
}
public class overr
{
public static void main(String args[])
{
SuperClass sp=new SubClss();
sp.GetData();
SubClass sb=new SubClass();
sb.GetData();
}
}



        Program No : 24



#include
//#include
class A
{
public:
    int a,b;
};
class B:public A
{
public :
    int result;
};
class add:publicB
{
public:
    void show();
};
void sdd::show()
{
    cout<<"Enter the value of a,b : ";
    cin>>a>>b;
    result=a+b;
    cout<<"a+b is ="<}
void main()
{
    add obj;
    obj.show();
    getch();
}




        Programm No : 25


public class primei
{
public static void main(String args[])
{
int i,j;
System.out.println("Seris of prime number up to 1000 is ");
for(i=2;i<=1000;i++)
{
for(j=2;j<=i;j++)
{
if(i%j==0)
break;
}
if(i==j)
System.out.println(""+i+"");
}
}
}


This is Content Title

Ours is a developing country. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

No comments: