Skip to main content

finding value of a character as integer in c++

#include<iostream>
using namespace std;
int main()
{
int x = 0x63;
float y = 32.245;
char z = 'c';
cout<< "x is " << x << " y is " << y << " z is " <<  z << '\n';
z = x;
x = y;
y = z;
cout<< "x is " << x << " y is " << y << " z is " <<  z << '\n';
x = 0x5632; //how many bytes are needed for 0x5632?
z = x;
cout<< "x is " << x << '\n';
cout<< "z as a character is " << hex << z << "....and as integer..." <<  (int) z;

return 0;
}

output
x is 99 y is 32.245 z is c
x is 32 y is 99 z is c
x is 22o66
z as a character is 2....and as integer...32

Comments

Popular posts from this blog

Area Calculation By ImageJ

  Area Calculation By ImageJ      Open the Software      File => Open       Zoom in the Image and select the straight line        Mark the small line on graph and go to analyse => set scale      Set known distance 01, unit cm and click ok       Go to free hand and cover the area you want to calculate       Then press (ctrl + m) repeat the process for 3 time       After that go to the result and summarize 

Weight conversion program using functions in c++

#include<iostream> using namespace std; int num(int n) { cout<<"num of chocolate:"; cin>>n; return n; } int ounce(int a) { cout<<"weight in ounce:"; cin>>a; return a; } int pound(int b) { cout<<"weight in pound:"; cin>>b; return b; } int main () { int n, a, b; char choice; cout<<"enter choice 'o' for ounce and 'p' for pounds:"; cin>>choice; int x, y, z; x = num(n); y = ounce(a); z = pound(b); if (choice == 'o') {cout<<"total weight in ounce:"<<x*y;} if (choice == 'p') {cout<<"total weight in pounds:"<<x*z;} return 0; } ************************** Output:

Activation Energy Calculation in Origon

  Activation Energy ·          Click on the curve, go to analysis, fitting, and linear fit ·          Note the slope and error ·          Then follow the Formula to find activation energy              Ea =  mRln(10)1000 m= slope, R= 8.6173*10 -5 eV/K , ln(10) = 2.303