fork download
  1. #include <stdio.h>
  2. #include<stdbool.h>
  3.  
  4. int main(void) {
  5. int arr[7]={1,2,3,4,5,6,7};
  6. int i, x=6;
  7. bool check=false;
  8. for(int i=0;i<7;i++){
  9. if(arr[i]==x){
  10. check=true;
  11. break;
  12. }
  13. }
  14.  
  15. if(check==false) printf("%d is not present in array",x);
  16.  
  17. else printf("%d is present in array and its index is %d",x,i) ;
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
6 is present in array and its index is 0