i need to make a program called palindrome.. this will reverse the word/s that you input, like wow, bar crab, when you reverse those word/s you will get the same word/s... my problem is i dont know how make this program..i hope anyone can help me with this...
thank you
How can i make a program in c++ using string.h, conio.h and iostream...?
If u r asking for complete code then we wont give u the code.
I can help u with a simple logic.
u have to make a program of pallandro, in which when u input a string/word, it will tell u wether the given string is pallandrom or not.
here u can do these things ...
1. input a string in a variable say 'a', using cin (for that u have to include iostream.h)
2. reverse the string in the variable a and store it in another string variable say 'b' (for that u have to use string reverse function. u have to include string.h)
3. now compare 'a' %26amp; 'b' string variables. if they r same the input string is Pallandrom, else it is not a pallandrom.
4. including conio.h, u can use clrscr() %26amp; getch(); functions.
Reply:#include %26lt;iostream%26gt;
#include %26lt;string.h%26gt;
using namespace std;
void main()
{
char inputLine[256];
//input the text
cin.getline(inputLine,255);
//reverse the string
_strrev(inputLine);
//output the reversed text
cout %26lt;%26lt; inputLine %26lt;%26lt; endl;
}
Reply:#include %26lt;string.h%26gt;
#include %26lt;conio.h%26gt;
#include %26lt;iostream.h%26gt;
private string (variable name);
{
insert your programme code here
}
Reply:Why do you want to use conio.h? And why do you want to use old style C++ header files?
Here is what I would start with:
#include %26lt;string%26gt;
#include %26lt;iostream%26gt;
using namespace std;
string reverseWord(string %26amp; s) {
//do something here
}
int main(void) {
//read in the string
string s;
cin %26gt;%26gt; s;
//reverse s using your function and output the result
return 0;
}
This page may be useful for you as a general C/C++ reference:
http://www.cppreference.com/index.html
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment