Question

Write a program that: program starts; declares and initializes to 10 an integer variable i; uses...

Write a program that: program starts; declares and initializes to 10 an integer variable i; uses a do loop; print on new line “loop pass # “ and i; if i = 4 break default decrement i by 1 by stating i once; test condition i > 0; just before ending print on new line “Program finished!” then terminate program.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#include <stdio.h>

int main() {

int i=10; // declares and initializes to 10 an integer variable i

do // uses a do loop

{

printf("\nloop pass # %d",i); // print on new line “loop pass # “ and i

if(i==4) // if i = 4 break default decrement i by 1 by stating i once

break;

i--;

}while(i>0); // test condition i > 0

printf("\nProgram finished!\n"); // just before ending print on new line “Program finished!”

return 0;

}

Output:

Online C IDE, and online share new repl Sign up run 88 talk save host your programs and apps online f... saving main.c clang

Any doubts leave a comment

Add a comment
Know the answer?
Add Answer to:
Write a program that: program starts; declares and initializes to 10 an integer variable i; uses...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You...

    Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You can initialize the variables to any legal value of your choosing. Next, declare and initialize a pointer variable to each of the variables Using printf), output the following: The address of each of the first three variables. Use the "Ox%x" format specifier to print the addresses in hexadecimal notation The value of each variable. They should equal the value you gave...

  • // Group Names: // Date: // Program Description: //   Import required packages //--> //   Declare class...

    // Group Names: // Date: // Program Description: //   Import required packages //--> //   Declare class (SwitchDoLab) //--> {    //   Declare the main method    //-->    {        //   Declare Constant integers SUM = 1, FACTORIAL = 2, QUIT = 3.        //-->        //-->        //-->        //   Create an integer variable named choice to store user's option.        //-->        //   Create a Scanner object        //   Create...

  • Write a C program named space_to_line.c that features a while loop that continuously reads input from...

    Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...

  • Hello. I just need help with my c++ code. Write a program that: Creates an integer...

    Hello. I just need help with my c++ code. Write a program that: Creates an integer variable AND an integer pointer variable Ask the user to input an integer value Store the value in the integer variable Print the address of the variable. Make the pointer variable point at the integer value Print the value pointed to by the pointer Print the address of the pointer

  • Write and submit the source code for the following program. The program will use an integer...

    Write and submit the source code for the following program. The program will use an integer array of size 10 to store the prices of smartphones. It will then determine and print the prices of the most expensive and cheapest phones. Use the following variables: int[] prices = new int[10]; // Array of smartphone prices Assignment Ask the user for the price of each smartphone (using a for loop) Sort the list of smartphones (once) from low to high price...

  • C program: 1: Write a program that uses 5 threads. Initialize a shared variable with a...

    C program: 1: Write a program that uses 5 threads. Initialize a shared variable with a value of 100. Each thread must add its Thread ID (tid) to the shared variable. Once a thread has done the addition, print the ID of the thread. [Note: thread does the printing] Output the value of the shared variable once all threads have finished incrementing it. [Note: main code does the printing] Provide a text file with your comments on the results of...

  • Need help with java programming. Here is what I need to do: Write a Java program...

    Need help with java programming. Here is what I need to do: Write a Java program that could help test programs that use text files. Your program will copy an input file to standard output, but whenever it sees a “$integer”, will replace that variable by a corresponding value in a 2ndfile, which will be called the “variable value file”. The requirements for the assignment: 1.     The input and variable value file are both text files that will be specified in...

  • I am creating a program that will allow users to sign in with a username and...

    I am creating a program that will allow users to sign in with a username and password. Their information is saved in a text file. The information in the text file is saved as such: Username Password I have created a method that will take the text file and convert into an array list. Once the username and password is found, it will be removed from the arraylist and will give the user an opportunity to sign in with a...

  • Task 5.2 Numerical Analysis Using Nested Loops (13 pts) Consider the following program: void setup() {...

    Task 5.2 Numerical Analysis Using Nested Loops (13 pts) Consider the following program: void setup() { //Read a positive integer from the user //Your code starts here } Complete this program such that it calculates all prime numbers between 1 and the value that is assigned to variable num and outputs them on the screen. A prime number is a positive integer that has no other factors other than itself and 1. You should use a nested loop, i.e., write...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT