Question
/* Determine if the numbers between 2 and 9 are prime numbers */ #include int main() { int c, number, i=0; printf(Enter a number between
/* Determine if the numbers between 2 and 9 are prime numbers */
#include
int main()
{
int c, number, i=0;
printf("Enter a number between 2 and 9 ");
scanf("%d", &number);
for ( c = 2; c <= number; c++);
{
if(c % i == 0)
number = number + 1;
}
switch(number)
{
case 2:
case 3:
case 5:
case 7:
printf("You entered a prime number ");
break;
case 4:
case 6:
case 8:
printf("You entered a composite number ");
break;
default:
printf("Invalid value entered. ");
}
return 0;
}
This is the program i wrote for my C problem, I think I'm having difficulty determining if the number is prime. I don't know where I went wrong. It has to be a switch statement.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started