Home › Forums › C Programming › Welcome C++ › Reply To: Welcome C++
July 31, 2007 at 5:11 am
#3203
[email protected]
Participant
How to count all the three digit number tht lie between 100 to 300 and whose 1st & last digit is 2?
Ans:
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <iostream> using namespace std; void display() { int count = 0; for(int i = 100;i<300;i++) { int value = i; if(((value%10)== 2) &&(value/100)==2) { cout<<value<<endl; count++; } } cout<<"Total Number "<<count<<endl; } void main() { display(); } output: 202 212 222 232 242 252 262 272 282 292 Total Number 10 |