Advertisement
Istanvir389

11/9/17 Class Work

Sep 11th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int count=0,value,i;
  5. int arr[5];
  6. for(i=0; i<5;i++)
  7. {
  8. scanf("%d",&arr[i]);
  9. //printf("\n%d",arr[i]);
  10.  
  11. }
  12. scanf("%d",&value);
  13. for(i=0;i<5;i++)
  14. {
  15. if(value==arr[i])
  16. {
  17. count++;
  18. }
  19. }
  20. if(count==0)
  21. {
  22. printf("Not found");
  23. }
  24. else
  25. printf("%d",count);
  26. return 0;}
  27.  
  28.  
  29.  
  30. ALTERNATE
  31.  
  32.  
  33.  
  34. #include<stdio.h>
  35. int main()
  36. {
  37. int count=0,value,i;
  38. int arr[10];
  39. for(i=0; i<10;i++)
  40. {
  41. scanf("%d",&arr[i]);
  42. //printf("\n%d",arr[i]);
  43.  
  44. }
  45. scanf("%d",&value);
  46. for(i=0;i<10;i++)
  47. {
  48. if(value==arr[i])
  49. {
  50. count++;
  51. }
  52. }
  53. if(count!=0)
  54. {
  55. printf("%d",count); }
  56. else
  57. printf("Not found");
  58.  
  59. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement