A
amanayin
As i am not at school for c programming can you please
tell me if there is anything bad about this program
/* EX4-9.C FUNCTION TO CALL OTHER FUNCTIONS */
#include<stdio.h>
float div(float a, float b);
float multi(float a, float b);
void call(void);
float a,b,c;
char z;
int main(void)
{
printf("Enter m to multiply or d to divid:");
scanf("%c",&z);
printf("Enter two numbers: ");
scanf("%f %f", &a, &b);
call();
return 0;
}
float div(float a, float b)
{
float c;
if(b == 0)
printf("The divisor should not be a zero\n");
else
c = a / b;
return c;
/* OR return(a / b); */
}
float multi(float a, float b)
{
int c;
return (c = a * b);
/* OR return(a * b); */
}
void call(void)
{
if(z == 'm')
c = multi(a,b);
else
c = div(a,b);
if(z != 'm' && z != 'd'){
c = 0;
printf("Incorrect operator\n");
}
printf("Output %f\n",c);
}
tell me if there is anything bad about this program
/* EX4-9.C FUNCTION TO CALL OTHER FUNCTIONS */
#include<stdio.h>
float div(float a, float b);
float multi(float a, float b);
void call(void);
float a,b,c;
char z;
int main(void)
{
printf("Enter m to multiply or d to divid:");
scanf("%c",&z);
printf("Enter two numbers: ");
scanf("%f %f", &a, &b);
call();
return 0;
}
float div(float a, float b)
{
float c;
if(b == 0)
printf("The divisor should not be a zero\n");
else
c = a / b;
return c;
/* OR return(a / b); */
}
float multi(float a, float b)
{
int c;
return (c = a * b);
/* OR return(a * b); */
}
void call(void)
{
if(z == 'm')
c = multi(a,b);
else
c = div(a,b);
if(z != 'm' && z != 'd'){
c = 0;
printf("Incorrect operator\n");
}
printf("Output %f\n",c);
}