Practice # 3
In this coding practice, Io discuss variable scope and types of data or data types. I have to mention the discussion in the comment code and the definitions of variable scope and the syntax declaration of variables in CPP. To get this code click on Read more and get the code and check and practice it thanks.
In this coding practice, Io discuss variable scope and types of data or data types. I have to mention the discussion in the comment code and the definitions of variable scope and the syntax declaration of variables in CPP. To get this code click on Read more and get the code and check and practice it thanks.
#include <iostream>
//variable scope and data types
/*
variable types or data type builtin
1. int (integer numbers)
2. float (floating type of numbers)
3. char (characters)
4. double (long and precise floating numbers)
5. boolean (true or false, 0 or 1)
Example: int sum=34; means sum is an integer veriable which
holds value 34 in memory.
*/
/*
Syntex for Decleration veriables in C++
Data_type Veriable_name = Value;
Like this
int sum = 6;
Based on scope, The two veriables in C++
1. Local Veriables: are declared inside the braces of any
function and can be accessed only from there.
2. Globle Veriables: re declared outside of any
function and can be accessed from anywhere.
*/
/*
Data types
1. Builtin (int, float, char, double, boolean)
2. User-defined (structure, union, Enum)
3. Derived (array, function, pointer)
*/
using namespace std;
int main(){
//int a=5;
//int b=10;
int a=5, b=10;
cout<<"It is the trial code\n";
cout<<"First Number is." <<a<<"\nSecond Number is."<<b;
int sum = a+b;
cout<<"\nTotal sum is ="<<sum;
float pi = 3.14;
cout<<"\nThe value of pi is = "<<pi;
char c = 'G';
cout<<"\nThe value of C is = "<<c;
return 0;
}

Comments
Post a Comment