+ 2

Write a c++ program that display all the even numbers from 1_ 100 using f0r loop

Loop

3rd Apr 2019, 12:13 PM
Aminu Kazaure
Aminu Kazaure - avatar
7 Respostas
+ 3
read and play around with the codes in here you can code yourself in minutes. If still having difficulty insert link of your effort here we will be glad to help. happy coding : https://www.sololearn.com/learn/CPlusPlus/1616
3rd Apr 2019, 12:28 PM
Daljeet Singh
Daljeet Singh - avatar
+ 3
#include <iostream> using namespace std; int main() { int x; for (x=0; x<=98; x+2) { x=x+2; cout<< x <<endl; } return 0; }
3rd Apr 2019, 12:36 PM
‎ ‏‏‎
+ 2
Tnx alot
5th Apr 2019, 1:32 PM
Aminu Kazaure
Aminu Kazaure - avatar
+ 1
Tnx
3rd Apr 2019, 11:45 PM
Aminu Kazaure
Aminu Kazaure - avatar
+ 1
Try this again! #include <iostream> #include <stdint.h> void print_even(uint32_t max_num) { for (uint32_t i = 2; i <= max_num; i += 2) std::cout << i << std:: endl; } int main() { print_even(2000); return 0; }
5th Apr 2019, 5:30 AM
Edison
Edison - avatar
+ 1
Hay Edison , your code is good for upto 200 but it doesn't work for huge numbers, once check it out.
5th Apr 2019, 2:30 PM
‎ ‏‏‎
+ 1
#include <iostream> using namespace std; int main() { int x; for (x=0; x<=98; x+2) { x=x+2; cout<< x <<endl; } return 0; }
20th Apr 2019, 6:26 PM
farrukh khan
farrukh khan - avatar