_hi i am Abhishek and i am new to this community before this i was a python programmer with not so great tools but i will learn eventually and now this is the code i have written from a 30 min tutorial _
include
int main() {
//this is used for comment
std::cout<<"we must initalise the values of variable or other wise it will return garbage which is some random value ";
int dedication =100 ;
double posibility = 99.99 ;
std::cout<<"hi there this is actualy just printing theme ";
std::cout<<dedication;
std::cout<<posibility ;
// this is the second section of the case
//-----------------------------------------------------------------------------------------------
int const pi=3.14;
std::cout<<pi;
// this is naming conventions
//-----------------------------------------------------------------------------------------------
int file_size=1; //this is snake case in
//in this case the spce in a sentence is replaced by an underscore
int FileSize=2; // PascaleCase
// in this case twowrds are wirtten together and the first letter is always capital
int fileSize=3; //camelCase
// in this case the first letter of the first word is small and then the first letter of the second word is capital
std::cout<<"the main thing is the code read the code and understand and the c++ thing the output is because i explained through coding itself ";
//MATHEMATICAL OPERATION
//---------------------------------------------------------------------------------------------------------------
//addition
int a1 = 4;
int a2=5;
int a3= a1+ a2 ; // because both a1 and a2 are intigers hence the a3 will also be intiger
std::cout<<a3;
//substraction
//intiger
int a4=6;
int a5=7;
int a6 = a5-a6; // positive results
std::cout<< a6;
int a7= 1;
int a8= 2;
int a9=a7-a8; //negitive results
std::cout<<a9;
//double
double a10=1.2;
double a11=2.3;
double a12=a11-a10; //positive results
double a13=a10-a11; //negitive results
std::cout<<a12;
std::cout<<a13;
//multiplication
//intiger
int a14 = 2;
int a15= 3 ;
int a16=a15*a14; //positive results
std::cout<<a16;
int a17= -a15;
int a18=a17*a14;
std::cout<<a18; //negitive results
// important
// if er devide an intiger with an intiger and the result is in decimal it will round off to the nearest digit
//double
double a19=1.00036456345364614663894363635365231351325132513315231231312231301;
double a20=2.0000000000000000000000000000000000002;
double a21=a20*a19; //positive results
std::cout<<a21;
double a22=-a19;
double a23= a21*a22;
std::cout<<a23;
//division
//here also we can not devide by 0
//we can devide by negitive number but the type must be same
double a24 = 10.03;
double a25 = -10.3;
double a26 = a24/a25;
std::cout<< a26 ;
//modulas %
//prints remainder
//avalable in both double and intiger form
int a27=10% 3;
std::cout<<a27;
//improved way of example
//incriment and decrement
//---------------------------------------------------------------------------------------------
//increment
// if we write ++ in front of a variable with a value then the value willbe increased by 1
int a28 = -2;
int a29 = a28++; //a28 will be -1 and a29 will be -2
int a32 = ++a28; // a32 = -1
std::cout<<a32;
std::cout<<a28;
//decreament
// if we write -- in front of an varible with an assighned value the the value will be decreased by 1
int a30 = 0 ;
int a31 = a30--; // a30 will be -1 and a31 will be 0
int a33 = --a30;
std::cout<<a33; // a33 = -1
std::cout<<a30;
//order of mathematical operators
//-----------------------------------------------------------------------------------------------------
//it will follow simple BODMAS rule
// for example
int x=10;
int y=5;
int z=(x+10)/(3*y);
std::cout<<z;
//using namespace and endl
using namespace std;
int x = 10 ;
int y = 20 ;
cout << "x=" << x << endl //this will print x = 10 and y=20 in two different lines
<<"y=" << y ;
return 0 ;
}
Top comments (0)