May 7, 2012

C program to demonstrate assert macro.

Write a C program to demonstrate assert macro.
assert macro defined in assert.h library. assert is mainly used for debugging. assert function checks the conditions at run time, and program executes only if the assert is true otherwise program aborts and shows the error message.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

* You can use all the programs on
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact
* To find more C programs, do visit
* and browse!
*                      Happy Coding

#include <stdio.h>
#include <assert.h>
int main()
    int num1, num2;
    printf("Enter two numbers:\n\n");
    scanf("%d %d", &num1, &num2);
    assert(num2 != 0);
    printf("%d/%d = %.2f\n", num1, num2, num1/(float)num2);
    return 0;
Read more Similar C Programs
Learn C Programming
Number System
You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link