header files and operators(syntax)
#include<iostream>
// iostream is a system header file which inhance the functionality of program
// there are two types of header files
// 1. system header files: it comes with the compiler
// 2. user defined header file: it is written by the prgrammer
#include "this.h" //this is user defined header file
//#include "this.h"-->> this will produce an error if this.h is not present in the current directory
//we can also use endl for jumping into another line but it should be red by the compiler
using namespace std;
int main(){
cout<<"operators in c++"<<endl;
cout<<"following are the operators in c++"<<endl;
//arithematic operators
int a=5;
int b=7;
cout<<"the value of a+b is "<<a+b<<endl;
cout<<"the value of a-b is "<<a-b<<endl;
cout<<"the value of a*b is "<<a*b<<endl;
cout<<"the value of a/b is "<<a/b<<endl; //it's like gif. 2 integer ke bich arithematic operation ka output integer hi hoga
cout<<"the value of a%b is "<<a%b<<endl;//modulus operator gives the remainder here the remainder is 5 bcoz 7 divides 5 zero times
cout<<"the value of a++ is "<<a++<<endl;//a print krke a mein 1 jod do(output a hi ayega)
cout<<"the value of a-- is "<<a--<<endl;//(here the value of a is 6) ab 6 print hoga and uske 1 minus hoga
cout<<"the value of ++a is "<<++a<<endl;//pehle 1 add kro then print kro
cout<<"the value of --a is "<<--a<<endl;//pehle 1 subtract krna then print krna
cout<<endl;
//to create multicursor alt+shift+cursor
//assignment operators-->used to assign value to variables
// int a=5, b=7;
// char s='s';
//comparison operators
cout<<"following are the comparison operators in c++ "<<endl;
cout<<"the value of a==b is "<<(a==b)<<endl;
cout<<"the value of a!=b is "<<(a!=b)<<endl;
cout<<"the value of a>=b is "<<(a>=b)<<endl;
cout<<"the value of a<=b is "<<(a<=b)<<endl;
cout<<"the value of a>b is "<<(a>b)<<endl;
cout<<"the value of a<b is "<<(a<b)<<endl;
cout<<endl;
//logical operator (mathematical reasoning)}
cout<<"following are the logical operators in c++ "<<endl;
cout<<"the value of ((a==b) && (a<b) is "<<((a==b) && (a<b))<<endl; //and operator(intersection)
cout<<"the value of ((a==b) || (a<b) is "<<((a==b) || (a<b))<<endl; //or operator(union)
cout<<"the value of (!(a==b)) is "<<(!(a==b))<<endl; //not operator
return 0;
}
Comments
Post a Comment