WAP To Justify Whether a No. Is Odd Or Even.

#include<iostream.h>
#include<conio.h>
Void main()
{   clrscr();
     Char ch;
     Int num,i;
     do
     {     
               Cout<<”Enter a no.\n”;
               Cin>>num;
               if(num%2==0)
                     cout<<”Even\n”;
               else
               cout<<”odd\n”;
               if(num==1)
                       cout<<”Prime no.\n”;
               else
               {     for(i=2i<=num/2;++i)
                      if(num%i==0)
                       {      
                                 Cout<<”Not prime\n”;
                                 goto lb;
                        }
                        cout<<”Prime \n”;
                  }
                   lb:
                   cout<<”\n Want to continue(y/n)?”;
                   cin>>ch’;
                }   while(ch==’y’||ch==’Y’);
                   getch();
               

  }                     

Comments

Popular Posts