Jump to content

Simple Two-number calculator in C++


NiharG

Recommended Posts

lol why, i sometimes use them to get out of tight spots

I already explained why in my previous posts. Here read this--

No there aren't any bugs but it gives rise to a lot of problems later on. After a software is made it has to maintained and enhanced. Bugs have to removed, improvements and new features have to be to be added and the software has to be tweaked from time to time as per the clients changing business needs. So after a software is developed it has to be maintained by a separate group of people. Since goto is an unconditional program branching the maintenance guy reading your code might not understand why you have used it in your program. So in any software development company the goto statement is banned. Only conditional branching is allowed.

Link to comment
Share on other sites

y goto is punishable?we can write comments why we used  can't we?

Well its banned in all respectable software development companies i know of. The GOTO statement is a very poor shortcut. You use GOTO statement only when you can't think of any other logical way to write your program. Using the GOTO statement is in essence an act of desperation. So good programming practice forbids you from using it.

Link to comment
Share on other sites

Well its banned in all respectable software development companies i know of. The GOTO statement is a very poor shortcut. You use GOTO statement only when you can't think of any other logical way to write your program. Using the GOTO statement is in essence an act of desperation. So good programming practice forbids you from using it.

So instead of goto u make different functions And return them?

Update: Putting && also does the job.

it will do '&&' means that like if u have 5 condtions than all must be true than only if part would be executed And '||' means that if one of any 5 conditions is true than it will executed And '!=' means that should not be equal to that than only condition will become true And if part will be executed ..And '==' means that is equal to And '=' means you are addressing it!! Hope u were knowing all these!!
Link to comment
Share on other sites

while And do-while will be dificult for me!! i'll do that only!!

But in some cases you will need to use a while loops. Use functions for now. When you become confident in loops you can start using while loops. Its pretty easy really and is less resource hungry and doesn't involve the function call overheads.

Link to comment
Share on other sites

But in some cases you will need to use a while loops. Use functions for now. When you become confident in loops you can start using while loops. Its pretty easy really and is less resource hungry and doesn't involve the function call overheads.

less resource hundry :-/ I don think any of my c program will every took more than 2 mb ram too!!
Link to comment
Share on other sites

You have to think about the time when your functions will be hundreds of lines long.

dude i wanna know a thing i didn't remember exact example to explain that to u but like

When there are users to search their roll no. And we need to build a search program for that.than that process would be very lengthy to compare every string with user requested And it will take hours if thr were millions of strings present so can't we make every string store in the same memory address? like roll no. 4567 will be stored in memory adress 4567 if we made that possible than searching would be of seconds as just we have to jump to that adress we searched for!!

Link to comment
Share on other sites

dude i wanna know a thing i didn't remember exact example to explain that to u but like

When there are users to search their roll no. And we need to build a search program for that.than that process would be very lengthy to compare every string with user requested And it will take hours if thr were millions of strings present so can't we make every string store in the same memory address? like roll no. 4567 will be stored in memory adress 4567 if we made that possible than searching would be of seconds as just we have to jump to that adress we searched for!!

for getting fast searching there are many algorithms like binary search
Link to comment
Share on other sites

dude i wanna know a thing i didn't remember exact example to explain that to u but like

When there are users to search their roll no. And we need to build a search program for that.than that process would be very lengthy to compare every string with user requested And it will take hours if thr were millions of strings present so can't we make every string store in the same memory address? like roll no. 4567 will be stored in memory adress 4567 if we made that possible than searching would be of seconds as just we have to jump to that adress we searched for!!

No its not possible to do that. You cannot store variables in memory addresses equal to their values.

To search something in a large amount of data we can sort the data and use binary search instead of linear search which results in extremely fast searching time. But sorting the data isn't really possible all the time in real life. Suppose you have 100 million strings and you need to find one particular string among them. In that situation it is not practically possible to sort 100 million alpha-numeric strings. So in such situations we employ a method known as indexing. If your database is indexed properly it takes only a few seconds to find any data amongst even 100 million data members.

Link to comment
Share on other sites

it will do '&&' means that like if u have 5 condtions than all must be true than only if part would be executed And '||' means that if one of any 5 conditions is true than it will executed And '!=' means that should not be equal to that than only condition will become true And if part will be executed ..And '==' means that is equal to And '=' means you are addressing it!! Hope u were knowing all these!!

I know all these. Thats why I can make a program :P
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...