Classes With Arrays As Data Members OOPS programming in c++ how to implement Classes with array

In these Source code algorithm it has class student and there fucniton get () and total(). It will get the data by through array from the user input for OOPS programming. CS 2209-object Oriented Programming
Source Code programming algorithm in c++ CS 2209
#include<iostream.h>
#include<conio.h>
class student
{
char name[30];
int m[5],i,sum;
float avg;
public:
void get();
void total();
void average();
};
void student::get()
{
cout<<"\nEnter a Name : ";
cin>>name;
cout<<"\nEnter the 5 marks : ";
for(i=0;i<5;i++)
{
cin>>m[i];
}
}
void student::total()
{
for(i=0;i<5;i++)
{
sum+=m[i];
}
cout<<"\nSum is "<<sum;
}
void student::average()
{
avg=sum/5;
cout<<"\nAverage is "<<avg;
}
void main()
{
clrscr();
student JJ;
JJ.get();
JJ.total();
JJ.average();
getch();
}
OUTPUT CS 2209 OOPS programming
Enter a Name : STUDENTWEBSITE
Enter the 5 marks :
100
99
95
80
100
Sum is 474
Average is 94.8
Read More>>>

Classes With Primitive Data Members in OOPS in c++ how to implment Class Primitve Data Member

In these primitive data Member we use the void AREA::circle(int r) , void AREA::rectangle(int l,int b) function by using these function we can implement Classes with primitive Data Members in C++ programming OOPS
Source code in c++ Programming OOPS
#include<iostream.h>
#include<conio.h>
#define pi 3.14
class AREA
{
int area1,area2;
public:
void circle(int r);
void rectangle(int l,int b);
};
void AREA::circle(int r)
{
area1=pi*r*r;
cout<<"AREA OF THE CIRCLE : "<<area1;
}
void AREA::rectangle(int l,int b)
{
area2=l*b;
cout<<"AREA OF THE RECTANGLE : "<<area2;
}
void main()
{
int r,l,b;
clrscr();
AREA JJ;
cout<<"\nEnter the radius of the circle : ";
cin>>r;
JJ.circle(r);
cout<<"\n\nEnter the length & breadth of the rectangle : ";
cin>>l>>b;
JJ.rectangle(l,b);
getch();
}

OUTPUT c++ programming for oops
Enter the radius of the circle : 7
AREA OF THE CIRCLE : 153
Enter the length & breadth of the rectangle : 15 7
AREA OF THE RECTANGLE : 105
Read More>>>

Call By Address Using Pointer To pefrom Swap operation in c ++

call by address Object oriented Porgramming in c++
#include<iostream.h>
#include<conio.h>
void swap(int *x,int *y)Call By Address Using Pointer To pefrom Swap operation in c ++
{
int temp;
temp=*x;
*x=*y;
*y=*temp;
cout<<"\n The value of a and b in swap fun is\t "<<*x<<"\t"<<*y;
}
void main()
{
int a,b;
clrscr();
cout<<"\n Enter the value of a and b:\n";
cin>>a>>b;
cout<<"\n The value of a and b before the swap fun is:\t"<<a<<"\t"<<b;
swap(&a,&b);
cout<<"\n\n The value of a and b after the swap fun is:\t"<<a<<"\t"<<b;
getch();
}
OUTPUT call by address by C programming
Enter the value of a and b:
6
8
The value of a and b before the swap fun is: 6 8
The value of a and b in swap fun is: 8 6
The value of a and b after the swap fun is: 6 8
Read More>>>

CALL BY REFERENCE To Perform The Swap Operation in c++ programming

Object Orient programming lap in c ++
Source Code call by reference in C programming
#include<iostream.h>
#include<conio.h>
void swap(int &x,int &y)CALL BY REFERENCE To Perform The Swap Operation in c++  programming
{
int temp;
temp=x;
x=y;
y=temp;
cout<<"\n The value of a and b in swap fun is\t "<<x<<"\t"<<y;
}
void main()
{
int a,b;
clrscr();
cout<<"\n Enter the value of a and b:\n";
cin>>a>>b;
cout<<"\n The value of a and b before the swap fun is:\t"<<a<<"\t"<<b;
swap(a,b);
cout<<"\n\n The value of a and b after the swap fun is:\t"<<a<<"\t"<<b;
getch();
}
OUTPUT Call by Reference Programming algorithm
Enter the value of a and b:
4
3
The value of a and b before the swap fun is:4 3
The value of a and b in swap fun is: 3 4
The value of a and b after the swap fun is:4 3

Read More>>>

How to preform Swap using CALL BY VALUE fucntion in c c++

First get the input from the user then using call by value function pass the value with three variable we performing swap process in object oriented programming .
Source code call by value swap programming algorithm in c c++
#include<iostream.h>
#include<conio.h>
void swap(int x,int y)
{
int temp;
temp=x;
x=y;
y=temp;
cout<<"\n The value of a and b in swap fun is\t "<<x<<"\t"<<y;
}
void main()
{
int a,b;
clrscr();
cout<<"\n Enter the value of a and b:\n";
cin>>a>>b;
cout<<"\n The value of a and b before the swap fun is:\t"<<a<<"\t"<<b;
swap(a,b);
cout<<"\n\n The value of a and b after the swap fun is:\t"<<a<<"\t"<<b;
getch();
}
OUTPUT swap fucniton call by value in c++ programming
Enter the value of a and b:
7
2
The value of a and b before the swap fun is: 7 2
The value of a and b in swap fun is: 2 7
The value of a and b after the swap fun is: 7
Read More>>>

How To Find Volume Of Rectangle Using Default Argument in c c++

Object Oriented Programming default argument refers to without getting input from the user to pass the value to and perform the process in these default argument we use the function name volume with passing three argument in c c++
Source Code programming Default Argument | CS 2209 – OBJECT ORIENTED PROGRAMMING LAB
#include<iostream.h>
#include<conio.h>
void volume(int l=10,int b=20,int h=15);
void volume(int l,int b,int h)
{
int vol;
vol=l*b*h;
cout<<"\n\nVOLUME OF RECTANGLE IS:\t"<<vol;
}

void main()
{
clrscr();
cout<<"\n\n When length, breadth, height are default arguments";
volume();
cout<<"\n\n When breadth, height are default arguments";
volume(90);
cout<<"\n\n When height is default argument";
volume(20,15);
cout<<"\n\n When No default arguments";
volume(20,20,10);
getch();
}
OUTPUT object oriented programming in c c++
When length, breadth, height are default arguments
VOLUME OF RECTANGLE IS: 3000
When breadth, height are default arguments
VOLUME OF RECTANGLE IS: 27000
When height is default argument
VOLUME OF RECTANGLE IS: 20000
When No default arguments
VOLUME OF RECTANGLE IS: 4000
Read More>>>

QUICK SORT Data Structure lab programming Algorithm Quick Sort

Quick sort Programming Source code it has the header file quick.h it contains void swap(int *x,int *y),void display(int A[],int n),void insertionsort(int A[],int n),int median(int A[],int left,int right),void quicksort(int A[],int left,int right) by using these function and there variable we can use in the main function of the program
“Quick.h” file
QUICK SORT Data Structure lab programming Algorithm in c / c++
QUICK SORT Data Structure lab programming Algorithm Quick Sort
#include<stdio.h>
#include<conio.h>
#define cutoff (3)
void swap(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
void display(int A[],int n)
{
int i;
for(i=0;i<n;i++)
printf("%d\t",A[i]);
}
void insertionsort(int A[],int n)
{
int j,p,temp;
for(p=1;p<n;p++)
{
temp=A[p];
for(j=p;j>0&&A[j-1]>temp;j--)
A[j]=A[j-1];
A[j]=temp;
}
}
int median(int A[],int left,int right)
{
int center=(left+right)/2;
if(A[left]>A[center])
swap(&A[left],&A[center]);
if(A[left]>A[right])
swap(&A[left],&A[right]);
if(A[center]>A[right])
swap(&A[center],&A[right]);
if(A[left]<=A[center]<=A[right])
swap(&A[center],&A[right-1]);
return A[right-1];
}
void quicksort(int A[],int left,int right)
{
int i,j,pivot;
if(left+cutoff<=right)
{
pivot=median(A,left,right);
i=left;
j=right-1;
for(;;)
{
while(A[++i]<pivot)
{}
while(A[--j]>pivot)
{}
if(i<j)
swap(&A[i],&A[j]);
else
break;
}
swap(&A[i],&A[right-1]);
quicksort(A,left,i-1);
quicksort(A,i+1,right);
}
else
insertionsort(A+left,right-left+1);
}
“Quick.c” file
QUICK SORT Data Structure lab programming Algorithm in c c++
#include"quick.h"
void main()
{
int A[20],n,i;
clrscr();
printf("\n how many numbers do u want to sort:\t");
scanf("%d",&n);
printf("\n\n Enter the values");
for(i=0;i<n;i++)
{
printf("\n A[%d]\t",i);
scanf("%d",&A[i]);
}
quicksort(A,0,n-1);
display(A,n);
getch();
}
OUTPUT
QUICK SORT Data Structure lab Output in c c++
How many numbers do u want to sort: 5
Enter the values
A[0] 25
A[1] 10
A[2] 89
A[3] 65
A[4] 15
10 15 25 65 89
Read More>>>