I pretty much got the assignment done. All it asked for was that you make a C program that displays which manufacturer owned a disk drive based on the code entered. Pretty simple. Just enter 1, 2, 3, or 4 and get the associated manufacturer. Though I am trying to implement an error messege to it for any interger that isn't 1-4.
Code:
#include <stdio.h>
int main()
{
int code;
printf("Please enter the Disk Drives code: ");
scanf("%d", &code);
switch (code)
{
case 1:
printf("The code entered was %d and the associated manufacturer is 3M Corporation", code);
break;
case 2:
printf("The code entered was %d and the associated manufacturer is Maxwell Corporation", code);
break;
case 3:
printf("The code entered was %d and the associated manufacturer is Sony Corporation", code);
break;
case 4:
if (code = 4)
printf("The code entered was %d and the associated manufacturer is Verbatim Corporation", code);
else
printf("The code entered was %d and is not related to any corporation.", code);
break;
}
return 0;
}
I also tried this, but it didn't work either.
Code:
case 4:
if (code < 1 || code > 4)
printf("The code entered was %d and is not related to any corporation.", code);
else
printf("The code entered was %d and the associated manufacturer is Sony Corporation", code);
break;
}
No errors are given and it works fine as long as you enter 1-4, but when you enter any other didgit it just stops the program without any messeges.
Thanks!