Please Can Someone Me With This Question On C++ - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Please Can Someone Me With This Question On C++ (798 Views)
| Please Can Someone Me With This Question On C++ by ade4prof(op): 10:22pm On Jun 14, 2021 |
Write a C++ program that print "Too Many" when the variable count exceeds 100 |
| Re: Please Can Someone Me With This Question On C++ by stanliwise(m): 7:25am On Jun 15, 2021 |
ade4prof:Use a simple loop. Check google it is everywhere. |
| Re: Please Can Someone Me With This Question On C++ by Nobody: 9:08am On Jun 19, 2021 |
It is been long I did c++ though, but I think this code should work, with maybe a little debugging #include<iostream> using namespace std; int main(){ for(int count = 1; count<=101; count++){ cout<<count<<endl; if(count>100){ cout<<"Too many"<<endl; } return 0; } |
| Re: Please Can Someone Me With This Question On C++ by Deicide: 6:03pm On Jun 19, 2021 |
|
| Re: Please Can Someone Me With This Question On C++ by ehinorlive: 6:53pm On Jun 19, 2021 |
Ikesmith:change for(int count = 1; count<=101; count++){ to for(int count = 1; count<101; count++){ |
| Re: Please Can Someone Me With This Question On C++ by shegzhkn: 9:16pm On Jun 19, 2021 |
| Re: Please Can Someone Me With This Question On C++ by africonn: 10:31pm On Jun 19, 2021 |
shegzhkn:< Will fix the bug |
| Re: Please Can Someone Me With This Question On C++ by Deicide: 11:20pm On Jun 19, 2021 |
| Re: Please Can Someone Me With This Question On C++ by TheCongo2: 11:41pm On Jun 19, 2021 |
ehinorlive:What is wrong with count <= 101 |
| Re: Please Can Someone Me With This Question On C++ by ehinorlive: 10:11am On Jun 20, 2021 |
TheCongo2:using ( < = ) will make it count to exactly 101 but using (< ) will count to 100 |
| Re: Please Can Someone Me With This Question On C++ by TheCongo2: 7:04pm On Jun 20, 2021 |
ehinorlive:Thank you so much |
| Re: Please Can Someone Me With This Question On C++ by airsaylongcome: 10:07pm On Jun 20, 2021 |
Deicide:Do loop will execute at least once before checking the loop condition meaning it will print "Too many" 100 times and when count=101 will stop and print nothing |
| Re: Please Can Someone Me With This Question On C++ by Deicide: 1:31am On Jun 21, 2021 |
airsaylongcome:did you run my code and it prints "Too many" 100 times? |
Help Needed On C • Tutor On C# Needed • Help Needed On C# • 2 • 3 • 4
Course Creators Needed • Python Programmers! Can The Errors Of Pycodestyle be Automated ? • If You Are Learning To Code Avoid Nairaland Frontpages