Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- //Twenty-five numbers are entered through the Keyboard into an array.
- //The Number to be searched is entered through the keyboard by user
- //Write a program to find if the number to be searched is present
- //in an arry and if it is present , display the number of times it
- //appears in array.
- int[] arr = new int[10];
- Console.WriteLine("Enter the Values in array");
- for (int i = 0; i < 5; i++)
- {
- arr[i] = Convert.ToInt16(Console.ReadLine());
- }
- int num;
- Console.WriteLine("Enter the value to be searched in array: ");
- num = Convert.ToInt16(Console.ReadLine());
- int count = 0;
- for (int i = 0; i < 5; i++)
- {
- if(num == arr[i])
- {
- count = count + 1;
- }
- }
- Console.WriteLine("\n" + "Number of times value appeared in array is ");
- Console.WriteLine(count);
- }
- }
Add Comment
Please, Sign In to add comment