What causes an infinite loop and how do we break it

Assignment Help Programming Languages
Reference no: EM131232606

For questions 1-5, please complete each question.

1. Write a loop to print all multiples of three from 0 to 100.

2. What causes an infinite loop? How do we break it?

3. Find 3 mistakes in the code and correct them:

#include <stdio.h>
int main();
{
float area = 0, length = 6;
area = length * width;

printf("The area of the rectangle is %f \n", &area);
return 0;
}

4. True or False. A switch statement can allow a range of values for a variable on a single case statement.

5. What is the output of the following code?

a = 0, b=0, c=0, d=0.

for (a = 0; a<=10; a++)
{
if (b<= -1)
{
b-=2;
c++;
d+=5;
}
else
{
for (b=0; b>=-5; b--)
{
c = a + b;
d = c - a;
}
printf("\n %d %d %d %d \n", a, b, c, d);
}
}

6. Write a program to compute the impedance, Z, and inductance, L, of an electrical coil given voltage, V, current, I, resistance, R, and frequency, F, for six different circuits. Have the user input V, I, R, and F each time. Use the following formulas for your calculation:

Z = V/I
Z2 = XL2 + R2
XL = sqrt(Z2 - R2)
L = XL / (2*PI*F)
L is the inductance
XL is the reactance
Z is the impedance.

Each iteration should print out the voltage, current, reactance and impedance.

Use these input values for your 6 iterations:

Iteration

Voltage

Current

Resistance

Frequency

1

120

12

8

50

2

250

14

7

50

3

150

16

9

50

4

100

10

5

50

5

220

12

8

50

6

300

19

9

50

7. Write a program to compute the periods of a simple pendulum for arm lengths starting at 12 inches and reaching a period of less than or equal to 3.45.

a. The arm length L in feet varies from 1 to n.

period = 2*PI * sqrt(L/g)

where g = 32.2 ft/sec2

For this problem, for each iteration, print out the length and period and increase the length by 1 foot.

Reference no: EM131232606

Questions Cloud

Design a treatment plan for don : Based on this additional information, design a treatment plan for Don. The facility at which you work uses the form in the template below. Use this form to complete your information.Attached is the form.
Why should business strategy drive is strategy : Why should business strategy drive IS strategy? Explain the commonality between organizational strategy and your own professional strategy. What is your professional strategy?
How many copies of each gene does a human being possess : What is a gene? How many copies of each gene does a human being possess? What is an allele? What is a chromosome? How many pairs of chromosomes do most human cells possess?
Uses proprietary computer software to offer services : A company uses proprietary computer software to offer services that other companies have not been able to match. A company has a product with unique features not matched by the competition and customers are clamoring to buy the product due to its uni..
What causes an infinite loop and how do we break it : Write a loop to print all multiples of three from 0 to 100. What causes an infinite loop? How do we break it? Write a program to compute the impedance, Z, and inductance, L, of an electrical coil given voltage, V.
Key performance measures of a make-to-stock process : Which of the following is/are key performance measures of a make-to-stock process? Which one of the following would be considered a primary input in a university system?
Maintaining a quality image is primarily the responsibility : Maintaining a quality image is primarily the responsibility of:
Uses make-to-tock strategy to meet customer demand : Suppose a company uses a make-to-tock strategy to meet customer demand. A critical performance measure in using this strategy is to:
Appropriate process for converting inputs to outputs : Which of the following factors should be considered to determine an appropriate process for converting inputs to outputs?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd