"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
Explain what is the concatenation operator?
What is static and auto variables in c?
how to write a c program to print list of fruits in alpabetical order?
how should functions be apportioned among source files?
Explain that why C is procedural?
Explain the difference between the local variable and global variable in c?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
What is the sizeof () operator?
How do I determine whether a character is numeric, alphabetic, and so on?
Which is the memory area not included in C program? give the reason
What is the best way to comment out a section of code that contains comments?
Explain what is output redirection?
What is register variable in c language?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
Why & is used in scanf in c?