-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINTRO_1.cpp
159 lines (142 loc) · 3.55 KB
/
INTRO_1.cpp
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
1)KEYWORDS:-for while true false if else\
2)VARIABLES:- user defined x=5
3)FUNCTIONS:-sequence of instructions to perfrom a certain task c=max(a,b), printf()
4)FUNCTION ORIENTED PROGRAMMING:- Used for small programming lang. a fucntion calls another function and another fucntion
5)OBJECT ORIENTED PROGRAMMING:-
6)Staistically typed:-c++& Java [int x; x=5;] faster
7)Dynamically typed:-python [x=5] slower
8) Header files:- #include<iostream>
---------------------------------------------------------------
--->>FIRST C++ PROGRAM<<----
<iostream> input output stream
cout-used to print in c++
#- used as PRE PROCESSOR DIRECTIVE
void main- doesn't returns value
----------------------------------------------------------------
PRIMITVE DATA TYPES:-
- Basic data types, fundamental data types
- INTEREGER- int, small(saves small space), large
- CHAR- char(-128->127), unassigned_char(doesn't store negative characters)
- FLOAT- float(32bits), double(higher precission), long double
- OTHER- BOOL(T/F,0/1) ,VOID()
NON-PRIMITIVE DATA TYPES:-
- Dervied from primitve data types
- ARRAY, POINTERS, user defined(class,struct),vector,string
----------------------------------------------------------------
SIZE OF OPERATOR:-
- No of elments in array
-cout<<sizeof(x)<<"\n";
cout<<sizeof(d)<<"\n";
cout<<sizeof(char)<<"\n";
-----------------------------------------------------------------
I/P & O/P
- I/P- Buffer- Process- buffer- O/P
- DIFFERENT STREAMS(classes):-
-istream:- I/P stream
-cin<<
-ifstream:-I/P from file stream
-ostream:- O/P stream
-cout<<
-ofstream:-O/P from file stream
-cerr:- for error
-clog:- for logging data
#include<iostream>
using namespace std;
int main(){
int x;
double d;
cout<<x;
return 0;
}
//INPUT IN C++
#include<iostream>
using namespace std;
int main()
{
string name;
cout<<"enter you name";
cin>>name;
cout<<"Hi"<<name<<",\n";
cout<<"Welcome to my c++ train";
return 0;
}
//ADDS X & Y
#include<iostream>
using namespace std;
int main()
{
int x,y;
cout<<"enter:";
cin>>x>>y;
cout<<x+y;
return 0;
}
//GETLINE
#include<iostream>
using namespace std;
int main(){
string name;
cout<<"enter your name \n";
getline(cin,name); //uses getline to include all inputs after space in input
cout<<("Welcome ")<<name;
return 0;
}
///BUFFERING IN C++ (reduces calculation speed)
#include <iostream>
using namespace std;
int main(){
int x,y;
cout<<"Enter first number\n";
cin>>x;
cout<<"Enter Second Number\n";
cin>>y;
cout<<"Multplied numbers are "<<( x*y );
return 0;
}
//ESCAPE SEQUENCE FOR DOUBLE INVERTED AND DOUBLE SLASH
#include <iostream>
using namespace std;
int main(){
string name, location;
name="\"geekforgeekss\"\n";
location="C:\\aadithlasar\\documents";
cout<<name;
cout<<location;
return 0;
}
//IO Manipulation\:
#include <iostream>
#include<iomanip>
using namespace std;
int main(){
int a;
cin>>a;
//cout<<uppercase;
//cout<<hex;//converts int to hex
//cout<<oct; int to oct
//cout<<showbase; adds prefix
//bool a = true; converts bool value from numeric to var
//cout<<boolalpha;
//cout<<noboolalpha;
cout<<left;
cout<<setw(5);
cout<<setfill('-');
cout<<a;
return 0;
}
//FLOATING POINT FIXED AND SCIENTIFIC FORMAT
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
double x,y;
cin>>x;
cin>>y;
cout<<fixed; //FIXED FORMAT NIL MANUPLATION
cout<<scientific; //SCIENTIFIC FORMAT MANIPULATION
cout<<uppercase; //UPPERCASE E IN SCIENTIFIC
cout<<showpoint; //SHOWS DECIMAL POINTS
cout<<showpos; // SHOWS POSITIVE SIGN
}
*/