HOW TO HANDLE EXCEPTIONS IN C

Answer Posted / chandan

There is no try,catch(available in C++,java..) facility to
handle exception in C.but we can handle exception by
validating data come from outside into the program.
eg.. cosider this code
void main(){
int a,b,div;
scanf("%d,%d",a,b)
div=a/b;
printf("%d",div);
}
int this case , b might be zero that will generate an
exception.so we can avoid it by using if statement.
if(b==0)
print("plz enter non zero value");

In this manner only we can prevent exception in C..

Thank you

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you please explain the difference between syntax vs logical error?

918


Disadvantages of C language.

837


‎How to define structures? · ‎

834


What is the total generic pointer type?

919


What are the types of pointers in c?

736


Hai what is the different types of versions and their differences

1721


How can I direct output to the printer?

1058


‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

2576


What do you mean by invalid pointer arithmetic?

825


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

1923


Describe wild pointers in c?

846


How is = symbol different from == symbol in c programming?

804


How can I handle floating-point exceptions gracefully?

872


What is a list in c?

792


Where register variables are stored in c?

738