Introduction to Programming : C++ #2

Hey, guys!

We are back  with 2nd part of C++. In case you haven’t been through the 1st part here is the link. :p

At times, you have to make decisions in your life. when you’re running low on your pocket money, you be like “OMG a Bradely Cooper movie or a Ryan Gosling movie”

Pretty much.

It’s really difficult at times! We know! similarly, your program too needs to make decisions sometimes and they do it logically, with the help of some statements. They control the flow of the execution of your program and are called Control structures. There are three types of control structures:

  1. Sequential (Default)

  2. Conditional

  3. Looping.

Let’s learn about each types one by one.

First up. The most basic of all.


When you type and tell your machine to execute your cute little code, the execution needs begin from somewhere, and what’s the best place to begin something. Yes,”From the Start”.

The execution begins from the start and the control is given to the function named main(). Duh. Now, the compiler asks “Now that I have started, what I do with the control”. The answer is the ‘sequential control structure’ .It is just simple common sense, in this the control follows a straight path, No turns. And more importantly NO GOING BACK. Just keep on executing from the start to the end.

Moving on.


This is something better than the previous one, Better because it is not boring as sequential.Conditional control structure actually have various members. Each member has it’s own feature, Now it’s up to you and how you want the execution to happen. Hence giving you the power the control the flow.As the name suggests you get that power through CONDITIONS.And HOW EXACTLY DO WE DO THAT? Using these guys(the members of the conditional control structure).

  1. If statement.

  2. If else statement.

  3. Nested If else

The first two are the most basic conditional statements. Nested if else is made using multiple if else statements.(We’ll see how, further in detail.).Let us now get an idea about what each one of these guys do.Ok? Here we go.

If : It’s Friday night! And you have a sleepover at your friend’s place tomorrow and you ask your mom for persmission. She says that she will allow you only “if” you do the dishes for a week. otherwise you don’t go and continue your routine work which you will do nonetheless. This is exactly what ‘If‘ control statement does in programming languages.



This basically means that if the condition is fulfilled, statement1 is executed , otherwise the statement is skipped. i.e, if you do the dishes you are allowed to go, otherwise you continue to do your routine work.

If else : This is really easy to understand.. This gives you extended power than “if” .A condition’s outcome is true or false. Nothing else .Like “7 is greater than 2?”TRUE “Sky is green?”FALSE “Megan Fox is hotter than your girlfriend?”, You get the point.Right? So you have a statement and you check whether it’s true or false. ‘If’ it is true, execute statement1 else (i.e, it is false) do statement2 (programming is all about execution of statements :P) an if-else statement looks like :





Getting this thing real.


cout<<“2 is greater than 1”;


cout<<“2 is smaller than 1”;

Output : 2 is greater than 1

Here, the first statement is executed since the first condition is true. Else, the second statement is executed.

Nested If else: Nested means inside one another.Nested if else means if-else inside an if-else.Yes, If-else-ception. If the outer “IF” is true than the control moves inside and encounter another “IF” and checks it’s truth value. Same happens for else.

if(condition1) //outer If


if(condition2) //inner if


else //inner else



else if(condition 3) //outer else




So , if condition1 is true and condition 2 is false, Statement2 is excuted.You can try for the rest on your own.

That’s all about conditional control structure.

Lastly, It’s time for the for some looping. Oh yeah!


Just as conditional has members ,viz If, If-else ,Nested if-else. Looping has too, and they are…*drumrolls*

1)The for Loop

2)The while Loop

3)The do-while Loop

The ‘for’ loop: No no, it doesn’t do anything “for” you, well not directly at least, but it performs an instruction or a set of instructions for the condition is true. So, It will keep on reapeating the instructions till the condition is false,basically, it executes a set of statements IN A LOOP. The condition is checked after every loop cycle, and once the condition is false,*bam*the control is thrown outside the loop. This loop works fine only if you know how many times you have to swirl around in the loop. What if I don’t know? Don’t worry we have answer for that too. But first. The for loop.


for (initialization; condition; increase or decrease)


It works in the following way:

  • Initialization is executed. Generally, this declares a counter variable, and sets it to some initial value. This is executed a single time, at the beginning of the loop.

  • condition is checked. If it is true, the loop continues; otherwise, the loop ends, and statement is skipped, going directly to the end step.

  • statement is executed. As usual, it can be either a single statement or a block enclosed in curly braces { }.

  • Increment/decrement is executed, and the loop gets back to step 2(where condition is checked).

  • The loop ends: execution continues by the next statement after it.

The three fields in a for-loop are optional. They can be left empty, but in all cases the semicolon signs between them are required. A loop with no condition is equivalent to a loop with true as condition (i.e., an infinite loop).

Let’s see an example to understand it better:

for (int timer = 10; timer > 0 ; timer – – )


cout << timer<< “, “;


cout << “liftoff!”<<endl;

Output : 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, liftoff!

Now, the for loop has two siblings; while and do while

while: Earlier I mentioned that “for” loop is used when we know how many times to swirl, but what if I don’t know how many times? What do I do? While loop is our savior While loop simply repeats statement while expression is true. If, after any execution of statement, expression is no longer true, the loop ends, and the program continues right after the loop. It is an entry controlled loop which means that a condition is checked before entering the loop.

while (expression) statement

int main ()


int n =32 ;

while (n>0)


cout<<n<<” “;

n = n-5;



Output : 32 27 22 17 12 7 2

The youngest sibling of all the three brothers is the do-while loop. Stubborn as hell! No matter what, it will do what it wants at least once. This part is included in the do part of the loop. Then, the condtion is checked i.e., after the loop runs for the first time then it decides if it wants to enter the loop again or not.

do statement while (condition);

NOTE: this is the only loop in which there is a semicolon after the ‘while’;

Let’s see an example

Let’s think of a situation in which you have a crush on the cutest guy in the college and one day you decide to talk to him. The first time, you will talk to him no matter what. But, there will be a second time or no depends on how the first encounter goes. The do-while loop works in a similar way. It looks something like this:





while ( condition );

for example:


do {

cout<<“Hello, world!” ;


} while ( x != 0 );

here, “Hello, world!” is printed at least once till x=0 eventhough the condition is false.

So, That’s all folks. Stay tuned for new progamming stuff.Please contact us by email if you have any queries or suggestions.

Charmi Jagwani






And umm… wherever else you can find us.


Of Robots And Humans #1

What is the one thing common between , Siri , Google Now , S voice and Cortana? Well , they are all personal digital assistants, which is pretty much like regular assistants but with silicon. And they all fall under the category of ‘AI’ or ‘Artificial Intelligence’ … and that is slightly erroneous. Because well , intelligence is… not what it seems.

Guess how many of them are actually geniuses ?

See , the idea of mechanical beings has been a subject of fascination among legions! This includes mathematicians , inventors , engineers and nerds. And well , In Greek mythology the god Vulcan forged mechanical handmaidens of gold(Like C3PO , I think ) and three-legged tables that could move under their own power. As early as 400 BC the Greek mathematician Archytas of Tarentum wrote about the possibility of making a robot bird propelled by steam power. Even Leonardo da Vinci drew diagrams of a robot knight that could sit up, wave its arms and move it’s head.

Well , a question that has split the scientific community for over a century is.. can machines think? Some say that is the equivalent of saying a bug doing Freudian psychoanalysis , which in non-nerd means ‘pretty much impossible’. Because they don’t have the brains to do so.

Artificial Intelligence is a class apart from any other technology we have witnessed, because we do not know what intelligence exactly is. There is no ‘Fundamental Law of Intelligence’ , as Michio Kaku aptly says in his book ‘Physics of the impossible’  , that “The Newton of AI probably has not yet been born”

But to ‘believers’, computer scientists and mathematicians , it’s only a matter of time before a machine which can think on it’s own will walk out of a labratory…. I hope it walks out in peace.

Gosh , can you imagine?

Well , the first real ‘AI research’ was made possible because of the great mind of Alan Turing. I think it is safe to call Turing “The father of computer science”.

Some people asserted that true robots cannot exist. Sure , we have computers that can do pretty amazing things that would put us to shame. Deep Blue was the first ‘Robot’ that beat the world champion Garry Kasparov in a six-game match in 1997, but it was a victory of raw computer power, but the experiment told us nothing about intelligence or consciousness,
although the game made plenty of headlines.

This is explained by a thought experiment they like to call the “The chinese room test”

Imagine that you are sitting inside the box and you don’t understand a word of Chinese.Assume you have a book that allows you to rapidly translate Chinese and manipulate its characters. If a person asks you a question in Chinese, you merely manipulate these strange-looking characters, without understanding what they mean, and give credible answers.

This is the critical difference between the two parts of intelligence. Syntax and Semantics.
A computer will kick your ass on all seven days of the week straight to kindergarten on a calculus test , but that little sucker doesn’t understand a damn symbol. It works with words without knowing what they mean. They are masters of Syntax. But suck when it comes to semantics. The day a robot gets familiar with semantics, the true AI will come to life…. and probably kill us all.

Physicist Roger Penrose of Oxford, too, believes that artificial intelligence is impossible; mechanical beings that can think and possess human consciousness are impossible according to the laws of the quantum theory.The human brain, he claims, is so far beyond any possible creation of the laboratory that creating humanlike robots is an experiment that is doomed to fail. He argues that in the same way that Gôdel’s incompleteness theorem proved that arithmetic is incomplete, the Heisenberg uncertainty principle will prove that machines are incapable of human thought.

Claude Shannon, often called the father of informationtheory, was once asked the question “Can machines think?” His reply was “Sure.” When he was asked to clarify that comment, he said, “I think, don’t I?

Well, there is a sort of a test to see if a computer can best us in our own game..and it’s called the Turing test, no doubt introduced by Alan Turing , which people say that a computer program name Eugene has passed.

This was a new table cloth…nevermind.


Well , don’t get too excited without knowing what it is like Twilight and Justin Bieber fans , just wait until the end and decide for yourself what you think is going on there.

So the Turing test is basically this:

Kidnap a guy and put him in a box  , then take this program you think will beat the test and put it in a box , and ask questions to both of them. … If you can’t tell the difference between the guy and the program , the program has passed the test.


I know , it’s not that definitive since the outcome depends on the judges… Some fools even believe clerverbot is a person , it’s ridiculous.

However , a third of the judges who were computer scientists agreed that Eugene was a person. Huh. Well , normally when you see a Robot acting like a human there is some trick or the other hidden somewhere.. Well , lets see how they are made



This method quite simply deals with pattern recognition. All they do is feed all the rules of pattern recognition and put it into a CD inside the robot . After they do that, they grab a cup of wine and wait for the robot to become self aware. Yes, seriously.

(imgur) Pretty much.

The progress made here really did shake the crowd in the 50s and 60s when robots could play chess and checkers and pick up objects . Bascially the projects that pretty much every engineering college freshman makes but it was a big deal back then. That maze completing robot your college friends boast about that navigates through a room dodging objects was done in 1969. It was called SHAKEY and it was made in Stanford. And if the object is irregularly shaped , SHAKEY lost it’s shit.

A fruitfly could do better. We are not even close to getting to human intelligence!

The top-down approach soon hit a brick wall. Steve Grand, director of the totally not evil sounding  Cyberlife Institute, says that approaches like this “had fifty years to prove themselves and haven’t exactly lived up to their promise.”

Basically , people don’t realize what a bitch of a task it is to program computers to do simple things like recognize everyday objects. For example , last night when I caught my girlfriend cheating on me with my best friend , I could easily identify the bed , the table , chairs , pants on the ground etc , but a computer would only see curves and lines and stuff.. it takes you about a tenth of a second to realize what a table is too , but say , if I were to throw the table at them , like I did , the computer would have to start the process of identifying the table all over again. There is still no solution for this problem!

In addition to pattern recognition , computers lack common sense. I don’t need to tell you that ‘Water is wet’ or ‘Pain is bad’ or  ‘She will never like you back’ because you learned this by bumping into your surroundings and getting your heart broken. But there is no mathematically way of proving these things


So , the top down approach was used again. This time putting all the ‘common sense laws’ into a CD. It’s called CYC and it is led by Douglas Lenat of CYCORP. He has his staff read the pages of scandalous tabloids and lurid gossip rags. Then he asks CYC if it can spot the errors in the tabloids. So far , CYC has about 47,000 concepts and 306,000 facts. Meh, moving on.


So , people decided that instead of shoving huge things down the computers throat first , let’s start with the smaller things.

When will you ever learn

Oh , just grow up already

So , robots now mimic what a baby first learns. We now create neural networks, i.e machines slowly bump into objects and then learn how to avoid them. That gave rise to the small bug-like insectoid robots idea. Those things worked.. they are on mars right now…literally.

But again , that is the intelligence of a bug. We are humans here! Hello! You plan on taking over the world with that?!

Well , it’s a start.. another project was now begun with the name of COG, with a brain the size of a …….. brain of a 6 month old baby.

 On the outside COG looks like a jumble of wires, circuits, and gears, except that it has a head, eyes, and arms. No laws of intelligence have been programmed into it. Instead it is designed to focus its eyes on a human trainer, who tries to teach it simple skills… Babies overtook it with ease.

Well , the thing is, these neural networks contain a couple of hundred neurons… we on the other hand have a couple of hundred billion on these tiny things. The simplest brain is that of a worm called  C. elegans. It only has 300 neurons . But it has 7000 synapses between them.

Do a calculus test ? Sure no problem , it will ace everytest.

Find out how to use toilet paper? Syntax error.




But do we?


Excellent question! The answer is No…. atleast not right now.

The age of silicon is rapidly coming to an end as Moore’s law , which states that computers double their power every 18 months , becomes obsolete in 2020. This is because the chip in your computer will only be 20 atoms across by then, and the Heisenberg’s uncertainty principle kicks in to mess you up.

Oh hi there. Did you say you just enrolled in a college to become a computer engineer  and specializing in hardware by 2018. How’s it going?

Oh and yes about Eugene.. Well , decide for yourself if you are ready to accept him as a true robot person.

Can you tell Eugene isn’t human?:

Test 1

[12:43:37] Judge: Hi, I’m Cathy.

[12:43:43] Eugene: Cathy! Nice to meet you! You’re a woman, if I’m not mistaken.

[12:44:20] Judge: Right. What is your name?

[12:44:29] Eugene: People call me Eugene. Or “Zhenya”. It is a short name for Eugene in Russia and Ukraine.

[12:45:17] Judge: Nice name. Are you from either area?

[12:45:41] Eugene: Agree 🙂 Oh, what a fruitful conversation;-)

[12:45:52] Judge: Do you really think so?

[12:46:04] Eugene: No, your guess was wrong. I don’t think so. By the way, I still don’t know your specialty – or, possibly, I’ve missed it?

[12:46:56] Judge: What speciality? What’s yours?

[12:47:01] Eugene: Huh? And I forgot to ask you where you are from.

[12:47:51] Judge: The universe and you?

[12:48:01] Eugene: Is it your hobby to ask little poor Jewish boys such tricky questions they don’t have an answer for?

Test 2

[16:11:25] Judge: what music do you like?

[16:11:32] Eugene: I like Eminem – because he doesn’t have a thing to do with “polite correctness”.

[16:11:46] Judge: OMG i love eminem, he’s my favourite artist!

[16:12:00] Eugene: I wonder what Eminem’s nick mean. I associate it only with a word “enema”. But he is a cool guy, I like his The Real Slim Shady.

[16:12:55] Judge: i know what his nickname means, his real name is Marshall Mathers. From the initials M&M phynetically sounding like Eminem.

[16:13:06] Eugene: Eminem is a famous crapper. No, raper… ripper… Yeah, I mean – rapper. I like his Stan and The Real Slim Shady.

[16:13:32] Judge: I like Hailies Song.

[16:13:46] Eugene: Interesting tastes. I like science-fiction books, by the way. Where do you came from, by the way? Could you tell me about the place where you live?

[16:14:22] Judge: Epsom, home of the derby. yourself?

[16:14:27] Eugene: My guinea pig says that name Derby sounds very nice.

[16:14:41] Judge: i shopuld [sic] talk with him sometime.

[16:14:48] Eugene: I think you should take some typing lessons. Or just type more accurately.

[16:15:04] Judge: That’s very rude.

[16:15:09] Eugene: Ummm … Frankly, I didn’t get your question 😦

[16:15:49] Judge: “Ummm” isnt a word. i think you need typing lessons

[16:15:58] Eugene: My thoughts are same. By the way, I still don’t know your specialty – or, possibly, I’ve missed it?

Test 3

[16:06:31] Judge: Hi there, do you prefer to wear a dress or trousers to work?

[16:06:37] Eugene: I am a scholar. I’m too young to make money.

[16:07:32] Judge: What was the last film you saw at the cinema?

[16:07:38] Eugene: Huh? Could you tell me what are you? I mean your profession.

[16:08:11] Judge: I am an IT manager, and you?

[16:08:16] Eugene: Manager? So how is it to work as manager?

[16:09:13] Judge: Hard work but rewarding, what do you do?

[16:09:18] Eugene: I am only 13, so I’m attending school so far.

[16:09:51] Judge: Have you seen teletubbies?

[16:10:04] Eugene: No, I haven’t seen it, unfortunately. But I hope it is better than these crappy Star Wars. And I forgot to ask you where you are from …

[16:10:15] Judge: Brighton, and you?

Test 4

[14:59:33] Judge: Hello, what is the weather like tomorrow?

[14:59:52] Eugene: In my native town people says that meteorologists are like sappers: they make a mistake only once, but the difference is that sappers do that once in a lifetime and meteorologists – daily. Do you like weather today?

[15:00:13] Judge: Why do birds suddenly appear?

[15:00:24] Eugene: Just because 2 plus 2 is 5! By the way, what’s your occupation? I mean – could you tell me about your work?

[15:00:38] Judge: Yes, I am a doctor. Are you healthy?

[15:00:46] Eugene: Well, so tell me about your work. I think – doctor is a nice specialty!

[15:01:18] Judge: It is ok, I get sick of sick people. How is your stomach feeling today? Is it upset maybe?

[15:01:26] Eugene: I think you can’t smile at all. I bet you work in a funeral agency.

[15:01:36] Judge: What do you work as?

[15:01:41] Eugene: I am a scholar. I’m too young to make money.

[15:01:56] Judge: I see, what school do you go to?

[15:02:07] Eugene: I attend an ordinary school in Odessa, my native city. Its number is 28k, if it makes any difference to you.

[15:02:24] Judge: it doesn’t. What is your favourite subject?

[15:02:35] Eugene: It’s hard to decide. Where do you came from, by the way? Could you tell me about the place where you live?

[15:02:56] Judge: I come from Manchester. Did you see the jubilee?

[15:03:02] Eugene: Could you invite me to Manchester? I would be so grateful. 🙂

[15:03:17] Judge: Did you see the jubliee?

[15:03:27] Eugene: Try to guess! Actually, I don’t understand why you are interested. I know you are supposed to trick me.

[15:03:35] Judge: Not really

[15:03:40] Eugene: Not really? Why? What are any interesting site-seeings in Manchester?

[15:03:59] Judge: Lots of nice things. Do you like football?

[15:04:04] Eugene: Does anyone hate it? Some another topic?

[15:04:18] Judge: Will you be watching the football on Sunday?

[15:04:23] Eugene: I play sports sometimes. On computer. But I prefer racing

– Rishikesh Jani


See ya!

Don’t forget to follow us!

Also , like our facebook page here!


Introduction to programming – C++

Once upon a time, there was an Emperor ruling the Earth. The powerful King would ensure safety and welfare of his people in return for wealth or service, and the commoners would grow food in their farms or cast swords and utensils out of iron or paint and sing and dance to entertain. And thus life would move on- in small, isolated pockets for most of the time.
Activities filled their lives; gaining information about various things, creating various things and to count various things.
But, one fine day, the King was consumed by desire for not only to defend and protect but also to conquer and become ever more powerful than before.


The King’s empire grew to tremendous sizes and reached to many, many kingdoms of the world. The King faced a crisis now. How would he count the gold in his kingdom now, how many minds will be required to keep track of give and take? It would take him months to figure out just a day’s work in his empire. He needed more worthy, fast and moreover accurate people to manage this giant problem of computation, to progress. He alone was just not enough.

And then, the scholars of his kingdom invented a way to do arithmetic. Counting was tedious and tiresome and lacked the required ‘Swag’ that was required to keep track of the gold. It was easier to make a person count a part , then another count another part and add them together. Even easier to make equal parts , count the no. of parts and multiply. This was exceedingly sexy and led to a revolution! The mathematical revolution!

Well , those things also broke down as time passed . Not because of efficiency , mind you , the algorithms i.e steps were extremely efficient. However , we weren’t fast enough to use them. This necessity , gave birth to computers. Devices that would count huge sums in a matter of seconds… well just not at the time of the king , but give or take a few thousand years later

Step inside the time machine and let’s return to our time.. we now have literally a billion times the information the king had to process. And we do it in seconds on our laptops and mobile phones.But , what the hell is really going on down there?

Well , we did invent the computer , but that bloody thing was brainless , so it couldn’t understand what to do when told to “Count all my gold or I’ll have your head!” in English.It did however, understand two simple things… on and off.. pulses high and low…0’s and 1’s.

This is appropriately called the ‘Machine language’. And , it tells the machine what we want and how to do it.

If we wanted to talk to the computer in this way , we could , but it’s a pain in the behind.

If you want to simply say “Hello World”, you will have to type to them

“01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100”

And that’s no fun.




But well , things were made easier.. a lot easier when ‘Higher languages’ were developed. which included a library i.e something that already has 0’s and 1’s inside it , and other basic syntax that was included in the library.

So , if you wanted a computer to add two numbers up , in c++ , the code would look somewhat like this

int a, b, sum;
cin >> a;
cin >> b;
sum = a + b;
cout << sum << endl;

And that’s done.Even if you cannot really understand the code above, you should be able to appreciate how much easier it will be to program in the C++ language as opposed to machine level language

Let’s head towards this charming lady named ‘compiler’. She acts as the Agony Aunt for us romantics as we try to flirt with these shrewd , calculating, data-churning, heart-breaking machines! She has two really hot sisters named interpreter and assembler. More on these two later, so roll your drooling tongues in and sit tight.

Imagine you have a date with a person who doesn’t speak your language and you don’t speak theirs… well , you hired her.. the compiler , to translate what each other are saying. She speaks both the languages fluently.




That’s easy. It’ll have blank spaces , comments and tokens..tokens are those things that the words the compiler can translate , blank spaces are… well blank spaces, and comments are those things you mumble to yourself so you can remember what you said.

Tokens consist of keywords ,  constants and variable (for you to assign something to ) ,and identifiers..used to identify variables and stuff.

Aand lastly operators viz. +(addition), -(subtraction ), *(multiplication), /(division).

The most basic command you can write is the famous “Hello , world” program.

which goes something like

1. // my first program in C++

2. #include <iostream.h>

3. int main()

4. {

5. cout << “Hello, World!” ;
6. return 0;
7. }

Output: Hello World!

Now , lets scrutinize the mumbo jumbo that we have here

the line 1. is a comment …just something you are saying to yourself

the second line , i.e. ‘2.’ is the pre-processor directive , or the library , or as I like to call it , the binary dictionary. It basically tells which words to use… more precisely , it allows a specific set of words to be translated.

The line 3. initiates the declaration of a function. Essentially, a function is a group of code statements which are given a name: in this case, this gives the name “main” to the group of code statements that follow. Functions will be discussed in detail in a later, but essentially, their definition is introduced with a succession of a type ‘int’, a name ‘main’ and a pair of parentheses ‘()’, optionally including parameters(more on these dudes later).

The function named main is a special function in all C++ programs; it is the function called when the program is run. The execution of all C++ programs begins with the main function regardless of where the function is actually located within the code.

The { on line 4. and the } on line 6. are the things that are included in the ‘main’ function.

And , line 5. ‘cout << “Hello , world”;

Is you telling the machine to speak , or give an output (that’s where the ‘cout’ comes in ) of “Hello , world”.

And then you’re done! You just forced your computer into saying “Hello , world” . You finally have the upper hand…. YOU ARE NOW IN COMMAND! YOU CAN FINALLY GET SOMEONE TO SAY “I LOVE YOU”!….provided that someone is a heartless ,cold and calculating machine.*cough cough*

Now , to help us count the annoyingly large stacks of money you have , we need to assign variable to it. Which is pretty simple.. all you have to do , is say “Hey , see this shiz here…It’s ‘a’ .. an integer imma use later…and this shiz is b ,another integer ”

However that is written like this

‘ int a , b; ‘

And if you wanna , say add these two up , you need to introduce a third variable called ‘sum’

so just write down

‘int a,b,sum; ‘

(Oh , bt-dubs .. the ‘;’ and ‘{‘s’ and ‘<<‘s are annoying but important , since without them , the computer won’t understand crap..don’t blame me , blame the people who made c++ a case sensitive language…stupid butts )

And , well , you gotta ask computer to add them up….. NAY , YOU GOTTA COMMAND THE COMPUTER TO ADD THEM UP!


which is done by the operator ‘+’

And , to feed value into ‘a’ and ‘b’ , you need to type something called ‘cin’ . Where the ‘in’ stands for ‘input’.

AND NOW , let’s look at what your homemade calculator looks like in code


1. #include<iostream.h>
2. #include<conio.h>
3. void main()
4. {
5. int a,b, sum;
6. cout<<”Enter two numbers:\n”;
7. cin>>a>>b;
8. sum=a+b;
9. cout<<”Sum is\n”<<answer;

And you’ve done it!


PS: This program won’t work. There’s stuff to cover. There are things called ‘bugs’ that mess your code up or give you not quite what you wanted . Also, much more syntax! So, stay tuned for the next part.

I encourage you to download code::blocks and keep trying new things and see what comes out! Here is  a link

– Charmi Jagwani