Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you please do this 2 basic C program 3 A and B? Thank you. 7 CSCI Homework p

ID: 3863757 • Letter: C

Question

Can you please do this 2 basic C program 3 A and B? Thank you.

7 CSCI Homework pdf-Adobe Acrobat Reader DC File Edit View Window Help Home Tools CSCI 110151 /Home... x Sign In 3. Programming A. Create one program with four different types of loops: while loop, do while loop, for loop, and while (1) loop with a break. Each of the 4 loops should display the numbers 0 to 10 inclusive. The numbers 0 to 10 should be displayed on one line with spaces between the numbers. Each loop should display (printf) a short description of the loop type and sequence before the sequence is displayed. See the example below while loop 0 to 10- index is 0 1 2 3 4 5 6 7 8 9 10 do while loop 0 to 10 index is 0 1 2 3 4 5 6 7 8 9 10 for loop 0 to 10 index is 0 1 2 3 4 5 6 7 8 9 10 while (1) loop 0 to 10 index is 0 1 2 3 4 5 6 7 8 9 10 8.50 x 00 in 5 Pl Ask me anything 3/18/2017

Explanation / Answer

#include <stdio.h>

int main()
{
int i=0;
printf("index is :");
for(i=0;i<=10;i++)
{
printf("%d ",i);
}
printf(" ");
i=0;
printf("index is :");
while(i<=10)
{
printf("%d ",i);
i++;
}
printf(" ");
  
i=0;
printf("index is :");
do
{
printf("%d ",i);
i++;
}while(i<=10);
  
printf(" ");
printf("index is :");
i=0;
while(1)
{
printf("%d ",i);
i++;
if(i > 10)
{
break;
}
}
  
}

Output :

index is :0   1   2   3   4   5   6   7   8   9   10  
index is :0   1   2   3   4   5   6   7   8   9   10  
index is :0   1   2   3   4   5   6   7   8   9   10  
index is :0   1   2   3   4   5   6   7   8   9   10  

B)

#include <stdio.h>

int main()
{
int i=0;
printf("index is :");
for(i=0;i<=10;i++)
{
printf("%d ",i);
}
printf(" ");
i=0;
printf("index is :");
while(i<=10)
{
printf("%d ",i);
i++;
}
printf(" ");
  
i=0;
printf("index is :");
do
{
printf("%d ",i);
i++;
}while(i<=10);
  
printf(" ");
printf("index is :");
i=0;
while(1)
{
printf("%d ",i);
i++;
if(i > 10)
{
break;
}
}
  
  
printf(" ");
  
//For steps greater than 1
printf("for loop with step increment of 2 ");
printf("index is :");
for(i=0;i<=20;i=i+2)
{
printf("%d ",i);
}
printf(" ");
i=10;
printf("while loop with decrement step ");
printf("index is :");
while(i>=0)
{
printf("%d ",i);
i--;
}
printf(" ");
  
printf("do while loop with negative numbers as step ");
i=-10;
printf("index is :");
do
{
printf("%d ",i);
i++;
}while(i<=0);
  
printf(" ");
printf("sequence not starting with 0 or 1 ");
printf("index is :");
i=5;
while(1)
{
printf("%d ",i);
i++;
if(i > 10)
{
break;
}
}
  
float j=0.5;
printf("Floating number as step ");
printf("index is:");
for(j=0.5;j<10.5;j++)
{
printf("%.2f ",j);
}
  
}

Output:

index is :0   1   2   3   4   5   6   7   8   9   10  
index is :0   1   2   3   4   5   6   7   8   9   10  
index is :0   1   2   3   4   5   6   7   8   9   10  
index is :0   1   2   3   4   5   6   7   8   9   10  
for loop with step increment of 2
index is :0   2   4   6   8   10   12   14   16   18   20  
while loop with decrement step
index is :10   9   8   7   6   5   4   3   2   1   0  
do while loop with negative numbers as step
index is :-10   -9   -8   -7   -6   -5   -4   -3   -2   -1   0  
sequence not starting with 0 or 1
index is :5   6   7   8   9   10   Floating number as step
index is:0.50   1.50   2.50   3.50   4.50   5.50   6.50   7.50   8.50   9.50