Select the most appropriate answer for the given code#include<stdio.h>void main(){ int i=1; for(;i<=5;) { printf("i=%d\n",i); i++; }}a.Errorb.It will print i equal to 1 for five timesc.It will print i equal to 1 to 5 in decreasing orderd.It will print i equal to 1 to 5 in increasing order
Question
Select the most appropriate answer for the given code#include<stdio.h>void main(){ int i=1; for(;i<=5;) { printf("i=%d\n",i); i++; }}a.Errorb.It will print i equal to 1 for five timesc.It will print i equal to 1 to 5 in decreasing orderd.It will print i equal to 1 to 5 in increasing order
Solution
The correct answer is d. It will print i equal to 1 to 5 in increasing order.
Here's the step by step explanation:
- The variable
iis initialized to 1. - The
forloop condition checks ifiis less than or equal to 5. If it is, it enters the loop. - Inside the loop, it prints the value of
iand then incrementsiby 1. - This process repeats until
iis no longer less than or equal to 5. - Therefore, the output will be
iequal to 1 to 5 in increasing order.
Similar Questions
Select the correct answerThe while loop repeats a set of code while the condition is not met?OptionsTrueFalse
Select the correct answerWhich of the following is an invalid variable?Options1code_tantra_codecode_tantra_1
Select the correct answerWhat will be the output of the following Python code snippet?ct = 'code'for i in range(len(ct)): print(ct) ct = 'a'Optionsnone of the mentionedaaaacodecodecodecodea
Select the correct answerWhich of the following is invalid?Options_c = 1__cod__ = 1none of the mentioned__c = 1
Select the correct answer Which of the following is not a keyword?Optionsevalnonlocalassertpass
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.