"I LOVE MY COUNTRY"
write a c program to get "COUNTRY MY LOVE I" as the output.
Use any other programming language. It is not mandatory to
use C.
Answer Posted / iravani
#include<iostream>
#include<vector>
using namespace std;
int main()
{
string s,s1;
int n,i,j,k;
vector<string>v,v1;
cin>>n;
getline(cin,s,'\n');
v.push_back(s);
for(i=0;i<n;i++){
getline(cin,s,'\n');
v.push_back(s);
}
for(i=0;i<v.size();i++){
for(j=0;j<v[i].size();j++){
while(v[i][j]!=' ' && j<v[i].size()){
s1+=v[i][j];
j++;
}
v1.push_back(s1);
s1.clear();
}
for(k=v1.size()-1;k>=0;k--){
cout<<v1[k]<<" ";
}
v1.clear();
cout<<endl;
}
u can give input as many string as u want..
| Is This Answer Correct ? | 9 Yes | 5 No |
Post New Answer View All Answers
What is the explanation for cyclic nature of data types in c?
What is include directive in c?
Explain what is the best way to comment out a section of code that contains comments?
What is echo in c programming?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
What are multidimensional arrays?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
What is character set?
how to construct a simulator keeping the logical boolean gates in c
program to convert a integer to string in c language'
What is difference between far and near pointers?
How can you allocate arrays or structures bigger than 64K?
string reverse using recursion
For what purpose null pointer used?
Explain how can I right-justify a string?