top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Does C++ have comparison operator that specify a range of values?

+3 votes
399 views

Something like :

IN(Range)

posted Feb 27, 2014 by Muskan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

No, you would have to use two conditions like:

if ((x >= 5) && (x <= 10))

or:

if ((x==1) || (x==2))

answer Feb 27, 2014 by Mehul Bhatt
Similar Questions
+1 vote

I have written a simple program and stored it with .c file,
When i compiled it with g++ it is getting compiled and giving the proper output when i run that,
but when i compile the same using gcc then it is throwing error.

Below is the sample .c file
#include<stdio.h>
struct A{
        private:
        int a;
        public:
        int sum(){
        a=10;
        }
        void print()
        {
        printf("%d\n",a);
        }
        A()
        {
                printf("Constructor\n");
        }
        A(int b)
        {
                printf("Copy Constructor\n");
        }
        ~A()
        {
                printf("Destructor\n");
        }
};
main()
{
        struct A a(10);
        a.sum();
        a.print();
}
...