Skip to content

Commit

Permalink
String introcution
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed Jul 3, 2018
1 parent aaf8a8b commit 8ceda6d
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 4 deletions.
3 changes: 0 additions & 3 deletions array/io.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* array declaration + initialization from keyboard
*/

#include<iostream>
#include<stdlib.h>
#include<iomanip>
Expand Down
38 changes: 38 additions & 0 deletions array/selection-sort.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* selection sort algorithm
made by :
*/
#include<iostream>
#include "io.cpp"
using namespace std;
void selection_sort(int x[] ,int n)
{
int i,j,low,pos,temp;
for(i=0;i<n;i++)
{
low = x[i];
pos = i;
for(j=i+1;j<n;j++){
if(x[j]>low)
{
low = x[j];
pos= j;
}
}
temp = x[i];
x[i]= x[pos];
x[pos]= temp;

}
}


int main()
{
int x[10];
input(x,10);
selection_sort(x,10);
cout<<"\n sorted Array :";
output(x,10);
return 0;
}

1 change: 0 additions & 1 deletion demo.txt

This file was deleted.

12 changes: 12 additions & 0 deletions string/string.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<iostream>
using namespace std;
int main()
{
char string[100];
int i;
for(i=0;i<10;i++)
cin>>string[i];
string[10]='\0';
cout<<"\n Entered String :"<<string;
return 0;
}
9 changes: 9 additions & 0 deletions string/string1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<iostream>
using namespace std;
int main()
{
char string[100];
cin>>string;
cout<<"\n Entered String :"<<string;
return 0;
}
9 changes: 9 additions & 0 deletions string/string2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<iostream>
using namespace std;
int main()
{
char string[100];
cin.getline(string,100,'#');
cout<<"\n Entered String :"<<string;
return 0;
}
9 changes: 9 additions & 0 deletions string/string3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<iostream>
using namespace std;
int main()
{
char string[100];
gets(string);
cout<<"\n Entered String :"<<string;
return 0;
}
14 changes: 14 additions & 0 deletions string/string_Copy_function.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char string1[100]="This is me";
char string2[100];

//string2 = string1;

strcpy(string2, string1);
cout<<"Copied String :"<<string2;
return 0;
}
9 changes: 9 additions & 0 deletions string/string_out.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<iostream>
using namespace std;
int main()
{
char string[100]="This is me ";

cout<<"\n Entered String :"<<string;
return 0;
}
14 changes: 14 additions & 0 deletions string/string_out_charwise.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<iostream>
using namespace std;
int main()
{
char string[100]="This is me ";
int i=0;
while(string[i]!='\0')
{
cout<<string[i];
i++;
}

return 0;
}
9 changes: 9 additions & 0 deletions string/string_out_write.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<iostream>
using namespace std;
int main()
{
char string[100]="This is me ";
cout.write(string,5);

return 0;
}
16 changes: 16 additions & 0 deletions string/string_out_write_triangle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include<iostream>
using namespace std;
int main()
{
char string[100]="ProgrammingFun";
int i;
for(i=1;i<=14;i++)
{ cout.write(string,i);
cout<<endl;
}
for(i;i>=1;i--)
{ cout.write(string,i);
cout<<endl;
}
return 0;
}
23 changes: 23 additions & 0 deletions string/string_output_function.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char string[100];
int i;
cin.getline(string,100);

int n = strlen(string);

cout<<"\n Size of string :"<<n<<endl;

for(i=1;i<=n;i++)
{ cout.write(string,i);
cout<<endl;
}
for(i=i-1;i>=1;i--)
{ cout.write(string,i);
cout<<endl;
}
return 0;
}

0 comments on commit 8ceda6d

Please sign in to comment.