WAP to input the limit from the user and print all the even and odd numbers up to that?

Write a program to input the limit from the user and print all the even and odd numbers up to that using for loop?

#include<stdio.h>

int main() {
	int i,n;
	printf("Enter any number: ");
	scanf("%d",&n);
	for(i=1;i<=n;i++) {
		if(i%2==0)
		printf("Even number %d\n",i);
		else
		printf("Odd number %d\n",i);
	}
	return 0;
}

Output

WAP to input the limit from the user and print all the even and odd numbers up to that?
List of odd and even number till 5
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments