"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 ? | 8 Yes | 5 No |
Post New Answer View All Answers
how to capitalise first letter of each word in a given string?
What is selection sort in c?
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
What is function what are the types of function?
How would you obtain the current time and difference between two times?
What do you mean by keywords in c?
Write a program to know whether the input number is an armstrong number.
How many bytes is a struct in c?
What is a volatile keyword in c?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
Can i use “int” data type to store the value 32768? Why?
What is the use of header files?
What is difference between && and & in c?
Are pointers integer?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays