+ 1
Can you help me with a collatz string program but with do while?
The program does not compile me, with do while, what I have to do is collatz series #include<stdio.h> int main(void){ int numero; printf("Ingresa un numero: "); scanf("%d", &numero); Do(numero != 1){ } while (numero % 2 == 0){ printf("%d,", numero); numero = numero / 2; }//fin if Do{ printf("%d,", numero); numero = (numero * 3) + 1; }While(numero == 1); printf("1\n"); return 0; }
2 Answers
+ 3
1st problem: keywords can never be in CamelCase(Like This), they are always lowercase(like this)
2nd problem: you didn't put any statement in do, instead you put that in while... replace the statement in while loop in do.
3rd problem: in do-while loop, the do keyword never take conditions, only while does.
here's the example of the 3rd problem in case you didn't understand it.
do {
printf("%d,", numero);
numero = numero / 2;
} while (numero % 2 == 0);
+ 1
Mucas thanks, now eh I understand better