मराठी
महाराष्ट्र राज्य शिक्षण मंडळएचएससी विज्ञान (संगणक विज्ञान) इयत्ता १२ वी

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×