After execution of the following code fragment what is the v
After execution of the following code fragment, what is the value of length and count? Int length = 5; int count = 4; while (count = 100) length = length -2; else length = count length; count++;}
Solution
#include<stdio.h>
#include<conio.h>
main()
{
int length=5;
int count=4;
while(count<=7) ; //here the while loop will run until count value less than or equal to 7
{
if(length>=100) // here the if length satifies the count it will executes it inner statements
length=length-2; //here the length will decrement by 2
else
length=count*length; // else length will be multiple of its count
count++; //and counter increment will done
}
printf(\"length: %d\",length);
printf(\"count: %d\",length);
}
output:
length =686 and count =686
