Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/* 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

Students also viewed these Databases questions