Rewrite the following code using a for loop instead of a whileloop. The variable i is an integer. Only provide the first line ofthe for loop. I am assuming the body of the for loop will onlycontain the print statement.
int i =1;
while (i <= 10) {
printf(“%dn”, i);
i++;
}
Answer
for (int i = 1; i <= 10; i++)