Practice # 6.1
#include<iostream>
using namespace std;
int main(){
//First Here we practice reference veriables
/*What will do referece variable
suppos if we want to call same value from different variables
or we want to call out our one value from different names of
veriables in our program, so the reference veriable helps us
to do this. Lets check it out and practice */
float before = 245;
float & after = before;
// Let's print it out it's output
cout<<before<<endl;
cout<<after<<endl;
//Now we practice Typecasting
/*What is typecasting?
Typecasting meaning is to change the variable or datatype into another
variable or datatype.*/
int k = 24;
float h = 34.78f;
cout<<"The value of k is : "<<float(k)<<endl;
cout<<"The value of k is : "<<(float)k<<endl;
cout<<"The value of h is : "<<int(h)<<endl;
cout<<"The value of h is : "<<(int)h<<endl;
int g = int(h);
cout<<"The output of the expression : "<<k+h<<endl;
cout<<"The output of the expression : "<<k+g<<endl;
cout<<"The output of the expression : "<<k+int(h)<<endl;
cout<<"The output of the expression : "<<k+(int)h<<endl;
return 0;
}

Comments
Post a Comment