473,396 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

why we write return 0 at the end of program

mostly we write getch at the end..and what is the diference in between getch and return 0
Oct 11 '13 #1

✓ answered by Nepomuk

Hi swapnil gaikwad and welcome to bytes.com!

I think explaining what those two statements do will make it clear where the difference lies. So here goes:
  • getch is a function that will wait for input and then read this input. It is often used at the end of programs to make sure the window you run it in doesn't close immediately. You can however use it to read input.
  • return is a statement used to return a value at the end of a function. If you define a function yourself you will use this to decide what the result of that function should be. In the main function it is used to give feedback to the caller, meaning the program that started your program. This is often the command line or the IDE. If you return 0 at the end and this value is interpreted, 0 means "everything is OK". Returning a different value is often interpreted as an error, so this is a method to get error codes.
Hope that helps.

2 15090
mostly we write getch() at the end of program.so why we write return 0 ..and what is the difference in between getch and return 0
Oct 11 '13 #2
Nepomuk
3,112 Expert 2GB
Hi swapnil gaikwad and welcome to bytes.com!

I think explaining what those two statements do will make it clear where the difference lies. So here goes:
  • getch is a function that will wait for input and then read this input. It is often used at the end of programs to make sure the window you run it in doesn't close immediately. You can however use it to read input.
  • return is a statement used to return a value at the end of a function. If you define a function yourself you will use this to decide what the result of that function should be. In the main function it is used to give feedback to the caller, meaning the program that started your program. This is often the command line or the IDE. If you return 0 at the end and this value is interpreted, 0 means "everything is OK". Returning a different value is often interpreted as an error, so this is a method to get error codes.
Hope that helps.
Oct 11 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

33
by: Nick Evans | last post by:
Hello there, I have been on and off learning to code (with python being the second language I have worked on after a bit of BASIC). What I really want to know is, if you are going to actually...
8
by: Zheng Da | last post by:
I don't know where should I ask the question, so send the email to this group. I choose this group, because I want to write the program with c++ :) I want to write a program which support...
8
by: brian.digipimp | last post by:
I turned this in for my programming fundamentals class for our second exam. I am a c++ newb, this is my first class I've taken. I got a good grade on this project I'm just wondering if there is a...
7
by: Randy Yates | last post by:
Hi, I work in an embedded environment in which we often use a mix of C and assembly code. Thus a recurring requirement is to be able to take a C header file with structure definitions as input...
2
by: susmitasp | last post by:
Question: 24students registered to the class. Write C++ program to find how many students with age range of: //- less than 25 //- 26-30 //- 31-40 //- 41 and above Please try to help me to...
19
by: pitamber kumar | last post by:
Write a program to find the number of and sum of all intergers greater than 100 & less than 200 that are divisible by 7.
11
by: Jordan218 | last post by:
Hi. How do I write a program that sums the digits of a 4-digit number? I have a program that works, but you have to input the digits separately. Can anyone help or possibly explain what I'm doing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.