Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahil624 committed Mar 9, 2017
0 parents commit 81ebfa8
Show file tree
Hide file tree
Showing 160 changed files with 2,995 additions and 0 deletions.
4 changes: 4 additions & 0 deletions + overloading.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#inculde<iostresam>
using namespace std

class
Binary file added 1
Binary file not shown.
39 changes: 39 additions & 0 deletions 1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include<iostream>
#include<string.h>
using namespace std;
class data
{
char *a;
public:
data(char *b)
{
a= new char(strlen(b)+1);
strcpy(a,b);
}
void show()
{
a[0]=a[0]-32;
cout<<"\n"<<a;
}
void compare(data d2)
{
if(strcmp(d2.a,a))
cout<<"\nBoth Objects have different text";
else
cout<<"\nBoth Objects have same text";
}

};




int main()
{
data d1("obfuscation");
data d2("obstruction");
d1.show();
d2.show();
d1.compare(d2);
return 0;
}
Binary file added 1.exe
Binary file not shown.
Binary file added 1.o
Binary file not shown.
Binary file added 2d array using pointer
Binary file not shown.
60 changes: 60 additions & 0 deletions 2d array using pointer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include<iostream>
using namespace std;

/******************************************************** Class ********************************************************/


class matrix
{
int **ptr;
int d1,d2;

public:
matrix (int x,int y)
{
d1=x;
d2=y;
ptr = new int *[d1];
for(int i=0; i<d1; i++)
{
ptr[i]=new int[d2];
}
}

void getval(int i,int j,int val)
{
ptr[i][j]=val;
}

int & putval(int i,int j)
{
return (ptr[i][j]);
}
};

/******************************************************** Main ********************************************************/


int main()
{
int m,n,value;

cout<<"Enter size of matrix";
cin>>m>>n;

matrix A(m,n);

cout<<"Enter elements of matrix";

for(int i=0; i<m; i++)
{
for(int j=0; j<n; j++)
{
cin>>value;
A.getval(i,j,value);
}
}

cout<<"\n"<<A.putval(1,1);
return 0;
}
Binary file added 2d array using pointer.o
Binary file not shown.
Binary file added Link to time overloaded.cpp
Binary file not shown.
21 changes: 21 additions & 0 deletions Untitled2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include<iostream>
using namespace std;

class arr{
public:

int insert(int *ptr,int pos,int n,int num){
int temp[100],j;
for(int i=0;i<n+1;i++){
if(i==pos){
temp[i]=num;
j--;
}

temp[i]=arr[j];
j++;
}
}

void
};
Binary file added age calc
Binary file not shown.
49 changes: 49 additions & 0 deletions age calc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include<iostream>
using namespace std;
class persondata{
int birthmonth,birthyear;
float cm,meters;
int currentmonth,currentyear;
int agey,agem;

public:

void getdata(){
cout<<"Enter Your Birth Year:";
cin>>birthyear;
cout<<"\nEnter Your Birth Month:";
cin>>birthmonth;
cout<<"\nEnter The Current Month:";
cin>>currentmonth;
cout<<"\nEnter The Current Year:";
cin>>currentyear;
cout<<"\nEnter Your Height in Meters:";
cin>>meters;
}

void calc(){
int m;
cm=meters*100;
agey=currentyear-birthyear;
m=currentmonth-birthmonth;
if(m<0){
agey=currentyear-birthyear+m;
agem=12+m;}

}

void putdata(){
cout<<"\nYour Age is "<<agey<<" Years And "<<agem<<" Months and Height in Centimeter is "<<cm;
}
};

int main()
{
persondata per;
per.getdata();
per.calc();
per.putdata();


return 0;
}
Binary file added age calc.exe
Binary file not shown.
Binary file added age calc.o
Binary file not shown.
48 changes: 48 additions & 0 deletions arr sort in cls.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include<iostream>
using namespace std;

class ptr{
int arr[100];
public :

void getarr(int n){
for(int i;i<n;i++){
cin>>arr[i];
}
}

void sort (int n){
int temp=0;

for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if (arr[j]>arr[j+1]){
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}

}

void putarr(int n){
for(int i;i<n;i++){
cout<<arr[i];
}
}
};

int main(){
ptr obj;
int n;

cout<<"Enter the no elements"<<endl;
cin>>n;

obj.getarr(n);
obj.sort(n);
obj.putarr(n);

}

Binary file added arr sort in cls.exe
Binary file not shown.
Binary file added array in class
Binary file not shown.
67 changes: 67 additions & 0 deletions array in class.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include<iostream>
using namespace std;
int i=0;
class ary
{
int arr[10];
int size;
public:
ary();
ary(int n);
void showdata();
friend ary operator +(ary,ary);
};

ary::ary()
{
for(i=0; i<10; i++)
{
arr[i]=0;
}
size=0;
}

ary::ary(int n)
{
for(i=0; i<n; i++)
{
cin>>arr[i];
size=n;
}
}

void ary:: showdata()
{
// cout<<"\n------------------"<<size<<"------------------\n"<<endl;
for(i=0; i<size; i++)
{
cout<<arr[i]<<endl;
}
}

ary operator +(ary a1,ary a2)
{
ary temp;
temp.size=a1.size;
int i;
for(i=0; i<a1.size; i++)
{
temp.arr[i]=a1.arr[i]+a2.arr[i];
//cout<<"Temp\t\t"<<temp.arr<<endl;
}
return temp;
}

int main()
{
int n;
cout<<"Enter Size"<<endl;
cin>>n;

ary A(n),B(n),C;
C=A+B;

cout<<"The final Array is:"<<endl;

C.showdata();
}
Binary file added array in class.o
Binary file not shown.
Binary file added binary operator overloading
Binary file not shown.
52 changes: 52 additions & 0 deletions binary operator overloading.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include<iostream>
using namespace std;

class complex
{
float real,img;

public:

complex()
{
real=0;
img=0;
}

complex(float x,float y)
{
real=x;
img=y;
}

complex operator +(complex);

void display()
{
cout<<real<<"+"<<img<<"i"<<endl;
}
};

complex complex:: operator +(complex a)
{
complex temp;
temp.real=real+a.real;
temp.img=img+a.img;
// cout<<a.real<<"*******"<<endl;
return temp;
}

int main()
{
complex c1(12.5,22.6),c2(36.4,12.5);

complex c3;

c3=c1+c2;

c1.display();
c2.display();
c3.display();

return 0;
}
Binary file added binary operator overloading.o
Binary file not shown.
Binary file added celcius to ferenheight
Binary file not shown.
43 changes: 43 additions & 0 deletions celcius to ferenheight.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include<iostream>
using namespace std;

class faran{
float fr;

public:
faran(int fff=50){
fr =fff;
}


float getval(){
return fr;
}
};

class celc{
float cl;

public:

celc();

celc(faran f){
//cout<<f.getval();
cl=((f.getval() - 32) * .5555556);
}

void showdata(){
cout<<cl<<"degree celcius";
}


};


int main(){
faran f;
celc c(f);

c.showdata();
}
Binary file added celcius to ferenheight.o
Binary file not shown.
Loading

0 comments on commit 81ebfa8

Please sign in to comment.