You will be given 3 integers as input The inputs may or may not be different from each other.

+2 votes
asked Jul 30, 2019 by anonymous
You will be given 3 integers as input. The inputs may or may not be
 different from each other.

You have to output 1 if all three inputs
 are different from each other,
and 0 if any input is repeated more
 than once.

8 Answers

0 votes
answered Jul 31, 2019 by Swetha Vedhagiri (280 points)
#include<stdio.h>

int main()

{

int a,b,c;

printf("enter the numbers:  ");

scanf("%d%d%d",a,b,c);

if(a!=b&&b!=c&&c!=a)

{

printf("1");

}

else{

printf("0");

}

}
0 votes
answered Jul 31, 2019 by keerthanav666 (300 points)
#include<stdio.h>

int main()

{

int a,b,c,k=0,r=0;

scanf("%d%d%d",&a,&b,&c);

if(a!=b&&b!=c&&c!=a)

k=1;

else

r++;

if(k==1&&r==0)

printf("0");

else

printf("1");

return 0;

}
0 votes
answered Jul 31, 2019 by john (140 points)

#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a==b&&a==c)
    printf("0");
else
    printf("1");
}

commented Aug 1, 2019 by anonymous
This fails if b and c are equal but a isn't.
0 votes
answered Jul 31, 2019 by Rishu Mishra (160 points)
#include <stdio.h>

int main ()

{
  int a, b, c;
  printf ("Enter three numbers to be compared: ");  //asking for input
  scanf ("%d%d%d", &a, &b, &c);  //Taking input

    if (a == b || b == c)   //Comparing as per condition
    {
        printf ("0");  //output case 1
    }
    else
    {
        printf("1");  //output case 2
    }

}
commented Aug 1, 2019 by anonymous
This fails if a and c are equal
0 votes
answered Aug 1, 2019 by Loki (1,600 points)

#include <stdio.h>
void main()
{
    int a=0, b=0, c=0;
    printf("%c",(a==b)?'0':(c==a)?'0':(c==b)?'0':'1',scanf("%d%d%d",&a,&b,&c));
}

Try this one  wink.

0 votes
answered Aug 1, 2019 by anonymous
bool func(int a, int b, int c){

return a^b^c;

}
commented Aug 9, 2019 by Loki (1,600 points)
_Bool f(int a, int b, int c){
    return a^b&&a^c&&b^c;
}
this would be the correct answer i guess.
0 votes
answered Aug 5, 2019 by lata (220 points)
#include<stdio.h>
void main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b||a==c||b==c)
    printf("1");
    else
    printf("0");
}
0 votes
answered Aug 12, 2019 by anonymous
#include <stdio.h>
int main() {
    int a,b,c,x,y,z,w;
    printf("enter three integers:");
    scanf("%d%d%d",&a,&b,&c);
    x=(a==b);
    y=(b==c);
    z=(a==c);
    w=!(x+y+z);
    printf("the value of w is=%d",w);
   return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...