Problem Description
There was a group of elements in which there may be repeated elements. So there was a task to find occurrence of an element in one dimensional array. Write a C program for this scenarioTest Case 1
Input (stdin)6 10 20 30 10 50 60 10
Expected Output2
Test Case 2
Input (stdin)3 1 2 3 3
Expected Output1
Program
#include <stdio.h> int main() { int n,i,arr[10],c,count=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&arr[i]); } scanf("%d",&c); for(i=0;i<n;i++) { if(c==arr[i]) count++; } printf("%d",count); return 0; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.