answersLogoWhite

0


Best Answer

There are different ways, there is one straight forward though. For instance you have a variable of type char: var1. And you want to convert it to another variable of type int: var2. You can use casting for it:

var2 = (int) var1;

You have to be very careful using casting because it cause buffer overflow. Newer versions of C have many different function to assure correctness of parsing, for instance, TryToParse...

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

The value of an expression can be converted into a different data type if the two sides of the equal sign do not have the same type. This is known as explicit typecasting.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can the value of an expression be converted to a different data type in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is marshalling and Demarshalling?

data marshalling in java means that the structured data item is flattening and converted into external representation data demarshalling is the process of convert the data back to the internal representation and rebuild the data structures.


What is enctype in HTML?

Enctype is a portmanteau of "encoding type." In HTML enctype is an attribute applied to FORM tags. This attribute tells the browser how the data in the form should be encoded, prior to it being sent to the form's action.There are three valid values for the enctype attribute:application/x-www-form-urlencodedmultipart/form-datatext/plainThe first value, application/x-www-form-urlencoded, is the default value. When the browser sees this value, it will URL encode all the data in the form. This means that spaces are converted to "+" signs, and special characters are converted to their ASCII HEX value.Multipart/form-data is the encoding type used to prevent the encoding of the data by the browser. You must use this encoding type if you want to implement a form that uploads files. (Because encoding the binary data in a file would not be good.)The final type, text/plain, leaves the data unencoded except for changing the spaces into "+" signs.


Definition of sentinel-controlled loop?

In a Sentinel-Controlled loop, a special value called a sentinel value is used to change the loop control expression from true to false.For example,when reading data we may indicate the "end of data" by a special value,like -1 and 999.The control variable is called sentinel variable.A sentinel-Controlled loop is often called indefinite repetition loop because the number of repetitions is not known before the loop begins executing.


How can you add different type of data in a stack?

stack is a linear data structure in which data item is either inserted or deleted at one end there are mainly two operations performed on stack.they're push poppush:writing a value to the stack is push or moving the stack pointer up to accomodatethe new item. pop:reading a value from stack or moving the stack pointer down.


Primitive java data types?

The primitive data types in Java are:int: integer value from -232 to 232floatdoublelong: integer value from -264 to 264byte: integer value from -128 to 128char: charactershort: integer value from -32768 to 32768boolean: true or false valueString (not actually a primitive data type)

Related questions

When you add or subtract a certain value from a data set?

You may or may not get a different data set.


Why spreadsheets may need to be converted to alternative file formats?

To enable them to be used by other applications. If you want to get the data from a spreadsheet into a database, it may need to be converted. If it needs to be used on a different operating system, it may need to be converted. It may be converted into plain text so it can be read for example.


What is default values of different primitive data types?

in integral data types default value=0 in decimal type default value is 0.0 in boolean default value is fa


What is dependent sample?

Data gathering in two different samples such that there is matching of the first sample data drawn and a corresponding data value in the second sample.


What would the Z score be if Z equals 0 and Z equals -1.41?

1.41


Three different ways for checking Data is Valid?

One can check if data is valid by checking if a value is within acceptable set of values; by checking if a value is of the correct data type (such as Boolean, integer, double, or string); or by checking is data is formatted correctly.


What is a numerical expression with ex?

data another


Can you show me some example of c plus plus codes using Boolean Expression?

A boolean expression is any expression that evaluates true or false. All primitive types (int , char, etc) are implicitly converted to boolean values depending on whether the value is zero (false) or non-zero (true). User-defined classes must provide a type conversion operator overload in order to be implicitly converted to a boolean value. The following example demonstrates how to use implicit conversion to boolean: #include<iostream> #include<string> #include<cassert> struct foo { int data; operator bool() const { return data != 0; } }; int main() { // primitive data type int x = 42, y = 40; assert(x != y); y += 2; assert(x == y); assert(x&y); // user-defined type foo f {42}; assert(f); f.data = 0; assert(!f); }


What is categorical data?

Categorical data is the statistical data type consisting of categorical variables or of data that has been converted into that form, for example as grouped data.


What do you call information when it has been converted for processing?

data


Definition of Data Range?

the difference of greatest data value minus least data value = data range


Which of these is closest to what you mean to statistically significant?

Statistically significant is the term used to define when two data are distinct enough in value as to be considered different values. To determine whether two data are close enough in value or distinct enough in value to be considered the same or different, usually you have to do a p-test or a t-test, depending on the type of data that you are looking at. Then confer with the corresponding chart for the test that you did to see whether or not the data is statistically significant.