Hi I wrote this code to print out factors of an integer with a for looop
how do i write it with a while loop?
for(int i = 1; i < integer+1; i++) {
Following code will print the same result as your for loop in printing.
int i = 1; while(i < integer + 1) { if(integer % i == 0) { cout<< i<<" "; } i++; }