Write a c code only using array and for loop to find similar number among given numbers.?
how many numbers:7
give the numbers:2532655
mode:5
number of time present:3
1
Expert's answer
2011-12-15T07:08:54-0500
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace Similar_number { class Program { static void Main(string[] args) { string numbers; int number; int mode; int numberoftimepresent = 0; Console.Write("How many numbers: "); number=int.Parse(Console.ReadLine()); Console.Write("Give the numbers:"); numbers = Console.ReadLine(); Console.Write("Mode:"); mode = int.Parse(Console.ReadLine());
for (int i = 0; i < number;i++ ) { if (mode==int.Parse(numbers[i].ToString())) { numberoftimepresent += 1; } } Console.Write("Number of time present:" + numberoftimepresent.ToString()); Console.WriteLine("\nPress any key to exit"); Console.ReadLine(); } } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment