In: Computer Science
Create a basic program (C programming language) that accomplishes the following requirements:
Program:
#include <stdio.h>
int main()
{
int x, y;
printf("Enter 2 numbers:\n");
// Takes input of starting number from user
printf("Enter starting number : ");
scanf("%d",&x);
// Takes input of ending from user
printf("Enter ending number : ");
scanf("%d",&y);
// Loop iterates till the x is less than or equal to y
while (x <= y) {
// Printing the current number
printf("Current number is: %d\n", x);
// Condition to check if x is even
if (x%2 == 0) {
// Printing the current number is even
printf("The current number is even\n");
// Multiplying the number with 3 and print the result
printf("%d\n", x*3);
} else { // If x is odd
// Printing the current number is odd
printf("The current number is odd\n");
// Adding 10 to the number and print the result
printf("%d\n", x+10);
}
// Incrementing the x value
x++;
}
return 0;
}
Output: