dimanche 4 août 2019

If number in the thrird column of 2d array is less than or eual to 41 print "ok" else print "not ok"

If number in the third column of 2d array is less than or equal to 41 print "ok" else print "not ok" .Size of array is n*3 (n is taken as input from user.)

Sample Input

4 (value of n), 5 5 5 1 2 40 10 5 41 7 2 42

Sample output ok ok ok notok

#include <stdio.h>

int main(void) {
int n,i,j;
scanf("%d",&n);//n is taken as input from user.
int a[n][3];
for(i=0;i<n;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);//taking number input from user to fill n*3 array.

for(i=0;i<n;i++){

if(a[i][3]<=41 ){    //To check the condition given in question
printf("ok ");

}
else {
printf("not ok ");

}

}
return 0;
}

Showing ok in place of not ok in some test cases.

Aucun commentaire:

Enregistrer un commentaire