Category : while-loop

I wrote a programme to convert infix expression into postfix but with this lines of code my programme exit without showing any output. while((precedence(infix[i])<=precedence(s.top())) && (!s.empty())) { postfix+=s.top(); s.pop(); } About code—> here s is the object of stack and precendence is a function which return 3 for ^ 2 for * and / 1 ..

Read more

#include <iostream> #include <string> #include <cstring> using namespace std; int main() //geting input part { string wantedWord, name1, name2; cout<<"Player one, please enter your name: "; cin >> name1; cout<<"Player two, please enter your name: "; cin >> name2; cout << "OK " << name1 << " and "<< name2<<". Let’s start the game!/n"; cout ..

Read more

I am a beginner at coding and learning C++. I just wrote a code that asks the user to log in, Register, or exit. I thought doing it through functions would be easier. While checking for the constraints of the username and password for registration(referred to as "Rusr" and "Rpwd" here) the code I’ve written ..

Read more

The following code is suppose to grab the first word of a sentence (if there’s one) and print it letter by letter (The printing part works). The problem that I’ve encountered is that whenever I input a sentence in the prompt, it grabs every word in the sentence and not the first word (cin is ..

Read more