#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();
}
Sunday, January 18, 2015
To check a number is even or odd or prime
Install MySQL essential 5.0.67 and MySQL Query Analyzer
Download 'mysql-essential-5.0.67-win32'
Download 'MySQL Query Analyzer 57'
- Open mysql-essential-5.0.67-win32
- Next
- Complete
- Next
- Install
- Next
- Next
- Finish
- Next
- Standard Configuration
- Next
- Next
- Enter any password for root
- Retype the same password below
- Next
- Execute
- Finish
- Click to install the second setup - MySQL_Query_Analyzer_57
- Next
- Next
- tick Create a desktop icon
- Next
- Install
- Finish On the new window
- Server - localhost
- User name - root
- Password - password you given before
- 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.
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();
}
Subscribe to:
Comments (Atom)
