fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int arr[100],i,j,num,num1,num2=0;
  6. printf("Enter the number of elements of the array:");
  7. scanf("%d",&num);
  8. printf("Enter the elements of the array");
  9. for(i=0;i<num;i++)
  10. {
  11. scanf("%d",&arr[i]);
  12. }
  13. printf("Enter the element to be found:");
  14. scanf("%d",&num1);
  15. for(i=0;i<num;i++)
  16. {
  17. if(arr[i]==num1)
  18. {
  19. num2++;
  20. }
  21. else
  22. {
  23. num2=num2+0;
  24. }
  25. }
  26. if(num2==0)
  27. {
  28. printf("The element is not found");
  29. }
  30. else
  31. {
  32. printf("The element is found");
  33. }
  34. return 0;
  35. }
  36.  
  37.  
Success #stdin #stdout 0.03s 26060KB
stdin
Standard input is empty
stdout
#include <stdio.h>

int main()
{
    int arr[100],i,j,num,num1,num2=0;
    printf("Enter the number of elements of the array:");
    scanf("%d",&num);
    printf("Enter the elements of the array");
    for(i=0;i<num;i++)
    {
        scanf("%d",&arr[i]);
    }
    printf("Enter the element to be found:");
    scanf("%d",&num1);
    for(i=0;i<num;i++)
    {
        if(arr[i]==num1)
        {
            num2++;
        }
        else
        {
            num2=num2+0;
        }
    }
    if(num2==0)
    {
        printf("The element is not found");
    }
    else
    {
        printf("The element is found");
    }
    return 0;
}