answersLogoWhite

0

The switch/case statement in the c language is defined by the language specification to use an int value, so you can not use a float value. You can, however, convert the float into an int and use it, so long as the resulting values and functionality meet your functional requirements.

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

How do you convert string into integer in Asp.net using C?

In ASP.NET using C#, you can convert a string to an integer using the int.Parse() method or int.TryParse() method for safer conversion. For example, int number = int.Parse(yourString); will convert the string to an integer but will throw an exception if the string is not a valid integer. Alternatively, int.TryParse(yourString, out int result) returns a boolean indicating success or failure and assigns the converted integer to result if successful, avoiding exceptions.


How do you convert an integer into a text using C?

sprintf is the most common solution


Is it possible to convert a string into integer without using any function in c?

Yes


How do you find by program a given number is integer or float?

If it contains a decimal point or an exponential part, then it should be handled as a float (or double).You can determine an existing variable's type in C using the type() function


How do you convert integer array to string array in c?

To convert an integer array to a string array in C, you can use the sprintf function within a loop to format each integer as a string. First, create a string array with enough space to hold the string representations. Then, iterate through the integer array, using sprintf to convert each integer to a string and store it in the corresponding index of the string array. Here's a simple example: #include <stdio.h> void intArrayToStringArray(int *intArray, char stringArray[][12], int size) { for (int i = 0; i < size; i++) { sprintf(stringArray[i], "%d", intArray[i]); } }

Related Questions

Can an integer be 3 and a half?

No, an integer cannot contain a decimal place. Instead consider using a double or a float for decimals.


How do you convert string into integer in Asp.net using C?

In ASP.NET using C#, you can convert a string to an integer using the int.Parse() method or int.TryParse() method for safer conversion. For example, int number = int.Parse(yourString); will convert the string to an integer but will throw an exception if the string is not a valid integer. Alternatively, int.TryParse(yourString, out int result) returns a boolean indicating success or failure and assigns the converted integer to result if successful, avoiding exceptions.


How does a float switch work to detect liquid levels in a tank or container?

A float switch works by using a buoyant float that moves up and down with the liquid level in a tank or container. When the liquid level rises, the float also rises, triggering a switch to turn on or off based on the position of the float. This allows the float switch to detect and indicate the liquid level in the tank.


How do you convert an integer into a text using C?

sprintf is the most common solution


How do you enter integer in python?

In Python, you can enter an integer using the input() function, which captures user input as a string. To convert this string to an integer, you can use the int() function. For example: user_input = input("Enter an integer: ") integer_value = int(user_input) This will convert the input string to an integer, assuming the user enters a valid integer.


How do you convert string to int in Java?

One can convert a string variable to an int variable in Java using the parse integer command. The syntax is int foo = Integer.parseInt("1234"). This line will convert the string in the parenthesis into an integer.


How does a float switch work to detect liquid levels in a tank?

A float switch works by using a buoyant object, called a float, that moves up and down with the liquid level in a tank. When the liquid level reaches a certain point, the float rises and triggers a switch to indicate that the tank is full or empty.


Is it possible to convert a string into integer without using any function in c?

Yes


What are the benefits of using a sump pump with a vertical float switch for basement waterproofing?

Using a sump pump with a vertical float switch for basement waterproofing offers benefits such as efficient water removal, reliable operation, and space-saving design. The vertical float switch helps in automatically activating the pump when water levels rise, preventing flooding and water damage in the basement.


How does a water tank float switch work to regulate the water level in a tank?

A water tank float switch works by using a buoyant float that moves up and down with the water level in the tank. When the water level rises, the float also rises, triggering a switch to turn off the water supply. When the water level drops, the float lowers, turning the switch back on to refill the tank. This helps regulate the water level in the tank automatically.


How do I properly connect the float switch wire to the electrical system?

To properly connect the float switch wire to the electrical system, first ensure the power is turned off. Then, strip the wire ends and connect them to the corresponding terminals on the electrical system using wire connectors. Finally, secure the connections and test the float switch to ensure it is functioning correctly.


How do float switches work to detect liquid levels in a tank or container?

Float switches work by using a buoyant object, like a float, that moves up and down with the liquid level in a tank. When the liquid level rises, the float also rises, triggering a switch to turn on or off based on the position of the float. This switch then signals the liquid level to a control system, indicating whether the tank is full or empty.