0

How can we print 1 to 100 without using any loop and goto in c language

8th Oct 2020, 10:37 AM
Prathamesh Mehar
4 Réponses
8th Oct 2020, 10:47 AM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
cout << 1; cout << 2; ... ... ... cout << 100; Copy and paste 100 times. Or you can make a recursive function.
8th Oct 2020, 10:41 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
#include <iostream> void iterate(int j); void add(int k); int main(int argc, char *argv[]) { int i=0; iterate(i); } void iterate(int j) { j++; std::cout<<j<<std::endl; if(j<100) { add(j); } } void add(int k) { k++; std::cout<<k<<std::endl; if(k<100) { iterate(k); } }
8th Oct 2020, 5:12 PM
Aditya rout
Aditya rout - avatar
+ 1
cout<<1,2,3....98,99,100;
8th Oct 2020, 11:32 AM
Shadoff
Shadoff - avatar