My own fuction which count digits in number doesn't work as it should :/
Hi,
I wrote a program with function my own function which count the digits of entered number. The problem is whatever i type it shows 0 digits.Why is that?
Hoping for any help;)
Code:
#include <iostream>
using namespace std;
int cikCipari (int skaitlis, int cipars);
int main()
{
int x = 0;
int sk = 0;
cout << "Enter a number: ";
cin >> x;
cout << "There are " << sk << " digits." <<endl;
return 0;
}
int cikCipari (int skaitlis, int cipars){
int cik = 0;
//int skaits = 0;
// int skaitlis = 0;
while (skaitlis != 0){
skaitlis /= 10;
cout << cik;
cik++;
}
if (skaitlis == 0){
cik = 1;
}
return cik;
}