#define ADDITION = addition
#define SUBTRACTION = subtraction
#define MULTIPLICATION = multiplication
#define DIVISION = division
#define MODULAR = modular
#endif

int main() {

	int userInput = 0;
	int userInput2 = 0;
	int userInput3 = 'A', 'S', 'M', 'D', 'Q';
	int sum = 0;
	
// modular is q while m is multiplication
	printf(" Programming Assignment #2 - by Geoffrey \n");
	printf("\n");

	printf("please enter the First Number:");
	scanf("%d", &userInput);
	fflush(stdin);
	printf("please enter the Second Number:");
	scanf("%d", &userInput2);
	fflush(stdin);

if (userInput >= -1000 && userInput <= 1000 && userInput2 >= -1000 && userInput2 <= 1000); {
		printf("Please select an operation to put in the blank space");
		printf("%d_%d=", userInput, userInput2);
}
	
	if else (userInput <= -1001 && userInput >= 1001 && userInput2 <= -1001 && userInput >= 1001); {
			printf("Please Re-enter a number between -1000 and 1000");
			scanf("%d", &userInput);
			fflush(stdin);
			scanf("%d", &userInput2);
			fflush(stdin);
			}


	while (userInput >= -1000 && userInput <= 1000 && userInput2 >= -1000 && userInput2 <= 1000 == 1); {
			printf("type the associated letter and press enter:\n");
				printf(" A - Addition\n S - Subtraction\n M - Multiplication\n D - Division\n Q - Modular\n");
				scanf("%c", userInput3);
				fflush(stdin);


				while (userInput3 == 'A'); {
					printf("%d + d% = %d",sum = userInput + userInput2); 
				
						while (userInput3 == 'S'); {
						printf("%d - %d = %d", sum = userInput - userInput2);
					
						while (userInput3 == 'M'); {
						printf("%d * %d = %d", sum = userInput * userInput3);
						
						while (userInput3 == 'D'); {
								printf("%d / %d = %1d", sum = userInput / userInput2);
							
						while (userInput3 == 'Q'); {
									printf("%d % %d = %d", sum = userInput % userInput2);
								
						while (userInput3 == 0 ); {
									printf("Please Type eithor: A,S,M,D,Q\n");
						}
						}
						}
						}
						}
				}
	}

				
			
		return(0);
			}

Recommended Answers

All 2 Replies

#define ADDITION = addition
#define SUBTRACTION = subtraction
#define MULTIPLICATION = multiplication
#define DIVISION = division
#define MODULAR = modular

Find what's wrong with those

#define ADDITION = addition
#define SUBTRACTION = subtraction
#define MULTIPLICATION = multiplication
#define DIVISION = division
#define MODULAR = modular
#endif

int main() {

	int userInput = 0;
	int userInput2 = 0;
	int userInput3 = 'A', 'S', 'M', 'D', 'Q';
	int sum = 0;
	
// modular is q while m is multiplication
	printf(" Programming Assignment #2 - by Geoffrey \n");
	printf("\n");

	printf("please enter the First Number:");
	scanf("%d", &userInput);
	fflush(stdin);
	printf("please enter the Second Number:");
	scanf("%d", &userInput2);
	fflush(stdin);

if (userInput >= -1000 && userInput <= 1000 && userInput2 >= -1000 && userInput2 <= 1000); {
		printf("Please select an operation to put in the blank space");
		printf("%d_%d=", userInput, userInput2);
}
	
	if else (userInput <= -1001 && userInput >= 1001 && userInput2 <= -1001 && userInput >= 1001); {
			printf("Please Re-enter a number between -1000 and 1000");
			scanf("%d", &userInput);
			fflush(stdin);
			scanf("%d", &userInput2);
			fflush(stdin);
			}


	while (userInput >= -1000 && userInput <= 1000 && userInput2 >= -1000 && userInput2 <= 1000 == 1); {
			printf("type the associated letter and press enter:\n");
				printf(" A - Addition\n S - Subtraction\n M - Multiplication\n D - Division\n Q - Modular\n");
				scanf("%c", userInput3);
				fflush(stdin);


				while (userInput3 == 'A'); {
					printf("%d + d% = %d",sum = userInput + userInput2); 
				
						while (userInput3 == 'S'); {
						printf("%d - %d = %d", sum = userInput - userInput2);
					
						while (userInput3 == 'M'); {
						printf("%d * %d = %d", sum = userInput * userInput3);
						
						while (userInput3 == 'D'); {
								printf("%d / %d = %1d", sum = userInput / userInput2);
							
						while (userInput3 == 'Q'); {
									printf("%d % %d = %d", sum = userInput % userInput2);
								
						while (userInput3 == 0 ); {
									printf("Please Type eithor: A,S,M,D,Q\n");
						}
						}
						}
						}
						}
				}
	}

				
			
		return(0);
			}

I found many syntax errors in the program.
1.

#define ADDITION = addition
#define SUBTRACTION = subtraction
#define MULTIPLICATION = multiplication
#define DIVISION = division
#define MODULAR = modular
#endif

The assignment operator is not needed when you are defining macros.

#define identifier replacementtext

is enough.

ii)

int userInput3 = 'A', 'S', 'M', 'D', 'Q';

what do you want this statement to do.

2.

#endif

should have some #if or #ifdef or #ifndef at the beginig but i think here #if .. #endif is not needed.
3.

if else (userInput <= -1001 && userInput >= 1001 && userInput2 <= -1001 && userInput >= 1001);

should be else if ( ...) without semicolon
similarly all while loops
why do you want to use so many whiles for this simple code.

correct the code by correcting all the above mentioned.

better include<stdio.h>
and use
__fpurge(stdin); if you are using linux instead of
fflush(stdin);

commented: good explanation +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.