Given a number N, we need to find the Nth even number.
An even number is a number that is divisible by 2 with a remainder of zero. For example, 2, 4, 6, 8, 10, etc.
If we look closely at lists of even numbers, we can also represent them as
2*1=2, 2*2=4, 2*3=6, 2*4=8,. ..2*N.
So, to solve this problem, we can simply multiply the number N by 2 so that the result is a number that is divisible by 2, i.e. an even number.
Input: n = 4 Output: 8 The first 4 even numbers will be 2, 4, 6, 8, .. Input: n = 10 Output: 20
START STEP 1-> DECLARE AND SET n AS 10 STEP 2-> PRINT n*2 NUMBER STOP
#include <stdio.h> int main(int argc, char const *argv[]){ int n = 10; printf("Nth even will be:%d", n*2); return 0; }
Nth even will be:20
The above is the detailed content of C program to find the nth even number. For more information, please follow other related articles on the PHP Chinese website!