I made this code but it is looping infinite and I can not fix it ...
#include <stdio.h>
int main (){
int x, z;
while("x=100; x!=65; x-=5"){
z=x*x;
printf("%d --> %d\n", x, z);
}
}
I made this code but it is looping infinite and I can not fix it ...
#include <stdio.h>
int main (){
int x, z;
while("x=100; x!=65; x-=5"){
z=x*x;
printf("%d --> %d\n", x, z);
}
}
I'm pretty sure it's the quotes:
"x=100; x!=65; x-=5"
Remove them:
while(x=100; x!=65; x-=5){
Values in quotation marks in C are char *
, ie you did not pass variables, but char
, and pro loop break need to pass a value like " false
", however while it does not work with ;
, you probably want to use for
:
for (x=100; x!=65; x-=5){
z=x*x;
printf("%d --> %d\n", x, z);
}
Or if it is while
you can use it like this:
x=100;
while (x!=65){
z=x*x;
printf("%d --> %d\n", x, z);
x-=5;
}