Wednesday 6 February 2013

Write a c program to accept n number from user,store these numbers into an array & count the no of occurrences of each number



#include<stdio.h>
#include<conio.h>
  void main()
{
  int a[10],n,i,j,count=0;
  clrscr();
  printf("\nEnter the n numbers:");
  scanf("%d",&n);
  printf("\nEnter the numbers: ");
  for(i=0;i<n;i++)
{
  scanf("%d",&a[i]);
}
  printf("\nEnter the number to count the occurrences: ");
  scanf("%d",&j);
  for(i=0;i<n;i++)
{
  if(j==a[i])
 {
   count++;
  }
}
  printf("\nThe no of occurrences of given number:%d",count);
  getch();
}

//OUTPUT:
//Enter the n numbers:5
//Enter the numbers: 11
//12
//11
//11
//14

//Enter the number to count the occurrences: 11

//The no of occurrences of given number:3

3 comments:

  1. In the event that you don't have your framework kept up you could be taking in hurtful poisons furnace repair patterson

    ReplyDelete
  2. Window/divider climate control systems are anything but difficult to introduce; and can likewise be effortlessly expelled and put away furnace repair patterson

    ReplyDelete