#include<stdio.h>
int main()
{
int i=1;
while(i<=9)
{
printf("The value of i is :%d",i);
......................
}
printf("wrong input");
}
anyone can tell right formula that has put in blank , so it can show output 2,4,6,8
#include<stdio.h>
int main()
{
int i=1;
while(i<=9)
{
printf("The value of i is :%d",i);
......................
}
printf("wrong input");
}
anyone can tell right formula that has put in blank , so it can show output 2,4,6,8
Use code tags when posting code.
To see if a number is even, you can use the modulus operator:
Code:if (i % 2 == 0) { /* i is even. */ }
no... i dont want use if .....i want use that "While", i just want to no the formula that i can use?
Put the if expression inside the while loop and only print i when the expression is true. Or you could simply start at i=2 and increment it with two instead of one each iteration.
Bored with asking OP to use code tags - time for plan B
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.