C plus plus for beginners

C plus plus for beginners All about C++ programming basics for absolute beginners. Questions and challenges will be raised and

"The programmers of tomorrow are the wizards of the future You're going to look like you have magic powers compared to everybody else." ~Gabe Newell~
Wanna become one?

23/09/2017

Today's Learn to code day!
Happy codiversary. :)

Patterns are great way to learn and practice loops. Besides, those LED lights you see running on notice boards are made using patterns. Below are 20+ interesting ones made just for you.

Let's know if you have questions pertaining to any of them.

Got a pattern you want us to help with? Post it here and we'll get back to you ASAP!





using namespace std;

int main()
{
for(int a = 0; a < 5; a ++)
{
for(int c = 0; c < 5; c ++) cout

24/09/2016

!
Ever wondered if there is just a single line of code that would (1) check for values (2) do some calculations and (3) print the output without costing you the time and space? Well there is. Here is an example about how effectively and neatly you can write your code without using an if conditional statement or even case and switch for that matter.

What the following code would do is simply print the value of a user’s net payment. It does so after multiplying it with the proper rate.

using namespace std;
double input = 105;
int main()
{
cout

24/09/2016


It may be often that we face bugs in our codes. As some of them may be debugged by writing few extra lines of codes, some surprisingly involve removing them. Some may cause our code not to run in the first place, while others can crush it in the runtime. And some may do neither and just give us results we do not expect as in the case of a code put below. ;)
The following code is written by a junior C++ programmer. He, as an IT expert in a bank he works in, wanted to make a system to impress his boss and get himself a raise. One part of his system, shown here, simply lets a user to enter their ID and checks whether their data exists or doesn’t. He tried entering 2 IDs one that exists and another that does not. (Namely 44058 and 22022).
At this point he is confident that this section of his system is bug free and fully functional, as the two IDs returned values expected. Unfortunately, he must have missed something that, while he was showing his system to his B0$$, he noticed a bug. What an awkward moment that nobody wants to be in!
entered 12506, that should have returned a positive value.
See what you can do to help him out. ;)

using namespace std;
int userID, database [] = {15203, 12506, 99025, 44058};
bool doesCustomerDataExist(int input);
int main()
{
cout > userID;
if(doesCustomerDataExist(userID)) cout

01/08/2015

Tips and tricks on C++
Part 5
The answer to the last challenge given in part 4 will be answered soon as mentioned there.
For today let’s see if you could find a way to solve the bug in the program whose code is shown below.
Challenge 5
A C++ programmer wrote a code and uploaded it to his brand new ‘Metal Detector’. What the machine is intended to do is to detect a metal using its’ many physical parts. How the machine works is shown below:
A person passed through a door
If metal is detected he/she shall pass again through that door after security personnel apply the necessary procedures to ensure that the person is not having any metal as he/she passes through the door.
And if the person is found to have a metal again or if he/she is clean this time, to display some logical text on its’ LCD screen.
However, from many of its’ features the one which is responsible to print words in the LCD screen is not functioning in the way the programmer wanted it to. i.e The LCD will show the ‘Metal Detected” notice once a person is found to have a metal made material EVEN AFTER THE SECURITY PERSONNEL IS VERY MUCH SURE that the person is NOT having any type of metal. See what you can do to help this fellow!
Code:

using namespace std;
bool metal_detected=false,condition1=true;
int trials=2;
void check();
void check(){
if(condition1==true) {
trials--;
metal_detected=true;
}
else {
trials=0;
}
}
int main(){
while(trials>0) {
check();
condition1=false;
}
if(metal_detected==true) {
cout

01/08/2015

Tips and tricks on C++!
Part 4
The answer to the last challenge posted and NEW tips and tricks will be discussed here.
AAAA THERE WILL ALSO BE AN AWARD FOR ANYONE WHO ANSWERS THE CHALLENGE OF TODAY!!!! AAAA
Answer:

using namespace std;
int main(){
int c=1;
for(int a=0;a

01/08/2015

Tips and tricks on C++!
Part 3
The answer to the last challenge posted and NEW tips and tricks will be discussed here.
Answer: The last question can be simply solved like:

using namespace std;
int main()
{
int allow=2,input;
while(allow>0) {
coutinput;
for(int a=1; a

01/08/2015

Tips and tricks on C++!
Part 2
The answer to the last challenge posted and NEW tips and tricks will be discussed here.
Answer:

using namespace std;
int main()
{
for(int a=1;a

Address

Debre Zeit

Alerts

Be the first to know and let us send you an email when C plus plus for beginners posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Shortcuts

Share

Category