-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoursesection.php
More file actions
1552 lines (1511 loc) · 52.8 KB
/
coursesection.php
File metadata and controls
1552 lines (1511 loc) · 52.8 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style type="text/css">
@import url('https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
text-decoration: none;
font-family: sans-serif;
}
body{
background-color: #f3f5f9;
}
.wrapper{
position: relative;
margin: 10px;
}
.wrapper .sidebar{
width: auto;
height: auto;
margin-top: 1px;
padding: 30px 0px;
position: absolute;
background-color: white;
}
.c2{
padding: 15px;
border-bottom: 1px solid #bdb8d7;
border-bottom: 1px solid rgba(0,0,0,0.05);
border-top: 1px solid rgba(255,255,255,0.05);
list-style: none;
}
.c1{
color: black;
display: block;
}
.c2:hover{
background-color: lightgrey;
}
.wrapper .sidebar ul li:hover a{
color: #fff;
}
.wrapper .Content
{
float: right;
width:1180px;
min-height: 720px;
height:auto;
background-color:white;
margin-right:60px;
margin-top: 1px;
}
.y
{
text-align: center;
margin-top: 20px;
}
.basics
{
padding:10px;
display: block;
}
.basics p,h3{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.syntax,.data,.variables,.operator,.decision,.storage,.funt{
display: none;
}
.syntax p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.data p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.variables p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.operator p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.storage p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
}
.decision p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.storage p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.funt p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.z
{
width: 100%;
padding-top: 20px;
height: 80px;
outline: none;
top: 0;
background-color: white;
}
.left
{
float: left;
width: 140px;
margin-left: 10px;
}
.g
{
float: right;
margin-right: 60px;
margin-bottom: 25px;
margin-top: -8px;
}
.x71
{
background-color:rgb(153, 204, 255);
color: white;
padding: 8px 18px;
margin: 8px 0;
border: none;
cursor: pointer;
width: auto;
border-radius: 2px;
}
.x71:hover
{
opacity: 0.8;
}
.course{
cursor: pointer;
width: 40px;
height: 40px;
position: relative;
display: inline-block;
margin-left: 240px;
height: auto;
margin-top:-2px;
}
.course i{
font-size: 40px;
}
.dd-content{
display: none;
position: absolute;
padding: 10px 20px;
background-color: white;
width: 200px;
box-shadow: 2px 2px 4px rgba(0,0,0,0.125);
box-sizing: 0 5px 25px rgba(0,0,0,0.1);
transition: 0.5s;
z-index: 1;
}
.course ul li{
list-style: none;
padding: 10px 0;
border-bottom: 1px solid rgba(0,0,0,0.01);
display: flex;
align-items: center;
}
.course ul li i{
max-width: 20px;
margin-right: 10px;
opacity: 0.5s;
transition: 0.5s;
}
.course ul li:hover i{
opacity: 1;
}
.course ul li a{
display: inline-block;
text-decoration: none;
color: #555;
font-weight: 500;
transition: 0.5s;
}
.course ul li:hover a{
color: #ff5d94;
}
.show {display: block;}
.dropdown{
float: right;
cursor: pointer;
width: 40px;
height: 40px;
position: relative;
display: inline-block;
margin-right: 240px;
height: auto;
}
.dropdown i{
font-size: 40px;
}
.dropdown-content {
display: none;
position: absolute;
top: 50px;
padding: 10px 20px;
background-color: lightgrey;
width: 200px;
box-sizing: 0 5px 25px rgba(0,0,0,0.1);
transition: 0.5s;
z-index: 1;
border-radius:15px;
}
.dropdown .dropdown-content::before{
content: '';
position: absolute;
top: -5px;
right: 160px;
width: 20px;
height: 20px;
transform: rotate(45deg);
background-color: lightgrey;
}
.dropdown ul li{
list-style: none;
padding: 10px 0;
border-top: 1px solid rgba(0,0,0,0.1);
display: flex;
align-items: center;
}
.dropdown ul li i{
max-width: 20px;
margin-right: 10px;
opacity: 0.5s;
transition: 0.5s;
}
.dropdown ul li:hover i{
opacity: 1;
}
.dropdown ul li a{
display: inline-block;
text-decoration: none;
color: #555;
font-weight: 500;
transition: 0.5s;
}
.dropdown ul li:hover a{
color: #ff5d94;
}
.show {display: block;}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
padding-top: 60px;
}
.modal-content {
background-color: #fefefe;
margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
border: 1px solid #888;
width: 30%;
height:auto; /* Could be more or less, depending on screen size */
}
.container {
padding: 16px;
}
span.psw {
float: right;
padding-top: 16px;
}
.r1,.r2
{
width:100%;
padding:10px 15px;
margin:5px 0px;
border: 1px solid lightgrey;
outline: none;
border-radius: 2px;
font-size: 17px;
}
::placeholder
{
text-align: center;
}
/* The Close Button (x) */
.close {
position: absolute;
right: 30px;
top: 0;
color: #000;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: red;
cursor: pointer;
}
.submit-btn
{
background-color:#4CAF50;
color: white;
width: 100%;
padding: 10px 30px;
display: block;
outline: none;
margin:auto;
border:none;
cursor: pointer;
font-size: 20px;
}
a
{
text-decoration: none;
}
.slide-controls
{
width:100%;
margin: 35px auto;
position: relative;
box-shadow: 0 0 20px 9px #ff61241f;
}
.toggle-btn
{
text-align: center;
padding: 10px 45px;
cursor: pointer;
background: transparent;
border:0;
outline: none;
position: relative;
font-size: 20px;
}
#btn
{
text-align: center;
position: absolute;
width:50%;
height: 100%;
background: linear-gradient(to right,lightgrey,lightgrey);
transition: .5s;
}
.v
{
text-align: center;
color: white;
padding-top: 200px;
font-size: 45px;
}
.footer
{
padding:50px;
color: #fff;
background-color: #011c39;
}
#login
{
left: 50%;
}
.footer p{
text-align: center;
}
.footer a{
text-decoration: none;
}
.footer-bottom{
text-align: center;
color: #999;
margin-bottom:-30px;
}
.socials a{
background: #364a62;
width: 40px;
height: 40px;
display: inline-block;
}
.socials a i{
color: #e7f2f4;
padding: 10px 12px;
font-size: 20px;
}
.imgcontainer {
position: relative;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
@-webkit-keyframes animatezoom {
from {-webkit-transform: scale(0)}
to {-webkit-transform: scale(1)}
}
@keyframes animatezoom {
from {transform: scale(0)}
to {transform: scale(1)}
}
/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
img.avatar {
width: 40%;
border-radius: 50%;
}
</style>
<body>
<div class="z">
<div class="left">
<a href="newproject.php"><img src="https://www.simplilearn.com/ice9/new_logo.svgz" style="width: 140px;margin-left: 10px;cursor: pointer;"></a>
</div>
<div class="course">
<input type="button" onclick="mycourse()" class="x71" value="Courses" name="">
<ul id='myDrop' class='dd-content'>
<li><a href='coursesection.php'>C++</a></li>
<li><a href='javacoursepage.php'>Java</a></li>
<li><a href='sql.php' >Sql</a></li>
<li><a href='phpcourse.php' >Php</a></li>
<li><a href='PythonCourseNew.php' >Python</a></li>
</ul>
</div>
<?php if(!isset($_SESSION['name']))
echo " <div class='g' id='first'>
<button class='x71' onclick='loginform()' style='width:auto;' type='submit'>Login</button>
</div> " ?>
<?php if(isset($_SESSION['name']))
echo " <div class='dropdown' id='third'>
<i onclick='myFunction()' class='fa fa-user-circle-o'></i>
<ul id='myDropdown' class='dropdown-content'>
<li><i class='fa fa-user' style='font-size:15px;'></i> <a href='profilepage.php'>my profile</a></li>
<li><i class='fa fa-edit' style='font-size:15px;'></i> <a href='editprofile.php'>Edit profile</a></li>
<li><i class='fa fa-sign-out' style='font-size:15px;'></i> <a href='newlogout.php' id='second' >Logout</a></li>
</ul>
</div>";?>
</div>
<div id="id01" class="modal">
<div class="modal-content animate">
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
</div>
<div class="wrapper1" style="width:70%;height:70%;margin-left: 60px;padding: 30px;border-radius:5px;overflow: hidden;">
<div class="title-text" style="display: flex;width: 200%">
<div class="title login" style="width: 50%;font-size:35px;font-weight: 600;text-align: center">Login Form</div>
</div>
<div class="form-container" style="width: 100%;overflow: hidden;">
<div class="form-inner" style="display: flex;width: 200%;">
<form action="newlogin.php" method="post" class="login" id="login" style="width:50%;">
<div style="height: 50px;width: 90%;margin-top: 20px;padding-top: 2px;padding-bottom: 2px;">
<input type="text" class="r1" placeholder="username or email" name="name" required="">
</div>
<div style="height: 50px;width: 90%;margin-top: 20px;">
<input type="password" class="r2" placeholder="Password" name="password" required="">
</div><br><br>
<div class="pass-link">
<a href="#">Forgot password?</a><br><br>
</div>
<div>
<input type="submit" class="submit-btn" value="Login" onclick="account()">
</div><br>
<div class="signup-link">Not a member? <a href="http://localhost/signup.php">Signup now</a></div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="wrapper">
<div class="sidebar">
<ul>
<li class="c2"><a href="#" class="c1" onclick="basics()">C++ Programming Language</a></li>
<li class="c2"><a href="#" class="c1" onclick="syntax()">Basic Concepts of c++</a></li>
<li class="c2"><a href="#" class="c1" onclick="datatype()">Datatypes and Modifiers in C++ </a></li>
<li class="c2"><a href="#" class="c1" onclick="variables()">Variables</a></li>
<li class="c2"><a href="#" class="c1" onclick="operator()">Operators</a></li>
<li class="c2"><a href="#" class="c1" onclick="decision()">Decision making</a></li>
<li class="c2"><a href="#" class="c1" onclick="storage()">Storage classes</a></li>
<li class="c2"><a href="#" class="c1" onclick="fun()">functions</a></li>
<li class="c2"><a class="c1" href="https://docs.google.com/forms/d/e/1FAIpQLSdeCKdMZJEFeGeukLTPiE1wCP_UX-WA-QQrcYaEgjH6xDUWgg/viewform?usp=sf_link" target="_blank">Quiz-c++</a></li>
</ul>
</div>
<div class="Content" style="font-family: sans-serif;">
<div class="basics" id="v">
<h1 class="y">Introduction to C++ </h1>
<img src="https://www.geeksforgeeks.org/wp-content/uploads/titleShadow-768x256.png" style="margin-left: 190px;margin-top:40px;">
<p>C++, as we all know is an extension to C language and was developed by Bjarne
stroustrup at bell labs. C++ is an intermediate level language, as it comprises a
confirmation of both high level and low level language features. C++ is a
statically typed, free form, multiparadigm, compiled general-purpose language. </p>
<p>C++ is an Object Oriented Programming language but is not purely Object
Oriented. Its features like Friend and Virtual, violate some of the very
important OOPS features, rendering this language unworthy of being called
completely Object Oriented. Its a middle level language.
</p>
<h3>Benefits of C++ over C Language </h3>
<p>The major difference being OOPS concept, C++ is an object oriented language
whereas C language is a procedural language. Apart form this there are many
other features of C++ which gives this language an upper hand on C laguage. </p>
<p>
Following features of C++ makes it a stronger language than C,
</p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;" >There is Stronger Type Checking in C++. </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">All the OOPS features in C++ like Abstraction, Encapsulation, Inheritance
etc makes it more worthy and useful for programmers.</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">C++ supports and allows user defined operators (i.e Operator
Overloading) and function overloading is also supported in it. </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Exception Handling is there in C++.
</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">The Concept of Virtual functions and also Constructors and Destructors for Objects.</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;"> Inline Functions in C++ instead of Macros in C language. Inline functions
make complete function body act like Macro, safely. </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Variables can be declared anywhere in the program in C++, but must be
declared before they are used. </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">C++ is a compiled language, contributing to its speed.</li>
</ul>
</div>
<div class="syntax" id="syn">
<h1 class="y">Basic Concepts of C++ </h1>
<p>In this section we will cover the basics of C++, it will include the syntax, variable,
operators, loop types, pointers, references and information about other
requirements of a C++ program. You will come across lot of terms that you have
already studied in C language. </p>
<h2>Syntax and Structure of C++ program</h2>
<p>Here we will discuss one simple and basic C++ program to print "Hello this is
C++" and its structure in parts with details and uses. </p>
<h2>First C++ program </h2>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
#include < iostream><br><br>
using namespace std;<br><br>
// main() is where program execution begins.<br><br>
int main()<br>
{<br><br>
cout << "Hello World"; // prints Hello World<br><br>
return 0;<br><br>
}
</div><br>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Header files are included at the beginning
just like in C program.
Here iostream is a header file which provides us with input & output streams.
Header files contained predeclared function libraries, which can be used by
users for their ease
</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Using namespace std, tells the compiler to use standard namespace.
Namespace collects identifiers used for class, object and variables. NameSpace
can be used by two ways in a program, either by the use of using statement at
the beginning, like we did in above mentioned program or by using name of
namespace as prefix before the identifier with scope resolution (::) operator.<br>
Example: std::cout << "A";
</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">main(), is the function which holds the executing part of program its return type
is int. </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">cout <<, is used to print anything on screen, same as printf in C
language. cin and cout are same as scanf and printf, only difference is that
you do not need to mention format specifiers like, %d for int etc, in cout & cin. </li>
</ul>
<h2>Comments in C++ Program </h2>
<p>For single line comments, use // before mentioning comment, like </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
cout<<"single line"; // This is single line comment
</div>
<p>For multiple line comment, enclose the comment between /* and */</p>
<div style="background-color: lightgrey;margin-left: 400px;width:200px;padding: 15px;">
/*this is<br>
a multiple line<br>
comment */<br>
</div>
<h2>Creating Classes in C++ </h2>
<p>Classes name must start with capital letter, and they contain data variables and
member functions. This is a mere introduction to classes, we will discuss classes
in detail throughout the C++ tutorial. </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
class Abc<br>
{<br><br>
int i; //data variable<br><br>
void display() //Member Function<br><br>
{<br><br>
cout << "Inside Member Function";<br><br>
}<br><br>
}; // Class ends here<br><br>
int main()<br><br>
{<br><br>
Abc obj; // Creatig Abc class's object<br><br>
obj.display(); //Calling member function using class object<br><br>
}<br>
</div>
<p style="color:#696969; ">This is how a class is defined, once a class is defined, then its object is created
and the member functions are used.
Variables can be declared anywhere in the entire program, but must be
declared, before they are used. Hence, we don't need to declare variable at the
start of the program.
Don't worry this is just to give you a basic idea about C++ language, we will
cover everything in details in next tutorials </p>
</div>
<div class="data" id="dtype">
<h1 class="y">Datatypes and Modifiers in C++</h1>
<p>Let's start with Datatypes. They are used to define type of variables and
contents used. Data types define the way you use storage in the programs you
write. Data types can be of two types:<br><br>
1. Built-in Datatypes<br><br>
2. User-defined or Abstract Datatypes<br>
</p>
<h2>Built-in Data Types </h2>
<p>These are the datatypes which are predefined and are wired directly into the
compiler. <br><br>For eg: int, char etc.
</p>
<h2>User defined or Abstract data types</h2>
<p>
These are the type, that user creates as a class or a structure. In C++ these are
classes where as in C language user-defined datatypes were implemented as
structures.
</p>
<h2>Basic Built in Datatypes in C++ </h2>
<table style="width:50%;margin-left: 200px;">
<tr>
<th>Datatype</th>
<th>Bytes</th>
</tr>
<tr>
<td>char</td>
<td>for character storage (1 byte) </td>
</tr>
<tr>
<td>int</td>
<td>for integral number (2 bytes) </td>
</tr>
<tr>
<td>float</td>
<td>single precision floating point (4 bytes) </td>
</tr>
<tr>
<td>double</td>
<td>double precision floating point numbers (8 bytes) </td>
</tr>
</table><br><br>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
char a = 'A'; // character type<br><br>
int a = 1; // integer type<br><br>
float a = 3.14159; // floating point type<br><br>
double a = 6e-4; // double type (e is for exponential)<br>
</div>
<h2>Other Built in Datatypes in C++ </h2>
<table style="width:50%;margin-left: 200px;">
<tr>
<th>Datatype</th>
<th>Bytes</th>
</tr>
<tr>
<td>bool</td>
<td>Boolean (True or False)</td>
</tr>
<tr>
<td>void</td>
<td>Without any Value </td>
</tr>
<tr>
<td>wchar_t</td>
<td>Wide Character </td>
</tr>
</table><br><br>
<h2>Enum as Datatype in C++ </h2>
<p>Enumerated type declares a new type-name along with a sequence of values
containing identifiers which has values starting from 0 and incrementing by 1
every time. </p>
<p>For Example: </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
enum day(mon, tues, wed, thurs, fri) d;
</div>
<p>Here an enumeration of days is defined which is represented by the
variable d. mon will hold value 0, tue will have 1 and so on. We can also explicitly
assign values, like, enum day(mon, tue=7, wed);. Here, mon will be 0, tue will
be assigned 7, so wed will get value 8.</p>
<h2>Modifiers in C++ </h2>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">long</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">short</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">signed</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">unsigned</li>
</ul>
<p>The above mentioned modifiers can be used along with built in datatypes to
make them more precise and even expand their range.<br><br>
Below mentioned are some important points you must know about the
modifiers, </p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">long and short modify the maximum and minimum values that a data
type will hold.</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">A plain int must have a minimum size of short. </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Size hierarchy : short int < int < long int</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Size hierarchy for floating point numbers is : float < double < long
double
</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">long float is not a legal type and there are no short floating
point numbers.</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Signed types includes both positive and negative numbers and is the
default type</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Unsigned, numbers are always without any sign, that is always positive</li>
</ul>
</div>
<div class="variables" id="variable">
<h1 class="y">Variables</h1>
<p>Variable are used in C++, where we need storage for any value, which will
change in program. Variable can be declared in multiple ways each with
different memory requirements and functioning. Variable is the name of
memory location allocated by the compiler depending upon the datatype of the
variable. </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
Example: int i = 10;
</div>
<h2>Basic types of Variables </h2>
<p>Each variable while declaration must be given a datatype, on which the memory
assigned to the variable depends. Following are the basic types of variables,</p>
<table style="width:50%;margin-left: 200px;">
<tr>
<th>Datatype</th>
<th>description</th>
</tr>
<tr>
<td>bool</td>
<td>For variable to store boolean values( True or False ) </td>
</tr>
<tr>
<td>char</td>
<td>For variables to store character types.
</td>
</tr>
<tr>
<td>int</td>
<td>for variable with integral values</td>
</tr>
<tr>
<td>float and double</td>
<td> for variables with large and floating point values </td>
</tr>
</table><br><br>
<h2>Declaration and Initialization</h2>
<p>Variable must be declared before they are used. Usually it is preferred to
declare them at the starting of the program, but in C++ they can be declared in
the middle of program too, but must be done before using them.<br><br>
For example:</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
int i; // declared but not initialised<br><br>
char c;<br><br>
int i, j, k; // Multiple declaration<br><br>
</div>
<p>Initialization means assigning value to an already declared variable,</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
int i; // declaration<br><br>
i = 10; // initialization<br><br>
</div>
<p>Initialization and declaration can be done in one single step also,</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
int i=10; //initialization and declaration in same step<br><br>
int i=10, j=11; <br><br>
</div>
<p>If a variable is declared and not initialized by default it will hold a garbage value.
Also, if a variable is once declared and if try to declare it again, we will get a
compile time error.</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
int i,j;<br><br>
i=10;<br><br>
j=20;<br><br>
int j=i+j; //compile time error, cannot redeclare a variable in same
scope<br><br>
</div>
<h2>Scope of Variables </h2>
<p>All the variables have their area of functioning, and out of that boundary they
don't hold their value, this boundary is called scope of the variable. For most of
the cases its between the curly braces,in which variable is declared that a
variable exists, not outside it. We will study the storage classes later, but as of
now, we can broadly divide variables into two main types,</p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Global Variables</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Loacal Variables</li>
</ul>
<h2>Global variables </h2>
<p>Global variables are those, which ar once declared and can be used throughout
the lifetime of the program by any class or any function. They must be declared
outside the main() function. If only declared, they can be assigned different
values at different time in program lifetime. But even if they are declared and
initialized at the same time outside the main() function, then also they can be
assigned any value at any point in the program.<br><br>
For example: Only declared, not initialized </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
#include < iostream><br><br>
using namespace std;<br><br>
int x; // Global variable declared<br><br>
int main()<br><br>
{<br><br>
x=10; // Initialized once<br><br>
cout <<"first value of x = "<< x;<br><br>
x=20; // Initialized again<br><br>
cout <<"Initialized again with value = "<< x;<br><br>
}
</div>
<h2>Local variables </h2>
<p>Local variables are the variables which exist only between the curly braces, in
which its declared. Outside that they are unavailable and leads to compile time
error.<br><br>
For example: Only declared, not initialized </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
#include < iostream><br><br>
using namespace std;<br><br>
int main()<br><br>
{ <br><br>
int i=10;<br><br>
if(i<20) // if condition scope starts<br><br>
{<br><br>
int n=100; // Local variable declared and initialized<br><br>
} // if condition scope ends<br><br>
cout << n; // Compile time error, n not available here<br><br>
}<br><br>
</div>
<h2>Some special types of variable </h2>
<p>There are also some special keywords, to impart unique characteristics to the
variables in the program. Following two are mostly used, we will discuss them
in details later.<br><br>
1. Final - Once initialized, its value cant be changed.<br><br>
2. Static - These variables holds their value between function calls.<br><br>Example : <br><br></p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
#include < iostream.h><br><br>
using namespace std;<br><br>
int main()<br><br>
{<br><br>
final int i=10;<br><br>
static int y=20;<br><br>
}<br><br>
</div>
</div>
<div class="operator" id="op">
<h1 class="y">Operators in C++</h1>
<p>Operators are special type of functions, that takes one or more arguments and
produces a new value. For example : addition (+), substraction (-), multiplication
(*) etc, are all operators. Operators are used to perform various operations on
variables and constants. </p>
<h2>Types of operators</h2>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Assignment Operator </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Mathematical Operators </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Relational Operators </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Logical Operators</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Bitwise Operators </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Shift Operators</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Unary Operators</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Ternary Operator </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Comma Operator</li>
</ul>
<h2>Assignment Operator (=) </h2>
<p>Operates '=' is used for assignment, it takes the right-hand side (called rvalue)
and copy it into the left-hand side (called lvalue). Assignment operator is the
only operator which can be overloaded but cannot be inherited. </p>
<h2>Mathematical Operators </h2>
<p>
There are operators used to perform basic mathematical operations. Addition
(+) , subtraction (-) , diversion (/) multiplication (*) and modulus (%) are the basic
mathematical operators. Modulus operator cannot be used with floating-point
numbers.<br><br>
C++ and C also use a shorthand notation to perform an operation and
assignment at same type. Example,
</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
int x=10;<br><br>
x += 4 // will add 4 to 10, and hence assign 14 to X.<br><br>
x -= 5 // will subtract 5 from 10 and assign 5 to x.<br><br>
</div>
<h2>Relational Operators </h2>
<p>
These operators establish a relationship between operands. The relational
operators are : less than (<) , grater thatn (>) , less than or equal to (<=), greater
than equal to (>=), equivalent (==) and not equivalent (!=).<br><br>
You must notice that assignment operator is (=) and there is a relational
operator, for equivalent (==). These two are different from each other, the
assignment operator assigns the value to any variable, whereas equivalent
operator is used to compare values, like in if-else conditions, Example
</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
int x = 10; //assignment operator<br><br>
x=5; // again assignment operator<br><br>
if(x == 5) // here we have used equivalent relational operator, for
comparison<br><br>
{<br><br>
cout <<"Successfully compared";<br><br>
}<br><br>
</div>
<h2>Logical Operators</h2>
<p>
The logical operators are AND (&&) and OR (||). They are used to combine two
different expressions together.<br><br>
If two statement are connected using AND operator, the validity of both
statements will be considered, but if they are connected using OR operator,
then either one of them must be valid. These operators are mostly used in
loops (especially while loop) and in Decision making.
</p>
<h2>Bitwise Operators</h2>
<p>
There are used to change individual bits into a number. They work with only
integral data types like char, int and long and not with floating point values.</p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Bitwise AND operators &</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Bitwise OR operator |</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">And bitwise XOR operator ^
</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">And, bitwise NOT operator ~</li>
</ul>
<p>They can be used as shorthand notation too, & = , |= , ^= , ~= etc</p>
<h2>Shift Operators </h2>
<p>
Shift Operators are used to shift Bits of any variable. It is of three types, </p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Left Shift Operator <<</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;"> Right Shift Operator >></li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Unsigned Right Shift Operator >>>
</li>
</ul>
<h2>Unary Operators </h2>
<p>
These are the operators which work on only one operand. There are many
unary operators, but increment ++ and decrement -- operators are most used.<br><br>
Other Unary Operators : address of &, dereference *, new and delete, bitwise
not ~, logical not !, unary minus - and unary plus +. </p>
<h2>Ternary Operator </h2>
<p>
The ternary if-else ? : is an operator which has three operands. </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
int a = 10;<br><br>
a > 5 ? cout << "true" : cout << "false"<br><br>
</div>
<h2>Comma Operator</h2>
<p>
This is used to separate variable names and to separate expressions. In case of
expressions, the value of last expression is produced and used.
</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
int a,b,c; // variables declaration using comma operator<br><br>
a=b++, c++; // a = c++ will be done.<br><br>
</div>