🔍 Problem Solving from Codeforces using C language
This is a problem-solving post from Codeforces. Below is the problem with a short explanation and its solution.
This example is solved using C language.
🧩 Main Problem: Given a number N. Print all even numbers between 1 and N inclusive in separate lines.
🔗 Problem Link: Codeforces Problem
💡 Solution:
#include <stdio.h>
int main()
{
int x;
scanf("%d", &x);
int i;
for (i = 1; i <= x; i++)
{
if (i % 2 == 0) printf("%u\n", i);
}
if (x==1) printf("-1");
return 0;
}
✅ This solution reads four integers from user and calculate using the given equation.
📝 Input:
10
📄 Output:
2
4
6
8
10
📝 Input:
5
📄 Output:
2
4
🔗 Find Similar Problems from Codeforces– Click Here
🤔 More Problem Solving – Click Here
📘 Learn C Programming – Click Here