Pages

C++ Programming Tutorials - 5 (Built in data types,Reference variables and Typecasting)

tut8.cpp =

// This tut contains Built in data types,Reference variables and Typecasting
#include<iostream>
using namespace std;
// ******************Built in data types**********************
int c=45;

int main(){
    // int a,b,c;
    // cout<<"Enter the value of a :";
    // cin>>a;
    // cout<<"Enter the value of b :";
    // cin>>b;
    // c= a + b;
    // cout<<"The value of sum is :"<<c<<endl;
    // cout<<"The value of global c is :"<<::c<<endl;

//*******************Reference variables***********************    
    // float x=34.67;
    // float & y=x;
    // cout<<x<<endl;
    // cout<<y<<endl;
    
//******************Typecasting******************************

int p=45;
float f=25.64;
cout<<"The float value of p is :"<<(float)p<<endl;
cout<<"The float value of p is :"<<float(p)<<endl;
cout<<"The int value of f is :"<<(int)f<<endl;
cout<<"The int value of f is :"<<int(f)<<endl;
int tint(f);

cout<<"The expression is"<<p+f<<endl;
cout<<"The expression is"<<p+int(f)<<endl;
cout<<"The expression is"<<p+(int)f<<endl;

return 0;


}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Top 10 Python Packages Every Developer Should Learn

Top 10 Python Packages Every Developer Should Learn There are more than  200,000 Python packages  in the world (and that’s just counting tho...