C/C++

Objectives : How to quit a function using return and exit function in C programming language.

  • File Name : return_exit_functions1.c
  • Input and Output operations with scanf() and printf() functions of "stdio.h" library.
  • To remind you that "#include <headerfle>" work as a preprocessor directives and prevent loading this module more than once.
                #include <stdio.h>// scanf() and printf() functions
                #include <stdlib.h>// exit() function
  • Jump or goto function:  allowing you start over again from a defined preceding point. 
  • To quit return() or exit() with conditional statement.
  • Code: return_exit_functions1.txt
 

Step: 1 Create a source file, with Quincy 2005. This example may cause problem during runtime when compiled with recent C++ compilers, and complementary plugins with Eclipse /NetBeans IDE.  Please use Quincy 2005, to repeat this example

Make sure that your compiler support C language, you will get several errors.

Step: 2 Edit and save Source file

Step: 3 Runtime Views:

a) testing Number 14 (return 0), for signal completion;

b) testing for (return(1); for non-zero or signal incompletion error

c) testing for exit() : functions similar to return

Step: Brief Discussion:

This example was created as a preface to another example where we intend to discuss the back-end compatibility of C++ with C language. compare_c_cplus2.htm

The IDEs like NetBeans and Eclipse, allow developers to add plug-ins to create C++ projects.  In Eclipse, the header file, “#include <iostream>”, will let us use printf() or exit() functions  of C language.  compare_c_cplus2.htm

The goto statement in C/C++ languages is a jump statement which allows the cursor to jump from one point to another point within a function. The goto statement is marked by label statement, can be alpha-numeric and you can't use integer alone. This statement can be used anywhere in the function above or below the goto statement, and with this statement you may skip embedded instructions.