Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a program that will count the number of digits in an
input integer up to value MAX_VALUE (2147483647). Thus, for
an input of 5837 the output should be
4 digits
Make sure that your program works for the numbers 0, 1, and
10. For the number 0, the output should be
1 digit

Answer Posted / usama azam

#include<iostream.h>
int main ()
{
int num;
cout<<"enter the number ";
cin>>num;
if (num>=0 && num<=9)
cout<<"You have entered one digit";
else if (num>=10 && num<=99)
cout<<"You have entered two digits";

else if (num>=100 && num<=999)
cout<<"You have entered three digits";


else if (num>=1000 && num<=9999)
cout<<"You have entered four digits";

else if (num>=10000 && num<=99999)
cout<<"You have entered five digits";


else if (num>=100000 && num<=999999)
cout<<"You have entered six digits";

else if (num>=1000000 || num<=9999999)
cout<<"You have entered seven digits";
system("pause");
return 0;

}

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the important differences between c++ and java?

1103


How can you link a c++ program to c functions?

1068


What does extern mean in a function declaration in c++?

1166


What is the use of endl?

933


Can I learn c++ without learning c?

962


What is a virtual destructor? Explain the use of it?

953


Explain abstraction.

1047


Can we make any program in c++ without using any header file and what is the shortest program in c++.

1083


When to use “const” reference arguments in a function?

1027


If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?

1078


What is heap sort in c++?

1022


What is pointer in c++ with example?

1029


What are compilers in c++?

1031


What is the function to call to turn an ascii string into a long?

1012


Why can templates only be implemented in the header file?

1067