FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

WHAT IS PROGRAMMING

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Consider the following:1. Input a number 2 Check to see if the number ends in 0, 2, 4, 6 or 8? a. If yes, write “The number is even.” b. If no, write “The number is odd.” This is an example of which type of control structure?
A
Selection
B
Loop
C
Iteration
D
Sequence
Explanation: 

Detailed explanation-1: -In the program, the integer entered by the user is stored in the variable num . Then, whether num is perfectly divisible by 2 or not is checked using the modulus % operator. If the number is perfectly divisible by 2, test expression number%2 == 0 evaluates to 1 (true). This means the number is even.

Detailed explanation-2: -To determine whether a number is even or odd, it is divided by 2. If the remainder obtained after division is 0, then the number is referred to as an even number. On the other hand, when the remainder is not equal to zero, then the number is called an odd number.

Detailed explanation-3: -So what is it-odd, even or neither? For mathematicians the answer is easy: zero is an even number.

There is 1 question to complete.