Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,206,894 members, 7,997,145 topics. Date: Friday, 08 November 2024 at 01:59 AM

C++ Tutorial For Beginners... Part 1... - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / C++ Tutorial For Beginners... Part 1... (19548 Views)

C++ Tutorial Download Link / Java Tutorial For Beginners / Free C++ Tutorial Videos (2) (3) (4)

(1) (2) (3) (4) (5) (6) (Reply) (Go Down)

C++ Tutorial For Beginners... Part 1... by Nobody: 3:39am On Oct 08, 2014
hello Nairalanders, i greet you all.. i opened this interactive trend to share my knowledge on C++ ,

As they say, the best way to learn is to teach and get feedbacks as well, so i am more than happy and glad to learn new things too...

PART 1....

Apparatus :

1. a PC running on windows, mac etc

2. Compiler : there are lots of free tools online, but you can download this compiler below
( file size :12mb
filename :'"devcpp4980.exe" Search the file name on google then download it... or visit the link below

http://www.filewatcher.com/m/devcpp4980.exe.12627146-0.html

)


•Note, as beginners of cpp, i implore you to follow the about instructions before proceeding to the next phase.... thank you..


Part 3:

I intentionally skipped "part 2" , which mainly entails the installation and setting of the about file you probably must have installed... for now.... in other words am going to wait till i get a positive responds before explaining more about part 2"
.
.
.

Note:: pls am typing this with my mobile phone so bare with me... thank you... and your Encouragement n participation will go a very long way...

2 Likes

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 3:57am On Oct 08, 2014
Ezechinwa:
hello Nairalanders, i greet you all.. i opened this interactive trend to share my knowledge on C++ ,

As they say, the best way to learn is to teach and get feedbacks as well, so i am more than happy and glad to learn new things too...

PART 1....

Apparatus :

1. a PC running on windows, mac etc

2. Compiler : there are lots of free tools online, but you can download this compiler below
( file size :12mb
filename :'"devcpp4980.exe" Search the file name on google then download it... or visit the link below

http://www.filewatcher.com/m/devcpp4980.exe.12627146-0.html

)


•Note, as beginners of cpp, i implore you to follow the about instructions before proceeding to the next phase.... thank you..


Part 3:

I intentionally skipped "part 2" , which mainly entails the installation and setting of the about file you probably must have installed... for now.... in other words am going to wait till i get a positive responds before explaining more about part 2"
.
.
.

Note:: pls am typing this with my mobile phone so bare with me... thank you... and your Encouragement n participation will go a very long way...


Part 3... continues....

Am going to avoid posting technobabbles and head straight to the point... am not going to show you the all and all of programming ( which is impossible), but am going to build on the " basics of Cpp" thats what you need as a beginner...

NB... Pls don't be offended with the tag "beginners" i can get carried away sometimes...

I can guarantee you that by the end of this trend, you will know the following..

1. How to get outputs from giving inputs!

2. How to solve some complex mathematical problems using cpp!

3. How to write codes using Cpp

4. We will be friends at the end... lol....

"for the seek of beginners viewing this, feel free to ask questions, cause i have to skip lots of stuffs so as not to derail my post..."

resume shortly...

1 Like

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 4:26am On Oct 08, 2014
..... Part 3..... continues....

LET'S begin... relax... do not cram but practise,,, And Encourage me...

INTRODUCTION TO CPP...


As promised earlier, am going to skip unrelevant stuffs about CPP... but for reference sake you can read up the following online.. you can use "google.com"

1. history of cpp
2. important of learning cpp
3. why you require a compiler, functions of a compiler.. etc.

as i posted earlier the tools required, am now going to post the mindset/techniques needed to venture in programning with Cpp...

1. Using comments "//" to make your codes readable and traceable .. let me explain...

there are many ways to put comments in your programs, but as a beginner using just "//" will do just fine...

for example.. we intend writing a program that sums two numbers??

imaging the following "scenarios "
(
case 1

int a;
int b;
int c;

c=a+b;
...

)
(
case 2

// program that adds two numbers

int a ; // first number
int b; // second number
int c; // variable rep output

c=a+b; // output of sum off two numbers.
...
)

from the about cases, but programs will run correctly, but case 1 is done by a dirty programmer and it will be hard to understand his work...

but case 2, is a well mapped program and can easily be readable and tracable as well...

it is important to note that anything written after the // " would be ignored by the compiler ( also called Whitespaces)..


Nb.. its 4:24am, so am off to bed, i promise to update from here tomorrow.... once again thanks...

to be continued...

1 Like

Re: C++ Tutorial For Beginners... Part 1... by Drniyi4u(m): 9:16am On Oct 08, 2014
ŋįçę ţђŗęād... ƒollowįŋg!!!
Re: C++ Tutorial For Beginners... Part 1... by KazukiIto(m): 10:01am On Oct 08, 2014
Hello OP, can you kindly post ur number? Just in case some of us needs a one-on-one chat with u. Thanks
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:01am On Oct 08, 2014
Drniyi4u:
ŋįçę ţђŗęād... ƒollowįŋg!!!

chai... i really appreciate...thanks..
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:03am On Oct 08, 2014
KazukiIto:
Hello OP, can you kindly post ur number? Just in case some of us needs a one-on-one chat with u. Thanks

add me on facebook.. www.facebook.com /Londonboy8892
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:41am On Oct 08, 2014
Ezechinwa:
..... Part 3..... continues....

LET'S begin... relax... do not cram but practise,,, And Encourage me...

INTRODUCTION TO CPP...


As promised earlier, am going to skip unrelevant stuffs about CPP... but for reference sake you can read up the following online.. you can use "google.com"

1. history of cpp
2. important of learning cpp
3. why you require a compiler, functions of a compiler.. etc.

as i posted earlier the tools required, am now going to post the mindset/techniques needed to venture in programning with Cpp...

1. Using comments "//" to make your codes readable and traceable .. let me explain...

there are many ways to put comments in your programs, but as a beginner using just "//" will do just fine...

for example.. we intend writing a program that sums two numbers??

imaging the following "scenarios "
(
case 1

int a;
int b;
int c;

c=a+b;
...

)
(
case 2

// program that adds two numbers

int a ; // first number
int b; // second number
int c; // variable rep output

c=a+b; // output of sum off two numbers.
...
)

from the about cases, but programs will run correctly, but case 1 is done by a dirty programmer and it will be hard to understand his work...

but case 2, is a well mapped program and can easily be readable and tracable as well...

it is important to note that anything writing after the // " would be ignored by the compiler ( also called Whitespaces)..


Nb.. its 4:24am, so am off to bed, i promise to update from here tomorrow.... once again thanks...

to be continued...






....Part 3... continues ..

so far, we have learnt up to the point of exploiting the use of Comments(//) when coding, now we can continue to progress further..



2. use of semicolon " ; "....

In English language, its a grammatical error when you don't use punctuations, the same applies to Cpp.
the main function of the semicolon in cpp, is to inform the compiler a certain end of a line of command , its a syntax error when you forget to include them, of course your compiler won't be able to compile your code... brief example below...

{
case 1:

int a // first number
int b // second number
int c // output number

c= a+b // sum of two numbers

}

{
Case 2:

int a ; // first number
int b ; // second number
int c ; // output number

c= a+b ; // sum of two numbers
}

Explaination:: From the two cases above, the first one got it all wrong when she failed to include ";" (semicolon) at the end of her command...
while, the second case is totally correct and acceptable, the guy included semicolon to each command line...

Score: for this error, the current score stands at Men 1 vs Women 0... lol..

Conclusion: always include the semicolon to your command..

2 Likes 1 Share

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 12:07pm On Oct 08, 2014
Ezechinwa:




....Part 3... continues ..

so far, we have learnt up to the point of exploiting the use of Comments(//) when coding, now we can continue to progress further..



2. use of semicolon " ; "....

In English language, its a grammatical error when you don't use punctuations, the same applies to Cpp.
the main function of the semicolon in cpp, is to inform the compiler a certain end of a line of command , its a syntax error when you forget to include them, of course your compiler won't be able to compile your code... brief example below...

{
case 1:

int a // first number
int b // second number
int c // output number

c= a+b // sum of two numbers

}

{
Case 2:

int a ; // first number
int b ; // second number
int c ; // output number

c= a+b ; // sum of two numbers
}

Explaination:: From the two cases above, the first one got it all wrong when she failed to include ";" (semicolon) at the end of her command...
while, the second case is totally correct and acceptable, the guy included semicolon to each command line...

Score: for this error, the current score stands at Men 1 vs Women 0... lol..

Conclusion: always include the semicolon to your command..




3. Use of parentheses in cpp...

hmm.. we are moving pretty fast and that's good news, another important aspect to consider is the use of brackets "()" and "{}"...

I related the previous example to English language, but i think it's Maths turn..( just kidding lol)...

Its a syntax error, when you fail to do the following below,

• failing to use curly brackets "{" when opening the program function..
• failing to close the opened curly bracket "}" when done with the program function..

• failing to use pair of bracket after the "main" command ( otherwise referred to the on switch of all cpp codes), as well as during mathematical computation..

Tip: Computer never makes mistake but we do, it only carries out well debugged instruction(s)... so if you find errors in a program, then its your fault not the computer.... for practise reasons, always carry out a bracket count, ensure your brackets are in perfect pair or match.. thankyou...
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 3:40pm On Oct 08, 2014
i will continue after i get more responses from you guys.. i have to pause here and take your questions...thankyou
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 1:37pm On Oct 09, 2014
You're doing a great job, plz don't relent

I just wish there was something like this for java. I could even switch from java to C++, if this tutorial goes deeper

1 Like

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:26pm On Oct 09, 2014
Preboy:
You're doing a great job, plz don't relent

I just wish there was something like this for java. I could even switch from java to C++, if this tutorial goes deeper


My brother, thanks for ur comment...

will post shortly.. stay tuned...
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:37pm On Oct 09, 2014

Hello guys,,, please be informed that this trend will move in the following order...

after learning C++,,
goto java basics
then andriod games development...
also andriod application development....

Note : i will update this trend mostly between 9pm- 11:30pm ..

Cost : absolutly free, just need your constant encouragement...

My profit: to meet great minds online... to learn as well...

Current score : Men 1- women 0.. lmao..


2 Likes

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 10:45pm On Oct 09, 2014
Ezechinwa:





3. Use of parentheses in cpp...

hmm.. we are moving pretty fast and that's good news, another important aspect to consider is the use of brackets "()" and "{}"...

I related the previous example to English language, but i think it's Maths turn..( just kidding lol)...

Its a syntax error, when you fail to do the following below,

• failing to use curly brackets "{" when opening the program function..
• failing to close the opened curly bracket "}" when done with the program function..

• failing to use pair of bracket after the "main" command ( otherwise referred to the on switch of all cpp codes), as well as during mathematical computation..

Tip: Computer never makes mistake but we do, it only carries out well debugged instruction(s)... so if you find errors in a program, then its your fault not the computer.... for practise reasons, always carry out a bracket count, ensure your brackets are in perfect pair or match.. thankyou...





note: from now, i will update this trend using a red color format...i proceed..
So far, we have looked into few foundations of C++, like the proper implementation of semicolons, brackets etc, in case your just tuning in, you haven't missed that much, just go back and read from the beginning..

Part 3... continues..

4. Header files and directives...

hmm, you want to write a program ( maybe solve a problem, lets say mathematical in nature) , it is important to add "HEADER FILES" using a directive "#include < header file> ..
don't get overwhelmed, let me explain what i mean, there are lots of "Header files" in cplusplus ( and you are not required to know all of them ), these files have a function to play in the program your building..
furthermore, the files are added to the program using a directive #include. you still don't get it?, OK, consider the two concepts we are discussing here namely "directives" and " header files" relate them to this example, assuming your giving an assignment in mathematics ( " to find the area of a square"wink, of course you will go home and apply the formula "AREA= LENGTH * WIDTH" then return the result which is "AREA" to your teacher isn't it? now see ,

the "HEADER FILE" = FORMULA ( which is Area= length * width)
the Directive( #include) = YOU "applying the formula to the problem" ...

I will share with you few header files for beginners below,
"#include <stdio.h> " //will make the compiler to include the contents of standard header file
"#include <iostream>" // basically tells the compiler: i need input and output..
"#include <math.h> // to preform some mathematical operations, you need this library..

note:: please bear with me, i will get my laptop repaired soon, for now, am typing with a phone.. thank you..

2 Likes

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 11:09pm On Oct 09, 2014
Ezechinwa:



note: from now, i will update this trend using a red color format...i proceed..
So far, we have looked into few foundations of C++, like the proper implementation of semicolons, brackets etc, in case your just tuning in, you haven't missed that much, just go back and read from the beginning..

Part 3... continues..

4. Header files and directives...

hmm, you want to write a program ( maybe solve a problem, lets say mathematical in nature) , it is important to add "HEADER FILES" using a directive "#include < header file> ..
don't get overwhelmed, let me explain what i mean, there are lots of "Header files" in cplusplus ( and you are not required to know all of them ), these files have a function to play in the program your building..
furthermore, the files are added to the program using a directive #include. you still don't get it?, OK, consider the two concepts we are discussing here namely "directives" and " header files" relate them to this example, assuming your giving an assignment in mathematics ( " to find the area of a square"wink, of course you will go home and apply the formula "AREA= LENGTH * WIDTH" then return the result which is "AREA" to your teacher isn't it? now see ,

the "HEADER FILE" = FORMULA ( which is Area= length * width)
the Directive( #include) = YOU "applying the formula to the problem" ...

I will share with you few header files for beginners below,
"#include <stdio.h> " //will make the compiler to include the contents of standard header file
"#include <iostream>" // basically tells the compiler: i need input and output..
"#include <math.h> // to preform some mathematical operations, you need this library..

note:: please bear with me, i will get my laptop repaired soon, for now, am typing with a phone.. thank you..

because i promised to avoid posting long stories aka techno-babbles i will round up this section here and now,,,

5. MENTALITY OF A PROGRAMMER: Before proceeding further to the next stage of Cplusplus which is coding proper, ensure that you have the following at your disposal,

a PC, a COMPILER , a note book,

As programmers, we get paid solving problems ( if you choose to make it a career) and everyday is a challenge, without the listed materials about " i will assume your cramming because practice makes perfect"...

the next frame which is off course PART 4, we will start coding mostly mathematical functions for now( i will start from simple MATHEMATICAL PROBLEMS to Harder mathematical problem ( which involves loops, etc)"

you will wonder why i didn't discuss about concepts like "Variables", " Paragraphs", etc, well, i promise to do that in the next frame... for now , get ready...

share your comments,suggestions and questions... God bless Nigeria'''


1 Like

Re: C++ Tutorial For Beginners... Part 1... by leunamme93(m): 12:37am On Oct 11, 2014
Ezechinwa:


because i promised to avoid posting long stories aka techno-babbles i will round up this section here and now,,,

5. MENTALITY OF A PROGRAMMER: Before proceeding further to the next stage of Cplusplus which is coding proper, ensure that you have the following at your disposal,

a PC, a COMPILER , a note book,

As programmers, we get paid solving problems ( if you choose to make it a career) and everyday is a challenge, without the listed materials about " i will assume your cramming because practice makes perfect"...

the next frame which is off course PART 4, we will start coding mostly mathematical functions for now( i will start from simple MATHEMATICAL PROBLEMS to Harder mathematical problem ( which involves loops, etc)"

you will wonder why i didn't discuss about concepts like "Variables", " Paragraphs", etc, well, i promise to do that in the next frame... for now , get ready...

share your comments,suggestions and questions... God bless Nigeria'''



Have being following you... I just got the desire to learn c++ even though its not even near my academic environment, but i want to be different. so God willing pls keep the good work going. Godbless

2 Likes

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 10:31am On Oct 11, 2014
leunamme93:

Have being following you... I just got the desire to learn c++ even though its not even near my academic environment, but i want to be different. so God willing pls keep the good work going. Godbless

shout out to you guys, believe me i really appreciate it alot... lets keep this thread alive... God bless Nigeria....

Part 4... coming up shortly... stay tuned..
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 12:25pm On Oct 11, 2014


Part 4... begins here....

great to be back guys. so far, we have been discussing on the ethics of programming with C++, i made mention of the tools and skills required as well... ( i will assume you have them , so be ready) ...

i promised in the last frame to explain some key concepts, which i will do now.. but i will just give a quinessential summary of it, for further references you can read them up online...

briefly, lets talk about "VARIABLES"...

almost , if not all Cplusplus programs contains Variable(s), so its a key concept in programming, consider Variable to be a placeholder( where you store valves) , every variable is also an identifier
... there are different types of variables, but as for beginners i assumed you are, i will mention a few here.. ( pay full attention..).

in order not to forget, lets break Types of variables into the following...

• Numbers :
typically involves variable types like " int" = interger, " double"= numbers with decimal point ... etc..

warning::: the variable types are similar but are not the same, they have a specific function to play,, if i were to write a program involving "Real human numbers" for example, it will be a silly mistake using variable type "double" instead of "int", because we cant have a statement like, "there are two and the half people in the room" but instead " there are three people in the room" respectively..




• Letters/Words :

typically involves variable types as " char" = character ( a single letter ) , "string"= stream of characters.. ( combination of characters to form a word / field...

• Logical ( boolean): in short, the variable type boolean is for compairing two or more quantities.. it has two output namely, true / false or 1/0 respectively..

as i said, you will need to understand this concepts are we head into the next phase...

thank you...

Tip: the more difficult a problem is the more interesting it gets. ...







2 Likes

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 1:27pm On Oct 11, 2014
Ezechinwa:


Part 4... begins here....

great to be back guys. so far, we have been discussing on the ethics of programming with C++, i made mention of the tools and skills required as well... ( i will assume you have them , so be ready) ...

i promised in the last frame to explain some key concepts, which i will do now.. but i will just give a quinessential summary of it, for further references you can read them up online...

briefly, lets talk about "VARIABLES"...

almost , if not all Cplusplus programs contains Variable(s), so its a key concept in programming, consider Variable to be a placeholder( where you store valves) , every variable is also an identifier
... there are different types of variables, but as for beginners i assumed you are, i will mention a few here.. ( pay full attention..).

in order not to forget, lets break Types of variables into the following...

• Numbers :
typically involves variable types like " int" = interger, " double"= numbers with decimal point ... etc..

warning::: the variable types are similar but are not the same, they have a specific function to play,, if i were to write a program involving "Real human numbers" for example, it will be a silly mistake using variable type "double" instead of "int", because we cant have a statement like, "there are two and the half people in the room" but instead " there are three people in the room" respectively..




• Letters/Words :

typically involves variable types as " char" = character ( a single letter ) , "string"= stream of characters.. ( combination of characters to form a word / field...

• Logical ( boolean): in short, the variable type boolean is for compairing two or more quantities.. it has two output namely, true / false or 1/0 respectively..

as i said, you will need to understand this concepts are we head into the next phase...

thank you...

Tip: the more difficult a problem is the more interesting it gets. ...







1 Like

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 1:29pm On Oct 11, 2014
Ezechinwa:
[/quote]
[quote author=Ezechinwa post=27049534]

Part 4... begins here....

great to be back guys. so far, we have been discussing on the ethics of programming with C++, i made mention of the tools and skills required as well... ( i will assume you have them , so be ready) ...

i promised in the last frame to explain some key concepts, which i will do now.. but i will just give a quinessential summary of it, for further references you can read them up online...

briefly, lets talk about "VARIABLES"...

almost , if not all Cplusplus programs contains Variable(s), so its a key concept in programming, consider Variable to be a placeholder( where you store valves) , every variable is also an identifier
... there are different types of variables, but as for beginners i assumed you are, i will mention a few here.. ( pay full attention..).

in order not to forget, lets break Types of variables into the following...

• Numbers :
typically involves variable types like " int" = interger, " double"= numbers with decimal point ... etc..

warning::: the variable types are similar but are not the same, they have a specific function to play,, if i were to write a program involving "Real human numbers" for example, it will be a silly mistake using variable type "double" instead of "int", because we cant have a statement like, "there are two and the half people in the room" but instead " there are three people in the room" respectively..




• Letters/Words :

typically involves variable types as " char" = character ( a single letter ) , "string"= stream of characters.. ( combination of characters to form a word / field...

• Logical ( boolean): in short, the variable type boolean is for compairing two or more quantities.. it has two output namely, true / false or 1/0 respectively..

as i said, you will need to understand this concepts are we head into the next phase...

thank you...

Tip: the more difficult a problem is the more interesting it gets. ...









PART 4... Continues....


Note:
Do you want to develop Andriod apps
Do you know you make above $5000 per month with your apps??...

CAPITAL :: #0.00 naira ( absolutly free)...

Prequisites ::: Xml programming+ java programming..
( which i will show you here)

Just need your encouragement ... keep this thread alive ... thankyou ....


TITLE: WRITING YOUR FIRST PROGRAM..


In most programming text books, your first program is usually the "Hello world" , but this is not a textbook, and thats too simply obsolete to begin with...

instead, let's begin with something a little bit adventurous..
...

PROBLEM...

", WRITE A PROGRAM THAT CAN ESTIMATE THE AVERAGE OF THREE NUMBERS"

SOLUTION...

BECAUSE EVERY MOVIE NEEDS SUSPENSE , SO DOES EVERY THREAD,,, LOL.. BUT BEFORE I PROCEED I REALLY NEED RESPONSE, COMMENTS, SUGGESTIONS... ( to ensure am not teaching myself alone) ..lol...

1 Like

Re: C++ Tutorial For Beginners... Part 1... by leunamme93(m): 8:03pm On Oct 11, 2014
HAha you are not teaching yourself here oooh. God is with Us.
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:49pm On Oct 11, 2014
leunamme93:
HAha you are not teaching yourself here oooh. God is with Us.

LOL.. THANKS BRO.. HIGHLY APPRECIATED.... STAY TUNED...
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 10:07pm On Oct 11, 2014
Ezechinwa:




PART 4... Continues....


Note:
Do you want to develop Andriod apps
Do you know you make above $5000 per month with your apps??...

CAPITAL :: #0.00 naira ( absolutly free)...

Prequisites ::: Xml programming+ java programming..
( which i will show you here)

Just need your encouragement ... keep this thread alive ... thankyou ....


TITLE: WRITING YOUR FIRST PROGRAM..


In most programming text books, your first program is usually the "Hello world" , but this is not a textbook, and thats too simply obsolete to begin with...

instead, let's begin with something a little bit adventurous..
...

PROBLEM...

", WRITE A PROGRAM THAT CAN ESTIMATE THE AVERAGE OF THREE NUMBERS"

SOLUTION...

BECAUSE EVERY MOVIE NEEDS SUSPENSE , SO DOES EVERY THREAD,,, LOL.. BUT BEFORE I PROCEED I REALLY NEED RESPONSE, COMMENTS, SUGGESTIONS... ( to ensure am not teaching myself alone) ..lol...



PART 4... CONTINUES......

firstly, to all those following this thread i say a big thank you, and to those just viewing and ignoring this juicy thread , i say in Patience Jonathan's voice ( there is God oh...)


i think at this stage, it will be promptly wrong to tag you lovely followers as beginners, cause at this stage i dont think but i know your ready,, so just relax and watch...

We have a small problem in our hands, which is to write a program that can find the average of three numbers?.... in just a matter of minutes, you'll understand why i referred to it as a small problem...

first, to solve any problem in programming, its best you first understand the nature of that program( in nature i mean algorithm), understand the best choice of variable to use( for mathematicians, a good understanding of domain and range can also be applied here).. and always remember to follow the rules i mentioned above..

enough of my talking, lets start to find a solution to that problem.... be back shortly








1 Like

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 10:34pm On Oct 11, 2014
Ezechinwa:




PART 4... CONTINUES......

firstly, to all those following this thread i say a big thank you, and to those just viewing and ignoring this juicy thread , i say in Patience Jonathan's voice ( there is God oh...)


i think at this stage, it will be promptly wrong to tag you lovely followers as beginners, cause at this stage i dont think but i know your ready,, so just relax and watch...

We have a small problem in our hands, which is to write a program that can find the average of three numbers?.... in just a matter of minutes, you'll understand why i referred to it as a small problem...

first, to solve any problem in programming, its best you first understand the nature of that program( in nature i mean algorithm), understand the best choice of variable to use( for mathematicians, a good understanding of domain and range can also be applied here).. and always remember to follow the rules i mentioned above..

enough of my talking, lets start to find a solution to that problem.... be back shortly











OUTLINE....

*1 Aim: Program able to solve the average of three numbers..
*2 Header files: suitable header files includes

#include <math.h> ( because we might need some mathematical operations)
#include <cstdio>
#include < iostream> ( because we require our program to get input/information from the user..

* 3 NATURE: remember average of a set of numbers (IN THIS CASE 3 NUMBERS) is given as "Average=( Number_1+Number_2+Number_3)/ 3"

*4 INPUTS : this program will require 3 inputs from the user ( Number 1, NUMBER 2 AND NUMBER 3)....

*5 OUTPUT(S): this program will require just one major output which is "AVERAGE"

*6 MATHEMATICAL SIGNS REQUIRED: from the nature of the problem, we can find four (4) signs namely ( Equal sign , pair of bracket, addition and as well division..

*7 VARIABLE TYPE : " double" WILL BE VERY SUITABLE, DON'T USE "int" ( to avoid truncation error)...


what i just wrote above is an outline, it will serve as a guide in solving problems like this... the solution coming shortly... stay tuned.... share with your friends... lets make Nigeria great....












1 Like

Re: C++ Tutorial For Beginners... Part 1... by donphoenix: 12:14am On Oct 12, 2014
following. Keep up the good work
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 12:45am On Oct 12, 2014
OP... this is the best thread have ever came across on Cplusplus...

Even some text books don't explain like like dis.. op am following you bumper-bumper...

#Enjoying myself here...
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 12:48am On Oct 12, 2014
@don & @baddo... thanks alot... pls i will upload the solution this evening.. just stay tuned ... see u soon..
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:09am On Oct 12, 2014


Sorry i couldn't complete the solution yesterday ( sleep no gree me)... so i will do that now....

so far, we have written an outline of what our program should look like, is time to apply them... ( don't forget the rules)..

Sit down... Relax..... let's learn together....

// A PROGRAM THAT CAN FIND THE AVERAGE OF /////// THREE NUMBERS.


// include header files, ignore the semicolon below.
1. #include <iostream>
2. #include <cstdio>
3. #include <cstdio>

// add the program namespace and on the program flow.( adding int main)

4. using namespace std ;
5. int main () // ignore semicolon
6. { // open program flow...

// declare the three input variable and a single
//output variable using a suitable variable type below

7. double input1;
8. double input2;
9. double input3;
10. double output1;

// now time to get parameters from the user below.

// First input details
11. cout << " Enter the first valve and press Enter key : " << endl ;
12. cin >> input1;

// second input details
13. cout << "Enter the second valve and press Enter :" << endl;
14. cin >> input2;

// third input details
15. cout << "Enter the Third valve and press Enter:"
<< endl ;
16. cin >> input3;

// mathematical manupulation below.

output1= ( input1 + input2 + input3 ) / 3 ;

// almost done with the problem... display output

17. cout << " the average valve is : " << endl;
18. cout << output1;
19. cout << endl;

system ("PAUSE"wink ; // allow display to freeze....
return 0 ; // terminate program

}





1 Like

Re: C++ Tutorial For Beginners... Part 1... by Nobody: 9:12am On Oct 12, 2014
Ezechinwa:


Sorry i couldn't complete the solution yesterday ( sleep no gree me)... so i will do that now....

so far, we have written an outline of what our program should look like, is time to apply them... ( don't forget the rules)..

Sit down... Relax..... let's learn together....

// A PROGRAM THAT CAN FIND THE AVERAGE OF /////// THREE NUMBERS.


// include header files, ignore the semicolon below.
1. #include <iostream>
2. #include <cstdio>
3. #include <cstdio>

// add the program namespace and on the program flow.( adding int main)

4. using namespace std ;
5. int main () // ignore semicolon
6. { // open program flow...

// declare the three input variable and a single
//output variable using a suitable variable type below

7. double input1;
8. double input2;
9. double input3;
10. double output1;

// now time to get parameters from the user below.

// First input details
11. cout << " Enter the first valve and press Enter key : " << endl ;
12. cin >> input1;

// second input details
13. cout << "Enter the second valve and press Enter :" << endl;
14. cin >> input2;

// third input details
15. cout << "Enter the Third valve and press Enter:"
<< endl ;
16. cin >> input3;

// mathematical manupulation below.

output1= ( input1 + input2 + input3 ) / 3 ;

// almost done with the problem... display output

17. cout << " the average valve is : " << endl;
18. cout << output1;
19. cout << endl;

system ("PAUSE"wink ; // allow display to freeze....
return 0 ; // terminate program

}






note....remove that smiley on system ( " pause.. change it to ) .
Re: C++ Tutorial For Beginners... Part 1... by haxorDelite(m): 12:10pm On Oct 13, 2014
Ezechinwa:


note....remove that smiley on system ( " pause.. change it to ) .
following you bro keep it up, but that "cout" am lost there oo
Re: C++ Tutorial For Beginners... Part 1... by zyzxx(m): 1:59pm On Oct 13, 2014
bro u are a Gud teacher.
Av really learn a lot thanks
Following u bumper to bumper
Re: C++ Tutorial For Beginners... Part 1... by Nobody: 6:39pm On Oct 13, 2014
haxorDelite:
following you bro keep it up, but that "cout" am lost there oo

my brother, thank you jare, , this is my first out of many write ups on nairaland... i really appreciate it alot...

cout is a command to display stuff on screen/ output device...

for example,

cout << " anything you write here will show on screen ";

my main format is this, you must write the double arrow like dis << for cout and like dis >> for cin...

irrespective of the content, you must end it with semicolon ;

also see,

int nairaland ; // variable
nairaland = 4 ;

cout << nairaland ;

notice: from the second example, the output will not be nairaland but 4, becus nairaland is just a variable holding a valve which is 4...

conclusion... when displaying comments add ","... but when displaying the valve of a variable put that variable inside...

remember cpp is case sensitive, i mean capital letter is not the same as small letter...

example

int williams ;

williams is not the same as Williams...

thank you for following.. i do appreciate....

2 Likes

(1) (2) (3) (4) (5) (6) (Reply)

Pros And Cons Of Dating A Programmer Or Just A Geek / I Just Bombed A Technical Interview / How Much Do Web Developers Earn In Nigeria?

(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. 104
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.