"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 / aniket singh

#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(){
string str= "I love my country india";
string temp;
int st=0,i;

for(i=0;i<=str.size();i++){
if(str[i]==' '||str[i]==''){

temp = str.substr(st,(i-1)-st+1) + ' ' + temp;
st=i+1;
}
}
cout<<temp<<endl;
return 0;
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the standard predefined macros?

627


Write a Program to find whether the given number or string is palindrome.

605


‎How to define structures? · ‎

616


Is file a keyword in c?

492


Explain modulus operator. What are the restrictions of a modulus operator?

595






Explain how can you tell whether a program was compiled using c versus c++?

569


What is the use of typedef in c?

577


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1207


How can I split up a string into whitespace-separated fields?

562


Give differences between - new and malloc() , delete and free() ?

601


Explain how can I open a file so that other programs can update it at the same time?

582


Can main () be called recursively?

620


Why is c called c not d or e?

600


Is stack a keyword in c?

628


What is the use of pragma in embedded c?

583