What is output from the following segment of code

Assignment Help C/C++ Programming
Reference no: EM13809613

1. What is output from the following segment of code? (note: this is a code segment, not a complete program.)

int x;

for (x= 1; x <= 5; x++)

printf ("%i ", x+1)

2. Using the variable declarations below, what gets output once the printf statement shown below is executed:

int num1 = 2;

int num2 = 3;

printf ("%i", num1 + num2);

3. What is output from the following code segment:

int a, b;

for (a = 1; a <= 2; a++)

for (b = 1; b <= 3; b++)

printf("%i ", a + b);

4. Write a program that asks the user to enter how many hot dogs they wish to purchase. It will then compute the price of that many hot dogs at $1.50 each, compute the meals tax of 5%, and display the number of hot dogs and the original price, the meals tax amount, and the total amount due on three separate lines with appropriate labels. (No header or comments should be inserted in the code! No trap loops or any loops are needed, it will result in deductions!).

5. Assume that a, b, c, and d are all variables of type int. Also assume that: a = 2, b = 3, and c = 5. What value is stored in variable d after the following C statement is executed:

d = (a + b) + c * 5;

6. How many times would the following loop execute?

for (x = 2; x <= 10; x += 2)

printf ("I am in the loop!\n");

7. In C, for variables of type int we use %i as the format specifier in printf and scanf statements. What do we use as the format specifier for variables of type float, if we want to output the floating point value, showing 3 decimal places?

8. Assume x is a variable of type int. Which for loop below would output the following: (Choose all that apply.)

10

20

30

40

50

a. for (x = 1; x <= 5; x++)

printf ("%i\n", x * 10);

b. for (x = 1; x <= 50; x++)

printf ("%i\n", x);

c. for (x = 1; x <= 5; x++);

printf ("%i\n", x);

d. for (x = 10; x <= 50; x = x + 10)

printf ("%i\n", x);

e. for (x = 9; x <= 49; x = x + 10)

printf ("%i\n", x + 1);

Reference no: EM13809613

Questions Cloud

Weighted average cost of capital : The Black Bird Company plans an expansion. The expansion is to be financed by selling $32 million in new debt and $71 million in new common stock. The before-tax required rate of return on debt is 11.74% percent and the required rate of return on equ..
Assume annual compounding : You are a financial analyst with the U. S.- based MNC Prod & Push, which sells consumer products around the world. You report directly to the CFO. You have been assigned the task of negotiating with bankers on certain forward contracts involving the ..
Present value of an annuity stream-time value money : This assessment has two parts both addressing the subject of Time Value Money (TVM). Both parts should be submitted in the same paper. The main TVM problems relating to healthcare are: a) present value of a lump sum b) present value of an annuity str..
Discuss the neolithic revolution : Discuss the Neolithic Revolution
What is output from the following segment of code : What is output from the following segment of code? (note: this is a code segment, not a complete program.) What is output from the following code segment
Expected cash flow related to this debt issue : FRN and Expected Cash Flows. A U. S. firm issues a three- year FRN with a face value of $ 250,000. The coupon is set at LIBOR plus 50 basis points and is paid annually. The coupon rate is set at the beginning of the year. The firm’s CEO notes that th..
What is after-tax cost of capital for this debt financing : Great Seneca Inc. sells $100 million worth of 21-year to maturity 8.91% annual coupon bonds. The net proceeds (proceeds after flotation costs) are $988 for each $1,000 bond. The firm's marginal tax rate is 40%. What is the after-tax cost of capital f..
Examine the culture of the hewlett packard organization : Examine the culture of the selected organization. Explain how you determined that the selected organization showed the signs of the culture that you have identified.
Write the economic analysis section of a business proposal : Write the economic analysis section of a business proposal. This will include statements about the market structure and the elasticity of demand for the good or service, based on text book principles

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Solution to the naur text-processing problem

Design and implement a solution to the Naur text-processing problem using the language specified by your instructor. Execute it against test data and record the number of faults you find and the cause of each fault

  Pseudocode for constructing the reverse of an input string

For each position of the string starting at the end working backwards - Append the character at that position to the reverse of the string.

  Write a value-returning function

Write a program that uses the function isNumPalindrome given(Palindrome Number). Test your program on the following numbers: 10, 34, 22, 333, 678, 67876, 44444, and 123454321.

  Design an employee class that has fields for name

Design an Employee class that has fields for the following pieces of information: Employee Name and Employee Number

  Write a program that calculates the user''s bmi

Write a program that calculates the user's body mass index (BMI) and categorizes it as underweight, normal, overweight, or obese, based on the following table from the United States Centers for Disease Control

  Write the class definition for a class called complex

. Write the class definition for a class called complex.

  How to compile your program

how to compile your program (including the actual compile command) and how to run it (including command line arguments, if any) A description of your solution to these two problems, including what you did to solve the problem, and why you did it that..

  Variables should be private and the class functions public

All the class variables should be private and the class functions public. The class functions should be implemented in a file Inventory.cpp which should be linked with the inventory.hpp file.

  Write a for loop that displays the following set of numbers

Write a for loop that displays the following set of numbers 0, 5, 10, 15, 20, 25 ...... 500.

  To reverse the order of elements on a stack

Write a program in C++ to  reverse the order of elements on a stack S using two additional stacks using one additional stack

  Write an interactive program that prompts for a desired sum

Write an interactive program that prompts for a desired sum, then repeatedly rolls two six-sided dice until their sum is the desired sum. Here is the expected dialogue with the user.

  Write a program to calculate the area of a circle

Write a program to calculate the area of a circle. The program should use two procedures. The first procedure will print out the program heading and ask the user to enter the radius. The second procedure should calculate the area. The area of the cir..

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