I'm writing a program to work with complex numbers. It actually works well for what I need it for but there is a problem I would like to solve. Here is the code in question:
Right now if I enter a number it works quite well. But let's say I entered the word "banana". The program crashes. How can I avoid this?Code:int option; do { printf("\nHere are the options for the complex number arithmetic program:"); printf("\n1. Add two complex numbers."); printf("\n2. Subtract two complex numbers."); printf("\n3. Multiple two complex numbers."); printf("\n4. Divide two complex numbers."); printf("\n5. Find the conjugate of a complex number."); printf("\nEnter the number of your choice and press enter:"); scanf("%d",&option); } while (option<1 || option>5); printf("SUCCESS");



LinkBack URL
About LinkBacks



