#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
void Divisible_By_Three()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=0;
}
}
else if(s==2)
{
if(c=='0')
{
s=1;
}
else if(c=='1')
{
s=2;
}
}
}
if(s==0)
{
cout << "Divisible by 3" << endl;
}
else
{
cout<< "Not Divisible by 3" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Four()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==3)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
}
if(s==0)
{
cout << "Divisible by 4" << endl;
}
else
{
cout<< "Not Divisible by 4" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Five()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=0;
}
}
else if(s==3)
{
if(c=='0')
{
s=1;
}
else if(c=='1')
{
s=2;
}
}
else if(s==4)
{
if(c=='0')
{
s=3;
}
else if(c=='1')
{
s=4;
}
}
}
if(s==0)
{
cout << "Divisible by 5" << endl;
}
else
{
cout<< "Not Divisible by 5" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Six()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==3)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==4)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==5)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
}
if(s==0)
{
cout << "Divisible by 6" << endl;
}
else
{
cout<< "Not Divisible by 6" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Seven()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==3)
{
if(c=='0')
{
s=6;
}
else if(c=='1')
{
s=0;
}
}
else if(s==4)
{
if(c=='0')
{
s=1;
}
else if(c=='1')
{
s=2;
}
}
else if(s==5)
{
if(c=='0')
{
s=3;
}
else if(c=='1')
{
s=4;
}
}
else if(s==6)
{
if(c=='0')
{
s=5;
}
else if(c=='1')
{
s=6;
}
}
}
if(s==0)
{
cout << "Divisible by 7" << endl;
}
else
{
cout<< "Not Divisible by 7" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Eight()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==3)
{
if(c=='0')
{
s=6;
}
else if(c=='1')
{
s=7;
}
}
else if(s==4)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==5)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==6)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==7)
{
if(c=='0')
{
s=6;
}
else if(c=='1')
{
s=7;
}
}
}
if(s==0)
{
cout << "Divisible by 8" << endl;
}
else
{
cout<< "Not Divisible by 8" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Nine()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==3)
{
if(c=='0')
{
s=6;
}
else if(c=='1')
{
s=7;
}
}
else if(s==4)
{
if(c=='0')
{
s=8;
}
else if(c=='1')
{
s=0;
}
}
else if(s==5)
{
if(c=='0')
{
s=1;
}
else if(c=='1')
{
s=2;
}
}
else if(s==6)
{
if(c=='0')
{
s=3;
}
else if(c=='1')
{
s=4;
}
}
else if(s==7)
{
if(c=='0')
{
s=5;
}
else if(c=='1')
{
s=6;
}
}
else if(s==8)
{
if(c=='0')
{
s=7;
}
else if(c=='1')
{
s=8;
}
}
}
if(s==0)
{
cout << "Divisible by 9" << endl;
}
else
{
cout<< "Not Divisible by 9" << endl;
}
cout << "Enter your Divisor: ";
}
int main()
{
int div;
cout << "Enter your divisor : ";
while(cin >> div)
{
if(div<3 || div>9)
{
cout << "Conditon is Not Found!!!" << endl;
break;
}
if(div==3)
{
cin.ignore();
Divisible_By_Three();
}
if(div==4)
{
cin.ignore();
Divisible_By_Four();
}
if(div==5)
{
cin.ignore();
Divisible_By_Five();
}
if(div==6)
{
cin.ignore();
Divisible_By_Six();
}
if(div==7)
{
cin.ignore();
Divisible_By_Seven();
}
if(div==8)
{
cin.ignore();
Divisible_By_Eight();
}
if(div==9)
{
cin.ignore();
Divisible_By_Nine();
}
}
return 0;
}
#include<cstdio>
#include<cmath>
using namespace std;
void Divisible_By_Three()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=0;
}
}
else if(s==2)
{
if(c=='0')
{
s=1;
}
else if(c=='1')
{
s=2;
}
}
}
if(s==0)
{
cout << "Divisible by 3" << endl;
}
else
{
cout<< "Not Divisible by 3" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Four()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==3)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
}
if(s==0)
{
cout << "Divisible by 4" << endl;
}
else
{
cout<< "Not Divisible by 4" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Five()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=0;
}
}
else if(s==3)
{
if(c=='0')
{
s=1;
}
else if(c=='1')
{
s=2;
}
}
else if(s==4)
{
if(c=='0')
{
s=3;
}
else if(c=='1')
{
s=4;
}
}
}
if(s==0)
{
cout << "Divisible by 5" << endl;
}
else
{
cout<< "Not Divisible by 5" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Six()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==3)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==4)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==5)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
}
if(s==0)
{
cout << "Divisible by 6" << endl;
}
else
{
cout<< "Not Divisible by 6" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Seven()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==3)
{
if(c=='0')
{
s=6;
}
else if(c=='1')
{
s=0;
}
}
else if(s==4)
{
if(c=='0')
{
s=1;
}
else if(c=='1')
{
s=2;
}
}
else if(s==5)
{
if(c=='0')
{
s=3;
}
else if(c=='1')
{
s=4;
}
}
else if(s==6)
{
if(c=='0')
{
s=5;
}
else if(c=='1')
{
s=6;
}
}
}
if(s==0)
{
cout << "Divisible by 7" << endl;
}
else
{
cout<< "Not Divisible by 7" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Eight()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==3)
{
if(c=='0')
{
s=6;
}
else if(c=='1')
{
s=7;
}
}
else if(s==4)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==5)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==6)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==7)
{
if(c=='0')
{
s=6;
}
else if(c=='1')
{
s=7;
}
}
}
if(s==0)
{
cout << "Divisible by 8" << endl;
}
else
{
cout<< "Not Divisible by 8" << endl;
}
cout << "Enter your Divisor: ";
}
void Divisible_By_Nine()
{
char c;
int s=0;
cout << "Enter Your string : ";
while(cin.get(c))
{
if(c=='\n')
{
break;
}
if(s==0)
{
if(c=='0')
{
s=0;
}
else if(c=='1')
{
s=1;
}
}
else if(s==1)
{
if(c=='0')
{
s=2;
}
else if(c=='1')
{
s=3;
}
}
else if(s==2)
{
if(c=='0')
{
s=4;
}
else if(c=='1')
{
s=5;
}
}
else if(s==3)
{
if(c=='0')
{
s=6;
}
else if(c=='1')
{
s=7;
}
}
else if(s==4)
{
if(c=='0')
{
s=8;
}
else if(c=='1')
{
s=0;
}
}
else if(s==5)
{
if(c=='0')
{
s=1;
}
else if(c=='1')
{
s=2;
}
}
else if(s==6)
{
if(c=='0')
{
s=3;
}
else if(c=='1')
{
s=4;
}
}
else if(s==7)
{
if(c=='0')
{
s=5;
}
else if(c=='1')
{
s=6;
}
}
else if(s==8)
{
if(c=='0')
{
s=7;
}
else if(c=='1')
{
s=8;
}
}
}
if(s==0)
{
cout << "Divisible by 9" << endl;
}
else
{
cout<< "Not Divisible by 9" << endl;
}
cout << "Enter your Divisor: ";
}
int main()
{
int div;
cout << "Enter your divisor : ";
while(cin >> div)
{
if(div<3 || div>9)
{
cout << "Conditon is Not Found!!!" << endl;
break;
}
if(div==3)
{
cin.ignore();
Divisible_By_Three();
}
if(div==4)
{
cin.ignore();
Divisible_By_Four();
}
if(div==5)
{
cin.ignore();
Divisible_By_Five();
}
if(div==6)
{
cin.ignore();
Divisible_By_Six();
}
if(div==7)
{
cin.ignore();
Divisible_By_Seven();
}
if(div==8)
{
cin.ignore();
Divisible_By_Eight();
}
if(div==9)
{
cin.ignore();
Divisible_By_Nine();
}
}
return 0;
}
No comments:
Post a Comment