Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java g. You have two JoRels tO De 24 hours delay. Once the homework is discussed

ID: 3721977 • Letter: J

Question

Java g. You have two JoRels tO De 24 hours delay. Once the homework is discussed in class no joker is accepted 1. Write a program that generates a set of numbers based on differed criteria. Use a switch statement to handle the user choice and for loop to generate the numbers. You need to use do/while to repeat the menus for the user. Sample Run Enter an interval (a, b): 1 10 1. Odd Numbers 2. Even Numbers 3. Numbers can be divided by 3 4. Exit Choose an option: 1 The new sequence is 1 3 5 79 1. Odd Numbers 2. Even Numbers 3. Numbers can be divided by 3 4. Exit Choose an option: 3 The new sequence is 3 6 9 1. Odd Numbers 2. Even Numbers 3. Numbers can be divided by 3 4. Exit Choose an option:4 Thank You!!

Explanation / Answer

#include <stdio.h>

#include<stdio.h>

int main(void) {

int a,b,ch,i;

printf("Enter an interval (a,b): ");

scanf("%d%d",&a,&b);

do

{

printf(" 1. Odd number");

printf(" 2. Even number");

printf(" 3. Number can be divided by 3");

printf(" 4. Exit");

printf(" Choose an option:");

scanf("%d",&ch);

switch(ch)

{

case 1: printf(" The new sequence is");

for(i=a;i<=b;i++)

{

if(i%2!=0)

printf(" %d",i);

}

break;

case 2: printf(" The new sequence is");

for(i=a;i<=b;i++)

{

if(i%2==0)

printf(" %d",i);

}

break;

case 3: printf(" The new sequence is");

for(i=a;i<=b;i++)

{

if(i%3==0)

printf(" %d",i);

}

break;

case 4: break;

}

}while(ch>=1 && ch<=4);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote