-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut6.cpp
More file actions
38 lines (35 loc) · 1.69 KB
/
tut6.cpp
File metadata and controls
38 lines (35 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// there are two types of header files:
// 1.system header files:it comes with the COMPILER
// 2.user defined header files:it is written by the programmer
#include<iostream>
#include "this.h"
using namespace std;
int main(){
cout<<"this is a hello world program"<<endl;/* endl is used to create new line when you can't use \n*/
int a=4,b=5;
cout<<"\nthe value of a+b is: "<<a+b;
cout<<"\nthe value of a-b is: "<<a-b;
cout<<"\nthe value of a*b is: "<<a*b;
cout<<"\nthe value of a/b is: "<<a/b;
cout<<"\nthe value of a%b is: "<<a%b;
cout<<"\nthe value of a++ is: "<<a++;/*this changes a=4 to a=5 but prints the before value of a*/
cout<<"\nthe value of a-- is: "<<a--;/*this changes a=5 to a=4 but prints the before value of a*/
cout<<"\nthe value of ++a is: "<<++a;/*this changes a=4 to a=5 but prints the after value of a*/
cout<<"\nthe value of --a is: "<<--a;/*this changes a=5 to a=4 but prints the after value of a*/
// output of any operation on integers in c++ is always an integer thus a/b=0
// Assignment operators:- used to assign valuse to variables
// e.g. int a=4,b=6;
// char d='c';
// comparison operator:
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 and a==b is"<<((a<b)&&(a==b));/*this && is logical operator 'and'*/
//similarly || is 'or',! is 'not'
}
/*
there are 2 types of header files:
1. System header files- It comes wth the compiler.
2. user defined header files: it is written by the programmmer*/