The exit() function is use to terminate a program. The header file for exit() function is stdlib.h
Example 1: WAP to find a input number is prime or not using exit() function.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int n, i;
printf("Enter number: ");
scanf("%d", &n);
for (i=2; i<=n/2; i++)
{
if(n%2==0)
{
printf("\n%d is not a Prime Number",n);
getch();
exit(0);
}
}
printf("\n%d is a Prime Number",n);
}
Gotoxy function is use to print the statement at appropriate position on the screen. The parameters passed to gotoxy() are column number and row number.
Example 2: Print message "Hello" in the 5th row and 20th column. (Run in Turbo C++ IDE)
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
gotoxy(20,5); //gotoxy(col, row);
printf("Hello");
getch();
}