Sunday, 7 December 2014

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class stu
{
int x,i,j,a,b,n,ch;
public:
void putdata()
{
do
{
     cout<<"\n\n1.PRIME NUMBERS\n2.POLINDROME\n3.EVEN&ODD\n4.exit\nENTER UR CHOICE:\t";
     cin>>ch;
     switch(ch)
     {
	   case 1:
	   x=0;
	 cout<<"\nenter range:";
	 cin>>n;
	 cout<<"\n\nprime numbers are\n";
	 for(j=1;j<=n;j++)
	 { 	x=0;
		for(i=1;i<=j;i++)
		{
			if(j%i==0)
			x++;
		}
		if(x==2)
		cout<<"\t"<<j;
	 }
	   break;
	  case 2:
	    cout<<"\nenter n number:";
	 cin>>n;
	 b=0;a=n;
	 while(a>0)
	 {
	 b=b*10+a%10;
	 a=a/10;
	 }
	 if(n==b)
	 cout<<"it is palindrome\n";
	 else
	 cout<<"\nit is not palindrome:";

	   break;
	   case 3:
	   cout<<"\nenter range for even & odd:";
	 cin>>n;
	 cout<<"\n\neven no:s are\n";
	 for(i=1;i<=n;i++)
	 {
		if(i%2==0)
		{
		cout<<"\t"<<i;
		}
	 }
	 cout<<"\nodd numbers are:\n";
	 for(i=1;i<=n;i++)
	 {
		if(i%2!=0)
		{
		cout<<"\t"<<i;
		}
	 }
	   break;
	   case 4:
	   exit(0);
	   default:
	   cout<<"\ninvalid selection:";
     }
}while(ch<=4);
}
};
void main()
{
	clrscr();
	stu s;
	s.putdata();
	getch();
}