Answer to Question #300680 in C for Nobody

Question #300680

Create a program based on the sample output using the do-while loop.


--Choices--

1-EVEN 2-ODD 3-EXIT


Enter Your Choice Above : 2


Enter a Number : 16

Odd Numbers : 1 3 5 7 9 11 13 15


Enter Your Choice Above : 1


Enter a Number : 8

Odd Numbers : 2 4 6 8


Enter Your Choice Above : 2


Enter a Number : 0


Your Program is about to exit...

Thank You!


1
Expert's answer
2022-02-23T00:10:14-0500
#include <stdio.h>

int main() {
    int num;
    int num2;
    int start;
    do
    {
        printf("\n1-EVEN 2-ODD 3-EXIT\nEnter Your Choice Above: ");
        scanf("%d", &num);
        if (num != 0 && num != 3) {
            printf("\nEnter a Number: ");
            scanf("%d", &num2);
            if (num == 1) {
                printf("Even numbers: ");
                for (int i = 2; i <= num2; i+=2) {
                    printf("%d ", i);
                }
            } else if (num == 2){
                printf("Odd numbers: ");
                for (int i = 1; i <= num2; i+=2) {
                    printf("%d ", i);
                }
            }
        }
    }while(num != 0 && num != 3);
    printf("Your Program is about to exit...\nThank You!\n");

    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

nobody
17.08.22, 14:47

Thank You!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS