0
I want to count 9 b/w 100 to 1000 in c++ lng plz hlp me
5 Réponses
+ 9
@Rupam
according to me, the logic has to be like written below 👇👇👇👇
void main ()
{
int dig, count =0,q,n;
cout <<"enter the digit you want to count between 100 and 1000";
cin>>dig;
for (n=100;n<=1000;n++)
{
while(n)
{
q=n%10;
if(q==dig)
count++;
n=n/10;
}
}
cout <<count;
getch();
}
please correct me if I am wrong anywhere.....
suggestions are most welcome. 😀😀😀
+ 1
Like This?
#include <iostream>
using namespace std;
int main() {
for(int x=100; x<1000; x+=9)
{
cout << x << endl;
}
return 0;
}
https://code.sololearn.com/csYdU6qxQUjG/?ref=app
+ 1
https://code.sololearn.com/cP1xajslpO3H/?ref=app
This is your answer, I hope you understand it simply!
0
no i dont want this... i want to know how many nine digts b/w 100 to 1000..