fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int arr[7]={1,2,3,4,5,6,7};
  5. int x=4;
  6. for(int i=0;i<7;i++){
  7. if(arr[i]==x){
  8. printf("%d is present in array and its index is %d",x,i);
  9. break;
  10. }
  11. }
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
4 is present in array and its index is 3