1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Georgia [21]
3 years ago
6

Please use C programming to write a code segment as an answer. Instead of using an while-loop like the following code, please im

plement a code segment by using a do-while loop. What is the output of the code?
#include
void main()
{
int i = 0;
while (i < 5);
{
printf("%d ", ++i);
}
}
Computers and Technology
2 answers:
krok68 [10]3 years ago
5 0

Answer:

#include <stdio.h>

void main()

{

int i = 0;

do{

printf("%d ", ++i);

}

while (i < 5);

i=i+1;

}

}

Explanation

The #include needs to include something and that's the standard input and output which is coded has stdio.h

In the do while loop what it does is print the value of I while I is less than 5 and you increment I value so as to prevent infinite looping

Anna71 [15]3 years ago
4 0

Answer:

The program using do-while loop defined as follows:

Program:

#include <stdio.h> //include header file

int main() //defining main method

{

int i = 0; //defining integer variable i and assign value.

//defining do-while loop

do  

{

printf("%d", ++i); //print value

}while (i<5); //check condition  

return 0;

}

Output:

12345  

Explanation:

Output of given program:

In the given program, it will not print any value because in while loop semi colon is used which is not valid.

Program Explanation:

In the above C language program header file is included, which provides features to use basic function then the main method is defined inside this method an integer variable "i" declare, that holds a value which is "0".  In this method, the do-while loop is defined. In the do section, we print value and in the while block checks the condition which is i is less than 5.

You might be interested in
When defining an array of class objects, how do you pass arguments to the constructor for each object in the array?
Nuetrik [128]
Basically, the array[ index ] is the name of the object so when you  populate the array you'd have statement[s] like:

array[ index ] = new ClassName( arg0, arg1, arg2 );
8 0
3 years ago
Multiple Choice
natta225 [31]

Answer:

information technology

6 0
3 years ago
Read 2 more answers
Write short note on points to consider while using attributes with the tags.​
ASHA 777 [7]

Answer:

Explanation:

Tags are used to display the content but what about the specifics of that content like if a lik should open ina window or the location of an image .Attributes are used to specify things like this regarding the content on your webpages.Attributes are located within tags.Attributes are located in start tag only,not in end tags.

7 0
3 years ago
jakie krasnale mieszkaja we wroclawiu i opisz kto napisal kronike, prosze nie kopiowac dlugich tekstow najlepiej by bylo opisac
ASHA 777 [7]
Co kronika czytasz od?

6 0
4 years ago
Write a function that is named times_ten and accepts a number as an argument. When the function is called, it should return the
Stells [14]

It changes a little depending on what programming language you're using, but in C you could say

int times_ten (int num) {

    num = num*10;

    return num;

}

Or, in general terms:

Integer Function times_ten (Integer num)

    Set num = num * 10

    Return num

This is all done assuming the number used as an argument is an integer and that you are returning an integer value, not a decimal. The main thing to notice is that since you have to return a value, you must have two things: a return statement, and a type declaration for the function, otherwise you'll get an error.

4 0
3 years ago
Other questions:
  • Compare the specialized and statistical functions in excel
    10·1 answer
  • To share a document in my online electronic journal, I should select the option to _____.
    14·1 answer
  • List three things that scientists learned about earth beginning in the 1800s
    13·1 answer
  • Why is it preferable to code web pages in HTML format?
    6·2 answers
  • The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have t
    12·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    13·1 answer
  • a term to describe article that can be displayed in their entirety as opposed to abstract and reference only?​
    10·1 answer
  • I need answer pooooooo​
    13·1 answer
  • Provide 10 points for each question
    6·1 answer
  • Question 2 of 10
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!