Write a C++ program as per the following instructions:
(i) Write a C++ code which reads the contents of a text file “first_file.txt”
(ii) Write a function named vowel_words() which will segregate the words starting with vowels
from the “first_file.txt”
(iii) Write a C++ code which writes the resultant words to the output file, “second_file.txt”.
Example: Content of first_file – “I am going to buy an umbrella”
Output in second_file.txt – I am an umbrella
1
Expert's answer
2015-07-30T02:22:29-0400
#include <iostream>
using namespace std;
void Sort(int* arr, int size);
int main() {
int array[10];
cout<<"Enter 10 integer values : \n";
for (int i = 0 ; i < 10; i++) cin>>array[i];
cout<<"\nInitial array : ";
for (int i = 0 ; i < 10; i++) cout<<array[i]<<" ";
cout<<endl;
Sort(array, 10);
cout<<"\nArray on ascending order : "; for (int i = 0 ; i < 10; i++) cout<<array[i]<<" ";
cout<<endl;
cin.clear(); cin.ignore(1000, '\n'); cin.get();
return 0; }
void Sort(int* arr, int size) { int tmp;
for(int i = 0; i < size - 1; ++i) // i - number of passes { for(int j = 0; j < size - 1; ++j) // inner loop of passage { if (arr[j + 1] < arr[j]) { tmp = arr[j + 1]; arr[j + 1] = arr[j]; arr[j] = tmp; } } } }
Comments
Leave a comment