Hi im having a problem whem attempting to calculate using negative
with small numbers example==-2 1 + im getting the error message instead of the answer. PLZ HELP!!!
Code:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#define ERROR5 "Input strings too long. Applies to numbers and operators."
#define ERROR4 "Operation not possible."
#define ERROR3 "Division by zero."
#define ERROR2 "Unknown operation."
#define ERROR1 "Number contains alphabetic characters."
#define MAX 11
void main()
{
float Divide1,Divide2 = 0.0;
void function(char,float,float);
int Num1, x=0;
int Num2,y;
char isdigit(char);
char Str2[MAX];
char Str1[MAX];
char Operator;
do
{
printf("\nPlease enter the required calculation\n");
scanf("%s %s", &Str1, &Str2);
if (strlen(Str1) > MAX-1)
printf(ERROR5);
else if (strlen(Str2) > MAX-1)
printf(ERROR5);
Divide1= atof(Str1);
Divide2= atof(Str2);
if ((*Str2) == 'S')
printf("%f\n",sqrt(Divide1) );
else if ((*Str2) == 'R')
printf("=%f\n",1/Divide1 );
else for (y=0; y<MAX; y++)
{
if(isdigit (Str1[y] & Str2[y]))
x = 6;
else if (x != 6)
x = 2;
}
if(x == 2)
printf(ERROR1);
else if (x == 6)
{
scanf(" %s", &Operator);
Num1= atoi(Str1);
Num2= atoi(Str2);
switch(Operator)
{
case '+':
printf("= %d", Num1+Num2);
break;
case '-':
printf("= %d \n", Num1-Num2);
break;
case '*':
printf("=%d ", Num1*Num2);
break;
case '/':
function(*Str2,Divide1,Divide2);
break;
default:
printf(ERROR2);
}
}}
while((*Str1) != "EXIT");
getch();
}
void function(char Str2, float Divide1, float Divide2)
{
if(Str2 == '0')
printf(ERROR3);
else
printf("=%f",Divide1/Divide2);
}