I haven't compiled your program.
How many times will the loop below be executed?
Given that 'j' is 1 and 'i' is also 1?
Edit: I'll give you a hint because you're trying (unlike some other people asking questions).
Your current code is, effectively, the same as:
Code:
#include<stdio.h>
int main(void)
{
int i=1,n,sum=0,count=1,j;
printf("HOw many no u want to print");
scanf("%d", &n);
while(count <= n)
{
i++;
if (sum == i)
{
printf("%d",sum);
count++;
}
}
return 0;
}
Why would this be the case? When will the condition if (sum == i) evaluate to true?
Why does the while loop, apparently, never end (unless the number you enter for 'n' is 1 (and only 1)? And if this is the case, your code is, effectively, the same as:
Code:
#include<stdio.h>
int main(void)
{
int i=1,n,sum=0,count=1,j;
printf("HOw many no u want to print");
scanf("%d",&n);
return 0;
}