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?

#include<stdio.h>

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

Output

WAP to input the limit from the user and print all the even and odd numbers up to that?
List of even and odd number until 5

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments