[Use user defined function to solve this problem]
#include<iostream>
using namespace std;
int chkstrange(int digit);
int main()
{
int digit,p;
cout<<"Enter Number to Check: ";
cin>>digit;
p= chkstrange(digit);
if (p==1) cout<<"strange";
else
cout<<"Not strange";
}
//function start here
int chkstrange(int digit)
{
int temp,rem,temp2=1;
while(digit!=0)
{
temp=digit/10;
rem=digit%10;
digit=temp;
for(int i=2;i<rem;i++)
{
if (rem%i ==0)
{
temp2= 0;
i=rem;
}
}
}
return temp2;
}
#include<iostream>
using namespace std;
int chkstrange(int digit);
int main()
{
int digit,p;
cout<<"Enter Number to Check: ";
cin>>digit;
p= chkstrange(digit);
if (p==1) cout<<"strange";
else
cout<<"Not strange";
}
//function start here
int chkstrange(int digit)
{
int temp,rem,temp2=1;
while(digit!=0)
{
temp=digit/10;
rem=digit%10;
digit=temp;
for(int i=2;i<rem;i++)
{
if (rem%i ==0)
{
temp2= 0;
i=rem;
}
}
}
return temp2;
}
ID NO-201420406
ReplyDeleteBatch-46th
#include
int main()
{
int num,i,f,r,sum=0,temp;
cout << "Enter a number: ";
cin >> num;
temp=num;
while(num)
{
i=1,f=1;
r=num%10;
while(i<=r){
f=f*i;
i++;
}
sum=sum+f;
num=num/10;
}
if(sum==temp)
cout << temp << " is a strange number";
else
cout << temp << " is not a strange number";
return 0;
}
noted but answer is not relevant with question
Deletei told you to do using function
DeleteBatch-46th
ReplyDeleteId:201420405
#include
using namespace std;
int main()
{
int a,b,digit,p=1;
cin>>digit;
while(digit!=0)
{
a=digit/10;
b=digit%10;
cout<<b<<endl;
digit=a;
for(int i=2;i<b;i++)
{
if (b%i ==0)
{
p=0;
i=b;
}
}
}
if (p==1) cout<<"strange";
else
cout<<"Not strange";
}
noted but answer is not relevant with question
DeleteWhere is function ? read question carefully.
DeleteMD: Rashed Prodhania
ReplyDeleteBatch-46th
Id:201420763
#include
using namespace std;
int main()
{
int L,M,digit,p=1;
cin>>digit;
while(digit!=0)
{
L=digit/10;
M=digit%10;
cout<<M<<endl;
digit=L;
for(int i=2;i<b;i++)
{
if (b%i ==0)
{
p=0;
i=M;
}
}
}
//use if else statment
if (p==1) cout<<"This is Strange";
else
cout<<"This is Not Strange";
}
noted but answer is not relevant with question
Deletesir amr program half post hocche.plz do something
ReplyDeleteThere are some spam on your computer. Try using another browser or computer
DeleteName-MainUddin
ReplyDeleteID-201421090
Batch-46
#include
using namespace std;
//base class
class strange
{
public:
void setdigit(int d)
{
digit=d;
}
protected:
int digit;
};
//derived class
class number : public strange
{
public:
int i,j,t,d;
int devide()
{
d=digit;
while(d!=0)
{
j=d%10;
d=d/10;
for(i=2;i>a;
nmb.setdigit(a);
nmb.check();
}
do not copy. and this is wrong answer.
Deletehttp://itlearn24.blogspot.com/2014/11/check-whether-given-number-is-strange.html
ReplyDeletei checked your blog page. found correct.
DeleteName-Main Uddin
ReplyDeleteID-201421090
Batch-46
#include
using namespace std;
int StNumber ( int Num )
{
if ( Num > 2 )
{
for ( int L = 2 ; L <= ( Num/2 ) ; L++ )
{
if ( Num % L == 0 )
return (0);
}
return (1);
}
}
int main ()
{
int Num;
cout<<"Enter The Number"<>Num;
if ( StNumber ( Num ) )
cout<<"Strange Number"<<endl;
else
cout<<"Not Strange Number"<<endl;
cout<<endl;
}
noted
Delete#include
ReplyDeleteusing namespace std;
int strange(int digit)
{
int d,r;
while(digit!=0)
{
d=digit/10;
r=digit%10;
digit=d;
return r;
}
}
int main()
{
int digit,p=1,re;
cout<<"Enter number to check strange or not : ";
cin>>digit;
cout<<endl;
re=strange(digit);
for(int i=2;i<re;i++)
{
if (re%i ==0)
{
p=0;
i=re;
}
}
if (p==1)
cout<<"Yes!!"<<endl<<"Enter number is strange number"<<endl<<endl;
else
cout<<"Not!!"<<endl<<"Enter number is not a strange number"<<endl;
}
#include
ReplyDeleteusing namespace std;
int strange(int digit)
{
int d,r;
while(digit!=0)
{
d=digit/10;
r=digit%10;
digit=d;
return r;
}
}
int main()
{
int digit,p=1,re;
cout<<"Enter number to check strange or not : ";
cin>>digit;
cout<<endl;
re=strange(digit);
for(int i=2;i<re;i++)
{
if (re%i ==0)
{
p=0;
i=re;
}
}
if (p==1)
cout<<"Yes!!"<<endl<<"Enter number is strange number"<<endl<<endl;
else
cout<<"Not!!"<<endl<<"Enter number is not a strange number"<<endl;
}
#include
ReplyDeleteusing namespace std;
void strange(int i)
{
int check = 0, temp, rem;
while (rem != 0){
temp = i%10;
rem = i/10;
i = rem;
for (int j = 2; j < temp; j++){
if (temp%j==0){
check = 1;
break;
}
}
}
if (check == 1)
cout << "This number is not a strange number.";
else
cout << "This is a strange number.";
}
int main()
{
int i;
cout << "Enter number --: ";
cin >> i;
strange(i);
return 0;
}
using namespace std;
ReplyDeleteint strange(int digit)
{
int d,r;
while(digit!=0)
{
d=digit/10;
r=digit%10;
digit=d;
return r;
}
}
int main()
{
int num,p=1,re;
cout<<"Enter number to check strange or not : ";
cin>>num;
cout<<endl;
re=strange(num);
for(int i=2;i<re;i++)
{
if (re%i ==0)
{
p=0;
i=re;
}
}
if (p==1)
cout<<"Yes!!"<<endl<<"IT IS A STRANGE NUMBER"<<endl<<endl;
else
cout<<"Not!!"<<endl<<"ITS NOT A STRANGE NUMBER"<<endl;
}
///Tisha
ReplyDelete///201930034
#include
using namespace std;
int strange(int number)
{
int a,b;
while(number!=0)
{
a=number/10;
b=number%10;
number=a;
return b;
}
}
int main()
{
int number,x=1,y;
cout<<"Enter number to check strange or not : ";
cin>>number;
cout<<endl;
y=strange(number);
for(int i=2;i<y;i++)
{
if (y%i ==0)
{
x=0;
i=y;
}
}
if (y==1)
cout<<"strange"<<endl<<"This number is strange number"<<endl;
else
cout<<"Not strange"<<endl<<"This number is not a strange number"<<endl;
}
//Nayem Hossain
ReplyDelete//202010023
//Batch 63
#include
using namespace std;
int main()
{
int a,b,num,p=1;
cin>>num;
while(num!=0)
{
a=num/10;
b=num%10;
cout<<b<<endl;
num=a;
for(int i=2;i<b;i++)
{
if (b%i ==0)
{
p=0;
i=b;
}
}
}
if (p==1) cout<<"strange";
else
cout<<"Not strange";
}
#include
ReplyDeleteusing namespace std;
int main()
{
int m,n,number,p=1;
cin>>number ;
while(number=0)
{
m=number\10;
n=number %10;
cout<<n<<endl;
digit=m;
for(int i=2,i<n;i++)
{
if(n%i==0)
{
p=0;
i=n;
}
}
}
if(p==1)
cout<<"strange";
else
cout<<"not strange";
}