6 B

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include<setjmp.

h>
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
jmp_buf buf;
void addition(int a,int b)
{
int c;
c=a+b;
printf( sum is %d \n,c);
}
void division(int a, int b)
{
int c;
if(b==0)
longjmp(buf,1);
else
{
c=a/b;
printf(quotient is %d \n,c);
}
void cacl_calci(int x, int y,char ch)
{
if(ch==+)
addition(x,y);
else if(ch==/)
division(x,y);
}
int main()
{
int a,b;
char op;
fflush(stdin);
printf(enter operator);
scanf(%c, &op);
printf(enter values of operands);
scanf(%d %d, &a,&b);
fflush(stdin);
if(setjmp(buf)!=0)
{
printf(error \n);
exit(0);
}
cal_calci(a,b,op);
exit(0);
}

You might also like