हिंदी

Write a C++ Program to Accept a Sentence (Maximum 50 Characters) and Print the Sentence in Reverse - Computer Science 1

Advertisements
Advertisements

प्रश्न

Write a C++ program to accept a sentence (maximum 50 characters) and print the sentence in reverse.

संक्षेप में उत्तर

उत्तर

 //Reverse a string
#include
void main ( )
{
char str [50], reverse [50];
int len, i, k;
cout << “Enter a string :” <<endl;
cin>>str;
for (i = 0; str [i]! = ‘\0’ ; i++)
len = i;
len - -;
for (k = 0; len >=0; len - -, k++)
reverse [k] = str [len];
reverse [k] = ‘\0’;
cout <<“reverse string is :”;
cout <<reverse;

shaalaa.com
C++ Programming
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2018-2019 (February) Set 1
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×
Our website is made possible by ad-free subscriptions or displaying online advertisements to our visitors.
If you don't like ads you can support us by buying an ad-free subscription or please consider supporting us by disabling your ad blocker. Thank you.