"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


Please Help Members By Posting Answers For Below Questions

how to capitalise first letter of each word in a given string?

1424


What is selection sort in c?

596


Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me

1452


What is function what are the types of function?

552


How would you obtain the current time and difference between two times?

719






What do you mean by keywords in c?

614


Write a program to know whether the input number is an armstrong number.

660


How many bytes is a struct in c?

717


What is a volatile keyword in c?

632


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

678


Can i use “int” data type to store the value 32768? Why?

747


What is the use of header files?

590


What is difference between && and & in c?

572


Are pointers integer?

543


Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays

1880