📖 Samacheer Kalvi · 11th TN - English Medium · Computer Science · Page 138question

Data Types, Variables and Expressions · Part 3

Chapter 3: 4 · Computer Science

:- char c='A'; cout<<ch ; In the above code, ch is declared as a char type variable to hold a character. It displays the character A Example :- char ch='A' cout<<ch+ ; In the above statements, the value of ch is incremented by and the new value is stored back in the same variable ch . (Remember that, arithmetic operations are carried out only on the numbers not with alphabets) so it displays B Another program illustrates how int and char data types are working together. #include <iostream> using namespace std; int main () int n; char ch; cout << "\n Enter an ASCII code ( to ): "; cin >> n; ch = n; cout << "\n Equivalent Character: " << ch; The output Enter an ASCII code ( to ): Equivalent Character: d Illustration .

: C++ program to get an ASCII value and display the corresponding character In the above program, variable n is declared as an int type and another variable ch as a char type. During execution, the program prompts the user to enter an ASCII value. If the user enters an ASCII value as an integer, it will be stored in the variable n . In the statement ch = n ; the value of n is assigned into ch .

Remember that, ch is a char type variable. Chapter Page - - For example, if a user enters as input; initially, is stored in the variable n . In the next statement, the value of n i.e., is assigned to ch . Since, ch is a char type; it shows the corresponding ASCII character as output.

(Equivalent ASCII Character for is d). ( ) float data type: If a variable is declared as float, all values will be stored as floating point values. There are two advantages of using float data types. ( ) They can represent values between the integers.

( ) They can represent a much greater range of values. At the same time, floating point operations takes more time to execute compared to the integer

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →