Sunday, January 18, 2015

To check a number is even or odd or prime

#include<iostream.h>
#include<conio.h>
class s{
 int n;
public:
 void getvalues();
 void evodd();
 void prime();
};
void s::getvalues()
{
 cout<<"Enter a number greater than 1:";
 cin>>n;
}
void s::evodd()
{
 if(n%2==0)
  cout<<"The number is even and ";
 else
  cout<<"The number is odd and ";
}
void s::prime()
{
 int flag=0;
 for(int i=2;i<n;i++)
 {
  if(n%i==0)
  {
   flag=1;
   break;
  }
 }
 if(flag==1)
  cout<<"it is not a prime number.";
 else
  cout<<"it is a prime number.";
 getch();
}
void main()
{
 clrscr();
 s ob;
 char c;
 do{
 clrscr();
 ob.getvalues();
 ob.evodd();
 ob.prime();
 cout<<"\nDo you wish to continue? (Y/N)  :";
 cin>>c;
 }while(c=='y'||c=='Y');
 getch();
}

Install MySQL essential 5.0.67 and MySQL Query Analyzer

Download 'mysql-essential-5.0.67-win32'
 Download mysql essential 5.0.67

Download 'MySQL Query Analyzer 57'
  1. Open mysql-essential-5.0.67-win32
  2. Next
  3. Complete
  4. Next
  5. Install
  6. Next
  7. Next
  8. Finish
  9. Next
  10. Standard Configuration
  11. Next
  12. Next
  13. Enter any password for root
  14. Retype the same password below
  15. Next
  16. Execute
  17. Finish
  18. Click to install the second setup - MySQL_Query_Analyzer_57
  19. Next
  20. Next
  21. tick Create a desktop icon
  22. Next
  23. Install
  24. Finish On the new window
  25. Server - localhost
  26. User name - root
  27. Password - password you given before
  28. tick save password

Install MySQL on windows8

1. Download MySQL from http://dev.mysql.com/downloads/mysql/
2. Download this tutorial to install MySQL on your Windows 8 pc.

Find sum of digits of a number using c++

#include<iostream.h>
#include<conio.h>
class s_digits{
 int num,sum;
public:
 void input();
 void calculate();
 void output();
};
void s_digits::input()
{
 cout<<"Enter your number:";
 cin>>num;
}
void s_digits::calculate()
{
 sum=0;
 int r,n;
 n=num;
 while(n>0)
 {
  r=n%10;
  sum+=r;
  n=n/10;
 }
}
void s_digits::output()
{
 cout<<"The number entered is:"<<num;
 cout<<"\nSum of its digits is:"<<sum;
}
void main()
{       clrscr();
 s_digits ob;
 ob.input();
 ob.calculate();
 ob.output();
 getch();
}