abort C Library Function

The function void abort(void); aborts the program execution at the place of the call, producing an abnormal program termination. The abort function raises the SIGABRT signal, and causes abnormal program termination returning a platform-dependent unsuccessful termination error code.

Function prototype of abort

void abort(void);

Return value of abort


C program using abort function

The following program shows the use of abort function to terminate a program in case of some run-time exception.

abort C Library Function

#include <stdio.h>
#include <stdlib.h>
int main(){
    int numerator, denominator;
    printf("Enter numerator and denominator for division\n");
    scanf("%d %d", &numerator, &denominator);
    if(denominator == 0){
        printf("Aborting program\n");
        printf("It won't get printed ever\n");
    } else {
        printf("Quotient : %lf", (double)numerator/denominator);
    return 0;


Enter numerator and denominator for division
5 0
Aborting program
Enter numerator and denominator for division
5 2
Quotient : 2.500000