-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d28a548
commit cb59491
Showing
16 changed files
with
326 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
This is my first attempt in c++ | ||
hello world | ||
thiis is my third line | ||
and fourth line | ||
and fifth line | ||
and | ||
so | ||
on | ||
this ia again | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// program to create duplicate of sameer.txt file | ||
#include<iostream> | ||
#include<fstream> | ||
using namespace std; | ||
int main() | ||
{ | ||
ifstream object; | ||
ofstream object1; | ||
char ch; | ||
object.open("sameer.txt"); // member function of ofstream class | ||
object1.open("PRN"); | ||
while(!object.eof()) | ||
{ | ||
object.get(ch); | ||
object1<<ch; | ||
} | ||
object.close(); //member function of ofstream class | ||
object1.close(); | ||
|
||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include<iostream> | ||
#include<fstream> | ||
using namespace std; | ||
int main() | ||
{ | ||
ifstream object; | ||
char ch; | ||
object.open("sameer.txt"); // member function of ofstream class | ||
while(!object.eof()) | ||
{ | ||
object.get(ch); | ||
cout<<ch; | ||
} | ||
object.close(); //member function of ofstream class | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include<iostream> | ||
#include<fstream> | ||
using namespace std; | ||
int main() | ||
{ | ||
ofstream object; | ||
object.open("sameer.txt",ios::app); // file modes | ||
object<<"hello world"; | ||
object.close(); //member function of ofstream class | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include<iostream> | ||
#include<fstream> | ||
using namespace std; | ||
int main() | ||
{ | ||
ofstream object; | ||
object.open("sameer.txt"); // member function of ofstream class | ||
object<<"hello world"; | ||
object.close(); //member function of ofstream class | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include<iostream> | ||
#include<fstream> | ||
using namespace std; | ||
int main() | ||
{ | ||
ifstream object; | ||
char str[900]; | ||
object.open("sameer.txt"); // member function of ofstream class | ||
object>>str; | ||
cout<<str; | ||
object.close(); //member function of ofstream class | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include<iostream> | ||
#include<fstream> | ||
using namespace std; | ||
int main() | ||
{ | ||
ifstream object; | ||
char str[900]; | ||
object.open("sameer.txt"); // member function of ofstream class | ||
object.getline(str,900); // read a line | ||
cout<<str; | ||
object.getline(str,900); // read a line | ||
cout<<str; | ||
object.close(); //member function of ofstream class | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// program to remove multiple spaces from the text file | ||
#include<iostream> | ||
#include<fstream> | ||
using namespace std; | ||
int main() | ||
{ | ||
ifstream object; | ||
char ch; | ||
int count =0; | ||
object.open("sameer.txt"); // member function of ofstream class | ||
while(!object.eof()) | ||
{ | ||
object.get(ch); | ||
if(ch==' ') | ||
count++; | ||
else | ||
count=0; | ||
if(count<=1) | ||
cout<<ch; | ||
} | ||
object.close(); //member function of ofstream class | ||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This my first attempt in c++ | ||
hello world | ||
thiis is my third line | ||
and fourth line | ||
and fifth line | ||
and | ||
so | ||
on | ||
this ia again |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* array declaration + initialization method | ||
*/ | ||
|
||
#include<iostream> | ||
#include<stdlib.h> | ||
#include<iomanip> | ||
|
||
#define random(num) rand()%num | ||
|
||
using namespace std; | ||
int main(){ | ||
int a[10]={10,20,30,40,60}; | ||
|
||
// output phase | ||
for(int i=0;i<10;i++) | ||
cout<<setw(10)<<a[i]; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* array declaration + initialization from keyboard | ||
*/ | ||
|
||
#include<iostream> | ||
#include<stdlib.h> | ||
#include<iomanip> | ||
|
||
using namespace std; | ||
int main(){ | ||
int a[10]; | ||
int i; | ||
//input phase | ||
for(i=0;i<10;i++) | ||
{ | ||
cout<<"\n Enter a["<<i+1<<"] number "; | ||
cin>>a[i]; | ||
} | ||
|
||
//processing phase | ||
int sum =0; | ||
for(i=0;i<10;i++) | ||
sum = sum+a[i]; | ||
|
||
// output phase | ||
cout<<"\n Entered array :"; | ||
for(i=0;i<10;i++) | ||
cout<<setw(10)<<a[i]; | ||
cout<<"\n Sum of all elements :"<<sum; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* array declaration + initialization from keyboard | ||
*/ | ||
|
||
#include<iostream> | ||
#include<stdlib.h> | ||
#include<iomanip> | ||
|
||
using namespace std; | ||
|
||
int fun_add(int a){ | ||
a = a+10; | ||
return(a); | ||
} | ||
|
||
int main(){ | ||
int a[10]; | ||
int i; | ||
|
||
//input phase | ||
for(i=0;i<10;i++) | ||
{ | ||
cout<<"\n Enter a["<<i+1<<"] number "; | ||
cin>>a[i]; | ||
} | ||
|
||
//processing phase | ||
|
||
for(i=0;i<10;i++) | ||
a[i] = fun_add(a[i]); | ||
|
||
// output phase | ||
|
||
cout<<"\n Modified array :"; | ||
for(i=0;i<10;i++) | ||
cout<<setw(10)<<a[i]; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* array declaration + initialization from keyboard | ||
*/ | ||
|
||
#include<iostream> | ||
#include<stdlib.h> | ||
#include<iomanip> | ||
|
||
using namespace std; | ||
|
||
void fun_add(int a[10]){ | ||
int i; | ||
for(i=0;i<10;i++) | ||
a[i] = a[i]+10; | ||
|
||
} | ||
|
||
int main(){ | ||
int a[10]; | ||
int i; | ||
|
||
//input phase | ||
for(i=0;i<10;i++) | ||
{ | ||
cout<<"\n Enter a["<<i+1<<"] number "; | ||
cin>>a[i]; | ||
} | ||
|
||
//processing phase | ||
|
||
fun_add(a); | ||
|
||
// output phase | ||
|
||
cout<<"\n Modified array :"; | ||
for(i=0;i<10;i++) | ||
cout<<setw(10)<<a[i]; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* array declaration + initialization from keyboard | ||
*/ | ||
|
||
#include<iostream> | ||
#include<stdlib.h> | ||
#include<iomanip> | ||
|
||
using namespace std; | ||
int main(){ | ||
int a[10]; | ||
int i; | ||
//input phase | ||
for(i=0;i<10;i++) | ||
{ | ||
cout<<"\n Enter a["<<i+1<<"] number "; | ||
cin>>a[i]; | ||
} | ||
|
||
//processing phase | ||
|
||
for(i=0;i<10;i++) | ||
a[i]+=10; //shortand operator a[i] = a[i]+10 | ||
|
||
|
||
// output phase | ||
|
||
cout<<"\n Modified array :"; | ||
for(i=0;i<10;i++) | ||
cout<<setw(10)<<a[i]; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* array declaration + initialization from keyboard | ||
*/ | ||
|
||
#include<iostream> | ||
#include<stdlib.h> | ||
#include<iomanip> | ||
|
||
using namespace std; | ||
int main(){ | ||
int a[10]; | ||
int i; | ||
//input phase | ||
for(i=0;i<10;i++) | ||
{ | ||
cout<<"\n Enter a["<<i+1<<"] number "; | ||
cin>>a[i]; | ||
} | ||
|
||
//processing phase | ||
int sum =0; | ||
for(i=0;i<10;i++) | ||
sum = sum+a[i]; | ||
|
||
// output phase | ||
cout<<"\n Entered array :"; | ||
for(i=0;i<10;i++) | ||
cout<<setw(10)<<a[i]; | ||
cout<<"\n Sum of all elements :"<<sum; | ||
return 0; | ||
} |