Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,332 members, 7,808,121 topics. Date: Thursday, 25 April 2024 at 07:29 AM

C++ Thread For Beginners - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / C++ Thread For Beginners (2955 Views)

Thread For Nairaland Algorithm Questions / Thread For International Remote Tech Jobs - US, UK, Canada, Germany, UAE... / A Thread For Tutorial On Python Programming (2) (3) (4)

(1) (2) (Reply) (Go Down)

Re: C++ Thread For Beginners by Nobody: 11:57am On Oct 18, 2017
supervillain52:
(Facepalm)
you know what nevermind
This thread was made for beginners...your wahala ain't needed.
Re: C++ Thread For Beginners by Nobody: 11:59am On Oct 18, 2017
supervillain52:
u use ideone.com to test your codes right
I have a compiler on my system but when surfing the net i use that site. If you have problem with it, deal with it.
Re: C++ Thread For Beginners by Nobody: 12:01pm On Oct 18, 2017
supervillain52:
Backslides out of thread
Mtcheeeeeew undecided
Re: C++ Thread For Beginners by supervillain52(m): 12:05pm On Oct 18, 2017
TobiTobiTobiWhy:
Mtcheeeeeew undecided
Nice to meet me you too
Re: C++ Thread For Beginners by Nobody: 12:07pm On Oct 18, 2017
supervillain52:
Nice to meet me you too
cheesy grin mtcheeeeeew undecided
Re: C++ Thread For Beginners by Nobody: 12:09pm On Oct 18, 2017
TobiTobiTobiWhy:
Welcome bro, just what i was thinking.


CHALLENGE 1: CALCULATOR v1


Write a program that helps us calculate addition and subtraction of two given input.


EG. USER chooses an operator like addition (+) then input two numbers like 1 and 3. The computer processes the input and give us 4.


You can write the code on http://ideone.com and share the link.

#include <iostream>
using namespace std;

int main() {
//declare variables
char op;
int x;
int y;
cout <<"Choose operator, eg + or - "<<endl;
cin>>op;
//collect data
cout <<"Enter first digit:"<<endl;
cin>>x;
cout <<"Enter second digit:"<<endl;
cin>>y;
//using switch loop to check op
switch(op) {
case '+' :
cout<< x+y;
break;
case '-' :
cout << x-y;
break;
default:
cout << "Wrong operation, try again";
exit(1);
}
return 0;
}
Re: C++ Thread For Beginners by Nobody: 12:21pm On Oct 18, 2017
TobiTobiTobiWhy:
lol what'syour point There are lots of c++ library to achieve great gui

check out:

*MFC

*COCOA

*QT

*wxWidgets

*JUCE


so your point


Add
C++ builder

1 Like

Re: C++ Thread For Beginners by Nobody: 12:33pm On Oct 18, 2017
proxy20:


Add C++ builder
Thanks, i'll check that out.

1 Like

Re: C++ Thread For Beginners by Nobody: 1:52pm On Oct 18, 2017
Re: C++ Thread For Beginners by ibromodzi: 2:54pm On Oct 18, 2017
TobiTobiTobiWhy:
@ibromodzi,
Great code brother, it worked. I would have replied earlier but i was banned.

I used the code to calculate 5-9 and it gave the right answer.

https://ideone.com/5Mb9CY
SUGGESTION: Try replace a and s with + and - respectively.
Thanks..

1 Like

Re: C++ Thread For Beginners by ibromodzi: 2:58pm On Oct 18, 2017
excanny:

Any one for Windows Desktop?
Try code block
Re: C++ Thread For Beginners by Nobody: 3:05pm On Oct 18, 2017
ibromodzi:


Thanks..
Welcome. Lets try something else....may our efforts pay off




CHALLENGE #2: HANGMAN GAME


Let us create a simple text-based hangman game without gui.

*FEATURES*

- The word NI___IA(NIGERIA) is guessed.
- Game should be one player.
- Program should count number of guesses.
- If guesses=5, game over.
- If all is correct, game won.



Oya grin
Re: C++ Thread For Beginners by supervillain52(m): 4:40pm On Oct 18, 2017
TobiTobiTobiWhy:
I have a compiler on my system but when surfing the net i use that site. If you have problem with it, deal with it.
Okay .i also use it. i wanted ask a few question about it. and u jst de do as if we de fight
Re: C++ Thread For Beginners by Nobody: 7:22pm On Oct 18, 2017
supervillain52:
Okay .i also use it. i wanted ask a few question about it. and u jst de do as if we de fight
No vex bros wink , e get as you talk. Are we okay?
Re: C++ Thread For Beginners by Nobody: 5:38am On Oct 21, 2017
Solution For The Challenge
Re: C++ Thread For Beginners by Nobody: 5:41am On Oct 21, 2017
#include <iostream>
using namespace std;
int guesses=5;
char gap[3];
//creating question function
void question() {
cout << "GUESSES LEFT: "<<guesses<<endl;
cout<<"Fill in the gap: "<<endl<<"WORD: "<< "NI___IA"<<endl;
cout<<"Enter the three missing characters, UPPERCASE only:"<<endl;
cin>>gap[0]>>gap[1]>>gap[2];
}
//function to check answer
void checkWin() {
if (gap[0]=='G'&&gap[1]=='E'&&gap[2]=='R'&&guesses>0)
{
cout <<"YOU WON!!";
}
else if (gap[0]!='G'||gap[1]!='E'||gap[2]!='R'&&guesses>0)
{
guesses-=1;
cout <<"Wrong Answer"<<endl<<"GUESSES:" << guesses<<endl;
}
else if (gap[0]!='G'||gap[1]!='E'||gap[2]!='R'&&guesses==0){
cout<<"You LOST!";
exit(1);
}
}

int main(){
question();
checkWin();
if (guesses==4) {
switch(guesses) {
case'4':
question();
checkWin();
break;
case'3':
question();
checkWin();
break;
case'2':
question();
checkWin();
break;
case'1':
question();
checkWin();
break;
case'0':
checkWin();
break;
}
}
return 0;
}
Re: C++ Thread For Beginners by Nobody: 7:17am On Oct 21, 2017
TIPS: Never settle for the first solution, there is ALWAYS a better solution.
Re: C++ Thread For Beginners by ibromodzi: 8:36am On Oct 21, 2017
TobiTobiTobiWhy:
TIPS: Never settle for the first solution, there is ALWAYS a better solution.
Nice one...
I've been busy since, I would have given it a trial too.
Could you please chat me up on WhatsApp @08164402922.
Re: C++ Thread For Beginners by clockwisereport: 11:49pm On Aug 02, 2019
excanny:
Where does it run? Any best IDE for it?

try codeblocks

(1) (2) (Reply)

Get The Most Advance Networking Marketing Scripts With Any Matrix / Converting Stand-alone Application To Network-based(client-server) / How To Connet C++ Mfc Application With Mysql

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 22
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.