You are here:

C++/C++

Question
Dear sir

When i ask a user to input a number 3 digits long how do you ensure that the first digit is not one (1)?

thank you.

Dear Noorain,

enter a three digit number, and you wana put a
condition that it shouldn't contain '1' as the first
digit. Then you have to find such a condition that
will divide the number by a constant value whenever
you enter it, and it calculates the quotient,
for example,

User enters : 234

internally i would bring condition like

int number ;

number = entered number / 100 ;
It will store the quotient in the variable number.
Like i said you entered 234

it would be

number = 234 / 100 ;
It would store 2 in the number and make sure that the
number is not 1 by putting simple condition like this

if ( number != '1' )
cout<<"It is a valid number";
else
cout<<"It contains 1 as the first digit";

You should find out the 100th Number position in the
number. Like i did in the above example. I hope this
helps you a little.

Don't be afraid to ask, if you get stucked somewhere.
Best of Luck,
Professional
Questioner's Rating
 Rating(1-10) Knowledgeability = 10 Clarity of Response = 10 Politeness = 10 Comment the expert is polite, and expert in his field, and very friendly.

C++

Volunteer

Professional

Expertise

I can answer any question about functions,pointers,structures,object oriented programming basics of classes and data structures.My strong field is structured programming.

Experience

I have got 2 years experiece under C . I am able to answer about the structured concepts pointers to a little extent,OOP concepts. I have also experience in data Strucutres like Linked List, Stacks , Queues, Heaps, B Trees, Red Black Trees. I will try to satisfy with my knowledge. I am the Student of an expert here Martin, what i have learnt today, i just owe my every knowledge to him. He is the greatest.