AndreiL
Welcome to AndreiL.
Enjoy your time.
Please log in.

Lenght of integers.

Go down

Lenght of integers.

Post by Lucaci Andrei on Mon Jun 18, 2012 9:58 pm

This function will return the lenght of integers:

 1
2
3
4
5
6
7
8
9
10
11
12
int lenght(int x){
if ((x/10)==0) return (1);
else if (x/100==0) return (2);
else if (x/1000==0) return (3);
else if (x/10000==0) return (4);
else if (x/100000==0) return (5);
else if (x/1000000==0) return (6);
else if (x/10000000==0) return (7);
else if (x/100000000==0) return (8);
else if (x/1000000000==0) return (9);
else return (-1);
}

avatar
Lucaci Andrei
"Tata Lor"


Number of messages : 222
Points : 2266743
Reputation : 1007
Registration date : 2008-08-15
Age : 26
Location : Cluj-Napoca

View user profile http://www.andreil.wgz.ro

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum