length of each number in array in c 2b 2b

Solutions on MaxInterview for length of each number in array in c 2b 2b by the best coders in the world

showing results for - "length of each number in array in c 2b 2b"
Niclas
31 Feb 2020
1	const int SIZE = 9;
2	int arr[SIZE], arr2[SIZE];
3	cout << "Enter numbers: \n";
4	for (int i = 0; i < SIZE; i++)
5		cin >> arr[i];
6	for (int i = 0; i < SIZE; i++)
7		cout << arr[i] << "\t";
8	cout << endl;
9	
10	int count, number;
11	for (int i = 0; i < SIZE; i++)
12	{
13		count = 0;
14		number = arr[i];
15		do
16		{
17			++count;
18			number /= 10;
19		} while (number);
20		arr2[i] = count;
21	}
22	for (int i = 0; i < SIZE; i++)
23		cout << arr2[i] << "\t";
24	cout << endl;
25
similar questions
queries leading to this page
length of each number in array in c 2b 2b