5. Difference between int and void return type with main                function

Code : 


#include<stdio.h>
#include<conio.h>
/*Difference between int return type
 and void return type with main function*/
void main()
{
  printf("hello world");
  getch();
}

Void return type have no return value.So this main function gives output without return any value.

Next let's see int main() function...

int main()
{
  printf("hello world");
  getch();
  return 0;
}

Int return integer value so we return any integer value in main function.

Output of both function : hello world

4. Function "Exit" should have a prototype Error

 Code:

#include<stdio.h>
#include<conio.h>
void main()
{
 int a;
 while(1)
 {
   printf("1.Menu\n2.exit");
   printf("\nEnter your choice::");
   scanf("%d",&a);
   switch(a)
   {
    case 1:printf("\nYour choice is Menu");
    break;
    case 2:exit(0);
   }
   getch();
 }
}




Error: Function exit() should have a prototype
  • This type error occur due to missing library file.
  •  So just add header file #include<stdlib.h>  in above program.
  • Run  again program in turbo c++ and see output.

Note : Here we need compulsory add header file for standard library for use exit function.      

3.Comment in C ,C++ and JAVA

  1. In C:
  •   Single Line Comment::
                  //    -> It is used for single line comment.

  •   Multi-Line Comment::
                 /*.................................*/

                 It is used for Multi-Line Comment.      

 2. In C++:

  •   Single Line Comment::
                  //    -> It is used for single line comment.

  •   Multi-Line Comment::
                 /*.................................*/

                 It is used for Multi-Line Comment.  

3. In JAVA:

  •   Single Line Comment::
                  //    -> It is used for single line comment.

  •   Multi-Line Comment::
                 /*.................................*/

                 It is used for Multi-Line Comment.  

Note : We can write comment in C++ and JAVA language using same way which is used in C language.

2.Statement Missing Error


Basically this type of error occur when programmer is begineeer

How to solve it?
  • This type error is solve by adding Semi-colon at the end of statement.
  • Here Message box show basically error in line 6,but exactly error is occur in line 5.
  • Write printf("Hello world"); and solve error.


1 : Display your coding output in turboC++(For begineer choice)



Function : getch();
In turbo  C++ without getch() function ,we can't show our output.

How to solve it?
  • Add first header file : #include<conio.h>
  • Call function in main method : getch()