"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 / rabi

#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[100];
//string s;
gets(s);
int len=strlen(s);
int no;
for(int i=len-1;i>=0;i--)
{
if(i==0)
{
no=i;
while(s[no]!=' ')
{
cout<<s[no];
no++;
//if(s[i]==' ')
//break;
}
}
if(s[i]==' ')
{
no=i+1;
while(s[no]!=' ')
{
cout<<s[no];
no++;
if(s[no]=='' || s[no]==' ')
break;
}
cout<<" ";

}
}
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List the difference between a 'copy constructor' and a 'assignment operator' in C?

630


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3044


What is the use of sizeof?

543


What is operator promotion?

618


What is the explanation for modular programming?

674






What is auto keyword in c?

783


Explain how can I manipulate strings of multibyte characters?

772


What is the difference between arrays and pointers?

625


Explain what will the preprocessor do for a program?

591


How would you use the functions fseek(), freed(), fwrite() and ftell()?

693


What is console in c language?

599


What is oops c?

598


How do you define a string?

649


What is the difference between array and pointer in c?

569


Difference between pass by reference and pass by value?

647