Function Programming : Strange Number in C

WAP to check whether the given input is Strange or Not.

#include<stdio.h>
int main()
{
     int digit;
     printf("\nEnter your digit: ");
     scanf("%d", &digit);
     strng(digit);
}
 
int strng(int d)
{
     int i, j, t=1;
     while (d!=0)
         {
               j=d%10;
              d=d/10;
              for (i=2; i<j; i++)
                  {
                       if ( j%i = =0 )
                      {
                            t=0;
                            break;
                       }
                   }
           }
 
if (t = = 1)
      printf("\nThis number is strange");
else
      printf("\nThis number is not strange");
}

24 comments:

  1. //#include
    main()
    {
    int digit;
    printf("enter your digit\n");
    scanf("%d",&digit);
    strng(digit);
    }
    int strng(int d)
    {
    int i,j,t=1;
    while(d!=0)
    {
    j=d%10;
    d=d/10;
    for(i=2;i<j;i++)
    {
    if(j%i==0)
    {
    t=0;
    break;
    }
    }
    }
    if(t==1)
    printf("this number is strange");
    else
    printf("this number is not strange");
    }

    ReplyDelete
  2. //#include
    main()
    {
    int digit;
    printf("enter your digit\n");
    scanf("%d",&digit);
    strng(digit);
    }
    int strng(int d)
    {
    int i,j,t=1;
    while(d!=0)
    {
    j=d%10;
    d=d/10;
    for(i=2;i<j;i++)
    {
    if(j%i==0)
    {
    t=0;
    break;
    }
    }
    }
    if(t==1)
    printf("this number is strange");
    else
    printf("this number is not strange");
    }

    ReplyDelete
  3. #include
    main()
    {
    int j;
    printf("Enter your number :");
    scanf("%d",&j);
    strange (j);
    }

    int strange (int a)
    {
    int i,p,q,temp;
    while(a!=0)
    {
    p=a%10;
    a=a/10;
    q=p;

    for (i=2;i<q;i++)
    {
    if(q%i==0)
    {
    temp=0;
    break;
    }
    }
    }
    if(temp==0)
    printf(" not strange number ");
    else
    printf(" strange number ");
    }

    ReplyDelete
  4. #include
    int strange(int digit);
    main()
    {
    int digit;
    printf("Given an input to check a strange number: ");
    scanf("%d",&digit);
    strange(digit);
    }
    int strange(int d)

    {
    int i,rem,flag=1;
    while(d!=0)
    {
    rem=d%10;
    d=d/10;
    for(i=2;i<rem;i++)
    {

    if(rem%i==0)
    {
    flag=0;
    break;
    }
    }
    }
    if(flag==1)
    printf("\nGiven input is a strange number");
    else
    printf("\nGiven input is not a strange number");
    }

    ReplyDelete
  5. #include
    #include

    int check_strange(int);
    int main()
    {
    int a,rem;
    printf("\n Enter number for check if it is strange or not; ");
    scanf("%d",a);
    rem=check_strange(a);
    getch();
    return 0;

    }

    int check_strange(int b)
    {
    int i,n,st=1;
    while(b!=0)
    {
    n=b%10;
    b/=10;
    for(i=2;i<n;i++)
    {
    if(n%i==0)
    {
    st=0;
    break;

    }

    }
    if(st==1)
    printf("\n This is strange number",st);
    else
    printf("\n This is not strange number",st);

    return st;
    }

    }

    ReplyDelete
  6. #include
    #include
    int perfect_check(int);
    int main()
    {
    int n,shohan;
    printf("\n Enter number for check weathe it is perfect or not:");
    scanf("%d",&n);
    shohan=perfect_check(n);
    getch();
    return 0;

    }

    int perfect_check(int salmaan)
    {
    int shuvo,saad=0;
    for(shuvo=1;shuvo<salmaan;shuvo++)
    {
    if(salmaan%shuvo==0)
    saad+=shuvo;
    }
    if(saad==salmaan)
    printf("\n It is perfect number");
    else
    printf("\n It is not perfect number");
    getch();
    return shuvo;

    }

    ReplyDelete
  7. #include
    #include
    int check_strange(int);
    int main()
    {
    int j,shohan;
    printf("\n Enter number for check if it is strange or not : ");
    scanf("%d",&j);
    shohan=check_strange(j);
    getch();
    return 0;


    }

    int check_strange(int n)
    {
    int i,result,st=1;
    while(n!=0)
    {
    result=n%10;
    n/=10;
    i=2;
    do
    {
    if(result%i==0)
    {
    st=0;
    break;
    }
    i++;
    }while(i<result);

    if(st==1)
    printf("\n This is strange number",st);
    else
    printf("\n This is not strange number",st);
    return st;
    }

    }

    ReplyDelete
  8. #include
    #include
    int check_strange(int);
    int main()
    {
    int n,shohan;
    printf("\n Enter number for check if it is strange or not : ");
    scanf("%d",&n);
    shohan=check_strange(n);
    getch();
    return 0;


    }

    int check_strange(int a)
    {
    int Bangladesh, i,st=1;
    while(a!=0)
    {
    Bangladesh=a%10;
    a/=10;
    i=2;
    while(i<Bangladesh)
    {
    if(Bangladesh%i==0)
    {
    st=0;
    break;

    }
    i++;
    }

    if(st==1)
    printf("\n This is strange number",st);
    else
    printf("\n This is not strange number",st);
    return st;
    }

    }

    ReplyDelete
  9. Md. Rajib Sarker Id: 201320635December 12, 2013 at 10:32 PM

    #include
    main()
    {
    int j;
    printf("Enter your number :");
    scanf("%d",&j);
    strange (j);
    }

    int strange (int a)
    {
    int i,p,q,temp;
    while(a!=0)
    {
    p=a%10;
    a=a/10;
    q=p;

    for (i=2;i<q;i++)
    {
    if(q%i==0)
    {
    temp=0;
    break;
    }
    }
    }
    if(temp==0)
    printf(" not strange number ");
    else
    printf(" strange number ");
    }

    ReplyDelete
  10. Md. Rajib Sarker Id: 201320635December 12, 2013 at 10:32 PM

    #include
    main()
    {
    int j;
    printf("Enter your number :");
    scanf("%d",&j);
    strange (j);
    }

    int strange (int a)
    {
    int i,p,q,temp;
    while(a!=0)
    {
    p=a%10;
    a=a/10;
    q=p;

    for (i=2;i<q;i++)
    {
    if(q%i==0)
    {
    temp=0;
    break;
    }
    }
    }
    if(temp==0)
    printf(" not strange number ");
    else
    printf(" strange number ");
    }

    ReplyDelete
  11. Md. Rajib Sarker Id: 201320635December 12, 2013 at 10:32 PM

    #include
    main()
    {
    int j;
    printf("Enter your number :");
    scanf("%d",&j);
    strange (j);
    }

    int strange (int a)
    {
    int i,p,q,temp;
    while(a!=0)
    {
    p=a%10;
    a=a/10;
    q=p;

    for (i=2;i<q;i++)
    {
    if(q%i==0)
    {
    temp=0;
    break;
    }
    }
    }
    if(temp==0)
    printf(" not strange number ");
    else
    printf(" strange number ");
    }

    ReplyDelete
  12. Md. Rajib Sarker Id: 201320635December 12, 2013 at 10:33 PM

    //#include
    main()
    {
    int digit;
    printf("enter your digit\n");
    scanf("%d",&digit);
    strng(digit);
    }
    int strng(int d)
    {
    int i,j,t=1;
    while(d!=0)
    {
    j=d%10;
    d=d/10;
    for(i=2;i<j;i++)
    {
    if(j%i==0)
    {
    t=0;
    break;
    }
    }
    }
    if(t==1)
    printf("this number is strange");
    else
    printf("this number is not strange");
    }

    ReplyDelete
  13. #include
    #include
    int funcx(int);
    int main()
    {
    int n,result;
    printf("\n Enter your number:");
    scanf("%d",&n);
    result=funcx(n);
    getch();
    return 0;
    }

    int funcx(int digit)
    {
    int i,st=1,rem;
    while(digit!=0)
    {
    rem=digit%10;
    digit/10;
    for(i=0;i<rem;i++)
    {
    if(rem%2==0)
    {
    st=0;
    break;
    }

    }
    if(st==1)
    printf("\n It is a strange number:");
    else
    printf("\n It is not a strange number:");
    return st;
    }

    }

    ReplyDelete
  14. #include
    //#include
    #include
    void main()
    {
    char str1[25],str2[25];
    int dif;
    //clrscr();
    printf("Enter the string to check the String is True or not: ");
    gets(str1);
    strcpy(str2,str1);
    strrev(str2);
    dif=strcmp(str1,str2);
    if(dif==0)
    printf("\n%s is True",str1);
    else
    printf("\n%s is not True\n",str1);
    }

    ReplyDelete
  15. #include
    int checkStrange(int n)
    {
    int i,p,q,temp;
    while(n!=0)
    {
    p=n%10;
    n=n/10;
    q=p;

    for (i=2; i<q; i++)
    {
    if(q%i==0)
    {
    temp=0;
    break;
    }
    }
    }
    return temp;
    }
    int main()
    {
    int n,result;
    printf("Enter a number: ");
    scanf("%d",&n);
    result = checkStrange(n);
    if(result==1)
    {
    printf("%d is a strange number.\n", n);
    }
    else
    {
    printf("%d is not a strange number.\n", n);
    }
    return 0;
    }

    ReplyDelete
  16. #include
    int strange(int digit);
    main()
    {
    int digit;
    printf("Given an input to check a strange number: ");
    scanf("%d",&digit);
    strange(digit);
    }
    int strange(int d)

    {
    int i,rem,flag=1;
    while(d!=0)
    {
    rem=d%10;
    d=d/10;
    for(i=2;i<rem;i++)
    {

    if(rem%i==0)
    {
    flag=0;
    break;
    }
    }
    }
    if(flag==1)
    printf("\nGiven input is a strange number");
    else
    printf("\nGiven input is not a strange number");
    }

    ReplyDelete
  17. Id-201210803


    #include
    using namespace std;

    int strng(int d)
    {
    int i,j,t=1;
    while(d!=0)
    {
    j=d%10;
    d=d/10;
    for(i=2;i>digit;
    strng(digit);
    }

    ReplyDelete
  18. #include
    using namespace std;
    int strang(int d);
    main()
    {
    int digit;
    cout<<"enter your digit\n";
    cin>>digit;
    strang(digit);
    }
    int strang(int d)
    {
    int i,j,t=1;
    while(d!=0)
    {
    j=d%10;
    d=d/10;
    for(i=2;i<j;i++)
    {
    if(j%i==0)
    {
    t=0;
    break;
    }
    }
    }
    if(t==1)
    cout<<"this number is strange";
    else
    cout<<"this number is not strange";
    }

    ReplyDelete
  19. #include
    using namespace std;

    class strange
    {
    public:
    int num;
    strange();
    void show();
    ~strange();
    };
    strange::strange()
    {
    cout<<"Enter a number: ";
    cin>>num;
    }
    void strange::show()
    {
    int i,rem=0,flag=0,flag1=0;
    while(num!=0)
    {
    rem=num%10;
    num=num/10;
    for(i=2; i<=rem/2; i++)
    {
    if(rem%i==0)
    {
    flag=1;
    break;
    }
    else
    flag=0;
    }


    }
    for(i=2; i<=num/2; i++)
    {
    if(num%i==0)
    {
    flag1=1;
    break;
    }
    else
    flag1=0;
    }
    if(flag==0&&flag1==0)
    cout<<endl<<"This is a strange number."<<endl;
    else
    cout<<endl<<"This is not a strange number."<<endl;
    }
    strange::~strange()
    {

    }
    main()
    {
    strange ob;
    ob.show();
    }

    ReplyDelete
  20. #include
    using namespace std;
    class strange
    {
    public:
    int num;
    strange();
    void show();
    ~strange();
    };
    strange::strange()
    {
    cout<<"Enter a number: ";
    cin>>num;
    cout<<endl;
    }
    void strange::show()
    {
    int i, remain=0, flag1=0, flag2=0;
    while(num!=0)
    {
    remain=num%10;
    num=num/10;
    for(i=2; i<=num; i++)
    {
    if(remain%i==0){
    flag1=1;
    break;
    }
    else
    flag1=0;
    }
    }
    for(i=2; i<=num/2; i++)
    {
    if(num%i==0){
    flag2=1;
    break;
    }
    else
    flag2=0;
    }
    if(flag1==0 && flag2==0)
    cout<<"Strange number..."<<endl;
    else
    cout<<"Not strange number..."<<endl;
    }
    strange::~strange()
    {

    }
    int main()
    {
    strange obj;
    obj.show();
    return 0;
    }

    ReplyDelete
  21. using C++

    #include
    using namespace std;

    class cons
    {
    public:
    int num;
    cons(int i);
    ~cons();

    void result();
    };

    cons::cons(int i)
    {
    num = i;
    }

    void cons::result()
    {
    int temp, check = 1;
    while (num != 0){
    temp = num % 10;
    num /= 10;
    for (int i = 2; i < temp; i++){
    if (temp % i == 0)
    check = 0;
    break;
    }
    }

    if (check == 1)
    cout << "This number is a Strange number --\n";
    else
    cout << "This is not a Strange number --\n";
    }

    cons::~cons()
    {
    cout << "[+]MEMORY RELEASED[+]\n";
    }

    int main()
    {
    int i;
    cout << "Enter that number you want to check --: ";
    cin >> i;

    cons obj(i);
    obj.result();

    return 0;
    }

    ReplyDelete
  22. using constructor

    #include
    using namespace std;
    class Strange
    {
    public:
    int i,t,p,d;
    Strange ();

    ~Strange ();
    void result();
    };
    Strange ::Strange ()
    {
    cout<<"Enter a number :" ;
    cin>>d;
    }
    Strange ::~Strange ()
    {

    }
    void Strange ::result()
    {
    t=1;
    while(d!=0)
    {
    p=d%10;
    d=d/10;

    for(i=2;i<p;i++)
    {
    if(p%i==0)
    {
    t=0;
    break;
    }
    }

    }
    if(t==1)
    cout<<"This is Strange number:";
    else
    cout<<"This is not Strange number :"<<"\n";
    }
    int main()
    {
    Strange sb;
    sb.result();
    }

    ReplyDelete
  23. #include
    using namespace std;

    class strange
    {
    public:
    int num,i,temp=0;
    strange();
    ~strange()
    {
    cout<<"Distructor active";
    }
    int func()
    {
    string check="ok";
    while(num!=0)
    {
    temp=(num%10);
    num=num/10;
    for(i=2;i>num;
    }

    int main()
    {
    strange obj;
    obj.func();
    return 0;
    }

    id:201510660

    ReplyDelete