+ 2
Please find the error
9 Respuestas
+ 1
Then you can like if condition
if(n%3==0) or if you want to break in even condition also or odd condition then you can write like:
if(n%2==0)
{
break;
}
else
{
break;
}
I hope it's clear to you
+ 1
I want to break the loop if an odd number is entered
+ 1
Thank you
+ 1
Sahithi Polunati the code has an unnecessary use of the break statement. To exit the loop, put the condition in the while statement.
do {
printf("enter a number n: ");
scanf("%d", &n);
printf("%d \n",n);
} while (n%2==0); //loop while even
0
#include <stdio.h>
int main() {
int n;
do{
printf("enter a number n: ");
scanf("%d", &n);
printf("%d \n",n);
if(n%2==0) {
break;
}
} while(1);
printf("thank you");
return 0;
}
0
#include <stdio.h>
int main() {
int n;
do{
printf("enter a number n: ");
scanf("%d", &n);
printf("%d \n",n);
if(n%2!=0) {
break;
}
} while(0);
printf("thank you");
return 0;
}
0
Kripal Garaiya 🤔 while (0)⁉️ 🤦
0
Yes
0
Try it