#include<iostream.h> #include<conio.h> void main() { int n,k=0,l=0; clrscr(); cout<<"\nenter n:"; cin>>n; cout<<"\neven nums are:"; for(int i=0;i<=n;i++) if(i%2==0) { cout<<"\t"<<i; k++; } cout<<"\nnum of evens:"<<k; cout<<"\nodd nums are:"; for(i=0;i<=n;i++) if(i%2!=0) { cout<<"\t"<<i; l++; } cout<<"\n no of odds are:"<<l; getch(); }
Sunday, 7 December 2014
C++ program to print even or Odd numbers within given range
Posted by Madan
Posted on 14:39