int k;
for(k = 25; k > 0; k = k – 3)
printf(“\n%d”, k);
To convert this for
loop into a while
loop:
int k = 25;
while(k > 0) {
printf(“\n%d”, k);
k = k – 3;
}
Related Questions:
- Differentiate between for loop and while loop.
- Differentiate between while loop and do-while loop.
- What will be the output of the following code?
- What will be the output of the following code?
- Find errors in the following code.
- Explain the difference between a while loop and a do-while loop.
- What is a looping structure? Explain for loop with examples.
- Explain while and do-while loops with examples.
- Describe the concept of functions in C and explain different types of functions.
- What is the purpose of the printf() function? Explain with an example.
- Differentiate between printf() and scanf() functions.
- Evaluate the following expressions:
- What will be the output of the following program?
- What will be the output of the following program?
- Describe how basic and compound assignment operators are used.
- Describe the functions of the following operators:
- Write a program that reads three numbers and prints their sum, product, and average.
- Write a program that reads temperature in Celsius, converts it into Fahrenheit, and prints it on the screen.
- Write a program that reads the length and width of a rectangle and prints its area.
- Write a program that reads the length of one side of a cube and prints its volume.