//here's my code
#include<stdio.h>
#include<stdlib.h>
int main()
{
int N;
scanf("%d",&N);
int i,ct=0;//ct is to count how many given inputs of W & H fulfill the if and else if conditional statements given below.
float W,H,ratio;//W and H are width and rectangle of rectangle respectively.ratio is ratio b/w W&H.
for(i=0;i<N;i++)
{
scanf("%f%f",&W,&H);
ratio=W/H;
printf("%f\n",ratio);
if(ratio==1.7)//this statement is not getting executed for some reason
{
printf("true\n");
ct++;
}
else if(ratio>1.6)
{
if(ratio<1.7)
ct++;
}
}
printf("%d",ct);
}
note: when I give input as following
1
10 1
supposed output is
ct=1
my output is
ct=0
//ratio is 1.7 but if statement above is not getting executed that's why ct is not getting updated I want to know what is the problem with my above if statement.
Aucun commentaire:
Enregistrer un commentaire