Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,208,833 members, 8,003,960 topics. Date: Saturday, 16 November 2024 at 02:17 AM

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++ (626 Views)

Help Needed On C / Tutor On C# Needed / Help Needed On C# (2) (3) (4)

(1) (Reply) (Go Down)

Please Can Someone Me With This Question On C++ by ade4prof: 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:
Write a C++ program that print "Too Many" when the variable count exceeds 100
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

int count = 0;
do{
count<<"Too many";
break;
}while(count++ > 100);
Re: Please Can Someone Me With This Question On C++ by ehinorlive: 6:53pm On Jun 19, 2021
Ikesmith:
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;
}
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
Deicide:

int count = 0;
do{
count<<"Too many";
break;
}while(count++ > 100);

Really ??

Flawed code .
Re: Please Can Someone Me With This Question On C++ by africonn: 10:31pm On Jun 19, 2021
shegzhkn:


Really ??

Flawed code .

< Will fix the bug
Re: Please Can Someone Me With This Question On C++ by Deicide: 11:20pm On Jun 19, 2021
shegzhkn:


Really ??

Flawed code .
How is it flawed?
africonn:


< Will fix the bug
Which bug?
Re: Please Can Someone Me With This Question On C++ by TheCongo2: 11:41pm On Jun 19, 2021
ehinorlive:
change for(int count = 1; count<=101; count++){

to for(int count = 1; count<101; count++){

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:


What is wrong with count <= 101
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:
using ( < = ) will make it count to exactly 101 but using (< ) will count to 100

Thank you so much
Re: Please Can Someone Me With This Question On C++ by airsaylongcome: 10:07pm On Jun 20, 2021
Deicide:

int count = 0;
do{
count<<"Too many";
break;
}while(count++ > 100);

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:


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
did you run my code and it prints "Too many" 100 times?

(1) (Reply)

Pepakura Designer - Windows PC / Google Machine Learning Bootcamp Email / My Latest Project With HTML, CSS And Javascript.

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.