cant we compare two for inequality?
i mean if i have a char array 'a' and i want to know the number of digits in an array which is not '4' or not '7'
i.e if my array has value 4567778 the output should be 3 as there are three 7's and one 4 so output is 3.
my condition for check is (a!=52!!a!=55).
but this condition is never checked and if my condition is (a==52!!a==55) i got right output.
so that means we can only compare if the strings are equal?
this code give wrong output:
#include<stdio.h>
int main()
{
int t,i,o;
char a[100000];
scanf("%d",&t);
while(t--)
{
i=0;
o=0;
scanf("%s",a);
while(a[i]!=NULL)
{
if(a[i]!=52||a[i]!=55) //this condition is not working?
o++;
i++;
}
printf("%d",o);
}
return 0;
}
this works fine:
#include<stdio.h>
//#include<string.h>
//#include<conio.h>
using namespace std;
int main()
{
int t,i,o;
char a[100000];
// cin>>t;
scanf("%d",&t);
while(t--)
{
i=0;
o=0;
scanf("%s",a);
while(a[i]!=NULL)
{
if(a[i]==52||a[i]==55)
o++;
i++;
}
printf("%d ",i-o);
}
return 0;
}