Invoke function without main in C Language

Invoke function without main in C Language.

#include<stdio.h>
#include<conio.h>

#define FIRST   0
#define SECOND  1
#define THIRD   2


//Variables
int a,b,c,ch;
float d;
//Function Prototype
void Read();
void Operation();
void Display();

#pragma startup Read       0 //First_Priority
#pragma startup Operation  1 //Second_Priority
#pragma exit Display     //Third_Priority

void main()
{
 printf("

Enter to main() ");
 getch();
 printf("

Exit From main() ");
 getch();
}

void Read()
{
 clrscr();
 printf("
Enter the value of a : ");
 scanf("%d",&a);
 printf("
Enter the value of b : ");
 scanf("%d",&b);
}

void Operation()
{
 printf("
ArithMetic Operations
");
 printf("---------------------
");
 printf("1  -> Addition
");
 printf("2  -> Subtraction
");
 printf("3  -> Multiplication
");
 printf("---------------------
");
 scanf("%d",&ch);
 switch(ch)
 {
  case 1:
     c = a+b;
     break;
  case 2:
     c = a-b;
     break;
  case 3:
     c = a*b;
     break;
 }
}

void Display()
{
 switch(ch)
 {
  case 1:
    printf("

The Result (Addition) : %d",c);
    break;
  case 2:
    printf("

The Result (Subtraction): %d",c);
    break;
  case 3:
    printf("

The Result (Multiplication): %d",c);
    break;
  }
  getch();
}

Comments

Popular posts from this blog

C Program to Display the ATM Transaction

Java programming language

Python Program to Print all Prime Numbers in an Interval