"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 does main () mean in c?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
How do I read the arrow keys? What about function keys?
Explain goto?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
C program to find all possible outcomes of a dice?
Which driver is a pure java driver
What is the ANSI C Standard?
Explain what is the difference between #include and #include 'file' ?
Distinguish between actual and formal arguments.
What is the use of a semicolon (;) at the end of every program statement?
What is the total generic pointer type?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }