How can the code be corrected?

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

In the following lines of code, the Miracle C compiler will not compile the line of code in the center (float x = 1/a;). Why does this occur?

How can it be corrected?

int a = 3;
float x = 1/a;
printf("The value in x is: %f",x);

In some of the compilers the integer division returns an integer and hence cannot be stored in a float variable and to correct this you need to change the second line here with "float x=1.0/a;". Adding ".0" to 1 will make a difference.

Reference no: EM13939289

Questions Cloud

Explain conditional expressions in the c language : What if the initial value assigned to a is 13, not 3? What happens with this code and why does this occur? What does this tell you about setting up conditional expressions in the C language?
What is the genotype of all persons mentioned : In your own words, describe the process of protein synthesis, starting with the DNA, stored in the nulceus, and ending with the completed protein. Be sure to mention the terms code, codon, anticodon, mRNA, tRNA, amino acids and ribosomes in your a..
Calculate the value of t for the hypothesis test : Calculate the value of t for the hypothesis test. (Give your answer correct to two decimal places.)
Importance of distributing handouts : Q1. Explain 3 reasons why it may be hard to work in teams at times. With each reason you state, explain your strategies to try to make the experience more positive Q2. Explain the importance of distributing handouts during business presentation tha..
How can the code be corrected? : In some of the compilers the integer division returns an integer and hence cannot be stored in a float variable and to correct this you need to change the second line here with "float x=1.0/a;". Adding ".0" to 1 will make a difference.
How does mitosis differ from meiosis : In the male reproductive system, the hypothalamus releases (GnRH) to stimulate the release of (LH) from the anterior pituitary, which then causes (Leydig) cells to produce testosterone. (Use abbreviations.) Please check if answers in parenthesis a..
Discuss importance of assessing effect of intangible benefit : Recalculate the NPV of the standard equipment given this outcome. What is the decision now? Discuss the importance of assessing the effect of intangible benefits.
Which payment option would you prefer : Which payment option would you prefer?
Plan a professional powerpoint presentation : Use your Learning Benchmarks (initial and final), Mid-Placement Report and Evaluations, to carefully plan a professional PowerPoint presentation.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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