├── .gitignore
├── LICENSE
├── README.md
├── giris
└── derleyici_editor.md
├── giris_konular
├── degiskenler.md
├── giris_cikis.md
├── ilk_program.md
└── operatorler.md
├── orta_konular
├── diziler.md
├── fonksiyonlar.md
├── karakter_dizileri.md
├── kosullar_donguler.md
└── overloads_templates.md
└── Örnekler
├── arrays
├── array.cpp
└── multiarray.cpp
├── character_arrays
└── main.cpp
├── class
├── dikdortgen.cpp
├── dort_islem
│ ├── dort.cpp
│ ├── dort.h
│ └── main.cpp
├── header_files_example1
│ ├── Dog.cpp
│ ├── Dog.h
│ ├── Makefile
│ └── main.cpp
├── header_files_example2
│ ├── Makefile
│ ├── Person.cpp
│ ├── Person.h
│ └── main.cpp
└── ornek.cpp
├── dynamic_memory
└── main.cpp
├── functions
└── main.cpp
├── helloCpp
└── main.cpp
├── if-else
└── main.cpp
├── input_output
└── main.cpp
├── overloaded
└── main.cpp
├── pointers
├── call_by_referance.cpp
├── call_by_referance2.cpp
├── pointer1.cpp
└── pointer2.cpp
├── shapes
└── main.cpp
├── switch
└── main.cpp
├── templates
└── main.cpp
├── tuple
└── tuple.cpp
├── vector
├── a.out
├── vector1.cpp
├── vector2.cpp
└── vector3.cpp
└── while-for
└── main.cpp
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode/*
2 | !.vscode/settings.json
3 | !.vscode/tasks.json
4 | !.vscode/launch.json
5 | !.vscode/extensions.json
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation,
5 | Inc.
6 | Everyone is permitted to copy and distribute
7 | verbatim copies
8 | of this license document, but changing it is
9 | not allowed.
10 |
11 | Preamble
12 |
13 | The GNU General Public License is a free,
14 | copyleft license for
15 | software and other kinds of works.
16 |
17 | The licenses for most software and other
18 | practical works are designed
19 | to take away your freedom to share and change
20 | the works. By contrast,
21 | the GNU General Public License is intended to
22 | guarantee your freedom to
23 | share and change all versions of a program--to
24 | make sure it remains free
25 | software for all its users. We, the Free
26 | Software Foundation, use the
27 | GNU General Public License for most of our
28 | software; it applies also to
29 | any other work released this way by its
30 | authors. You can apply it to
31 | your programs, too.
32 |
33 | When we speak of free software, we are
34 | referring to freedom, not
35 | price. Our General Public Licenses are
36 | designed to make sure that you
37 | have the freedom to distribute copies of free
38 | software (and charge for
39 | them if you wish), that you receive source code
40 | or can get it if you
41 | want it, that you can change the software or
42 | use pieces of it in new
43 | free programs, and that you know you can do
44 | these things.
45 |
46 | To protect your rights, we need to prevent
47 | others from denying you
48 | these rights or asking you to surrender the
49 | rights. Therefore, you have
50 | certain responsibilities if you distribute
51 | copies of the software, or if
52 | you modify it: responsibilities to respect the
53 | freedom of others.
54 |
55 | For example, if you distribute copies of such
56 | a program, whether
57 | gratis or for a fee, you must pass on to the
58 | recipients the same
59 | freedoms that you received. You must make sure
60 | that they, too, receive
61 | or can get the source code. And you must show
62 | them these terms so they
63 | know their rights.
64 |
65 | Developers that use the GNU GPL protect your
66 | rights with two steps:
67 | (1) assert copyright on the software, and (2)
68 | offer you this License
69 | giving you legal permission to copy, distribute
70 | and/or modify it.
71 |
72 | For the developers' and authors' protection,
73 | the GPL clearly explains
74 | that there is no warranty for this free
75 | software. For both users' and
76 | authors' sake, the GPL requires that modified
77 | versions be marked as
78 | changed, so that their problems will not be
79 | attributed erroneously to
80 | authors of previous versions.
81 |
82 | Some devices are designed to deny users
83 | access to install or run
84 | modified versions of the software inside them,
85 | although the manufacturer
86 | can do so. This is fundamentally incompatible
87 | with the aim of
88 | protecting users' freedom to change the
89 | software. The systematic
90 | pattern of such abuse occurs in the area of
91 | products for individuals to
92 | use, which is precisely where it is most
93 | unacceptable. Therefore, we
94 | have designed this version of the GPL to
95 | prohibit the practice for those
96 | products. If such problems arise substantially
97 | in other domains, we
98 | stand ready to extend this provision to those
99 | domains in future versions
100 | of the GPL, as needed to protect the freedom of
101 | users.
102 |
103 | Finally, every program is threatened
104 | constantly by software patents.
105 | States should not allow patents to restrict
106 | development and use of
107 | software on general-purpose computers, but in
108 | those that do, we wish to
109 | avoid the special danger that patents applied
110 | to a free program could
111 | make it effectively proprietary. To prevent
112 | this, the GPL assures that
113 | patents cannot be used to render the program
114 | non-free.
115 |
116 | The precise terms and conditions for copying,
117 | distribution and
118 | modification follow.
119 |
120 | TERMS AND CONDITIONS
121 |
122 | 0. Definitions.
123 |
124 | "This License" refers to version 3 of the GNU
125 | General Public License.
126 |
127 | "Copyright" also means copyright-like laws
128 | that apply to other kinds of
129 | works, such as semiconductor masks.
130 |
131 | "The Program" refers to any copyrightable
132 | work licensed under this
133 | License. Each licensee is addressed as "you".
134 | "Licensees" and
135 | "recipients" may be individuals or
136 | organizations.
137 |
138 | To "modify" a work means to copy from or
139 | adapt all or part of the work
140 | in a fashion requiring copyright permission,
141 | other than the making of an
142 | exact copy. The resulting work is called a
143 | "modified version" of the
144 | earlier work or a work "based on" the earlier
145 | work.
146 |
147 | A "covered work" means either the unmodified
148 | Program or a work based
149 | on the Program.
150 |
151 | To "propagate" a work means to do anything
152 | with it that, without
153 | permission, would make you directly or
154 | secondarily liable for
155 | infringement under applicable copyright law,
156 | except executing it on a
157 | computer or modifying a private copy.
158 | Propagation includes copying,
159 | distribution (with or without modification),
160 | making available to the
161 | public, and in some countries other activities
162 | as well.
163 |
164 | To "convey" a work means any kind of
165 | propagation that enables other
166 | parties to make or receive copies. Mere
167 | interaction with a user through
168 | a computer network, with no transfer of a copy,
169 | is not conveying.
170 |
171 | An interactive user interface displays
172 | "Appropriate Legal Notices"
173 | to the extent that it includes a convenient and
174 | prominently visible
175 | feature that (1) displays an appropriate
176 | copyright notice, and (2)
177 | tells the user that there is no warranty for
178 | the work (except to the
179 | extent that warranties are provided), that
180 | licensees may convey the
181 | work under this License, and how to view a copy
182 | of this License. If
183 | the interface presents a list of user commands
184 | or options, such as a
185 | menu, a prominent item in the list meets this
186 | criterion.
187 |
188 | 1. Source Code.
189 |
190 | The "source code" for a work means the
191 | preferred form of the work
192 | for making modifications to it. "Object code"
193 | means any non-source
194 | form of a work.
195 |
196 | A "Standard Interface" means an interface
197 | that either is an official
198 | standard defined by a recognized standards
199 | body, or, in the case of
200 | interfaces specified for a particular
201 | programming language, one that
202 | is widely used among developers working in that
203 | language.
204 |
205 | The "System Libraries" of an executable work
206 | include anything, other
207 | than the work as a whole, that (a) is included
208 | in the normal form of
209 | packaging a Major Component, but which is not
210 | part of that Major
211 | Component, and (b) serves only to enable use of
212 | the work with that
213 | Major Component, or to implement a Standard
214 | Interface for which an
215 | implementation is available to the public in
216 | source code form. A
217 | "Major Component", in this context, means a
218 | major essential component
219 | (kernel, window system, and so on) of the
220 | specific operating system
221 | (if any) on which the executable work runs, or
222 | a compiler used to
223 | produce the work, or an object code interpreter
224 | used to run it.
225 |
226 | The "Corresponding Source" for a work in
227 | object code form means all
228 | the source code needed to generate, install,
229 | and (for an executable
230 | work) run the object code and to modify the
231 | work, including scripts to
232 | control those activities. However, it does not
233 | include the work's
234 | System Libraries, or general-purpose tools or
235 | generally available free
236 | programs which are used unmodified in
237 | performing those activities but
238 | which are not part of the work. For example,
239 | Corresponding Source
240 | includes interface definition files associated
241 | with source files for
242 | the work, and the source code for shared
243 | libraries and dynamically
244 | linked subprograms that the work is
245 | specifically designed to require,
246 | such as by intimate data communication or
247 | control flow between those
248 | subprograms and other parts of the work.
249 |
250 | The Corresponding Source need not include
251 | anything that users
252 | can regenerate automatically from other parts
253 | of the Corresponding
254 | Source.
255 |
256 | The Corresponding Source for a work in source
257 | code form is that
258 | same work.
259 |
260 | 2. Basic Permissions.
261 |
262 | All rights granted under this License are
263 | granted for the term of
264 | copyright on the Program, and are irrevocable
265 | provided the stated
266 | conditions are met. This License explicitly
267 | affirms your unlimited
268 | permission to run the unmodified Program. The
269 | output from running a
270 | covered work is covered by this License only if
271 | the output, given its
272 | content, constitutes a covered work. This
273 | License acknowledges your
274 | rights of fair use or other equivalent, as
275 | provided by copyright law.
276 |
277 | You may make, run and propagate covered works
278 | that you do not
279 | convey, without conditions so long as your
280 | license otherwise remains
281 | in force. You may convey covered works to
282 | others for the sole purpose
283 | of having them make modifications exclusively
284 | for you, or provide you
285 | with facilities for running those works,
286 | provided that you comply with
287 | the terms of this License in conveying all
288 | material for which you do
289 | not control copyright. Those thus making or
290 | running the covered works
291 | for you must do so exclusively on your behalf,
292 | under your direction
293 | and control, on terms that prohibit them from
294 | making any copies of
295 | your copyrighted material outside their
296 | relationship with you.
297 |
298 | Conveying under any other circumstances is
299 | permitted solely under
300 | the conditions stated below. Sublicensing is
301 | not allowed; section 10
302 | makes it unnecessary.
303 |
304 | 3. Protecting Users' Legal Rights From
305 | Anti-Circumvention Law.
306 |
307 | No covered work shall be deemed part of an
308 | effective technological
309 | measure under any applicable law fulfilling
310 | obligations under article
311 | 11 of the WIPO copyright treaty adopted on 20
312 | December 1996, or
313 | similar laws prohibiting or restricting
314 | circumvention of such
315 | measures.
316 |
317 | When you convey a covered work, you waive any
318 | legal power to forbid
319 | circumvention of technological measures to the
320 | extent such circumvention
321 | is effected by exercising rights under this
322 | License with respect to
323 | the covered work, and you disclaim any
324 | intention to limit operation or
325 | modification of the work as a means of
326 | enforcing, against the work's
327 | users, your or third parties' legal rights to
328 | forbid circumvention of
329 | technological measures.
330 |
331 | 4. Conveying Verbatim Copies.
332 |
333 | You may convey verbatim copies of the
334 | Program's source code as you
335 | receive it, in any medium, provided that you
336 | conspicuously and
337 | appropriately publish on each copy an
338 | appropriate copyright notice;
339 | keep intact all notices stating that this
340 | License and any
341 | non-permissive terms added in accord with
342 | section 7 apply to the code;
343 | keep intact all notices of the absence of any
344 | warranty; and give all
345 | recipients a copy of this License along with
346 | the Program.
347 |
348 | You may charge any price or no price for each
349 | copy that you convey,
350 | and you may offer support or warranty
351 | protection for a fee.
352 |
353 | 5. Conveying Modified Source Versions.
354 |
355 | You may convey a work based on the Program,
356 | or the modifications to
357 | produce it from the Program, in the form of
358 | source code under the
359 | terms of section 4, provided that you also meet
360 | all of these conditions:
361 |
362 | a) The work must carry prominent notices
363 | stating that you modified
364 | it, and giving a relevant date.
365 |
366 | b) The work must carry prominent notices
367 | stating that it is
368 | released under this License and any
369 | conditions added under section
370 | 7. This requirement modifies the
371 | requirement in section 4 to
372 | "keep intact all notices".
373 |
374 | c) You must license the entire work, as a
375 | whole, under this
376 | License to anyone who comes into possession
377 | of a copy. This
378 | License will therefore apply, along with
379 | any applicable section 7
380 | additional terms, to the whole of the work,
381 | and all its parts,
382 | regardless of how they are packaged. This
383 | License gives no
384 | permission to license the work in any other
385 | way, but it does not
386 | invalidate such permission if you have
387 | separately received it.
388 |
389 | d) If the work has interactive user
390 | interfaces, each must display
391 | Appropriate Legal Notices; however, if the
392 | Program has interactive
393 | interfaces that do not display Appropriate
394 | Legal Notices, your
395 | work need not make them do so.
396 |
397 | A compilation of a covered work with other
398 | separate and independent
399 | works, which are not by their nature extensions
400 | of the covered work,
401 | and which are not combined with it such as to
402 | form a larger program,
403 | in or on a volume of a storage or distribution
404 | medium, is called an
405 | "aggregate" if the compilation and its
406 | resulting copyright are not
407 | used to limit the access or legal rights of the
408 | compilation's users
409 | beyond what the individual works permit.
410 | Inclusion of a covered work
411 | in an aggregate does not cause this License to
412 | apply to the other
413 | parts of the aggregate.
414 |
415 | 6. Conveying Non-Source Forms.
416 |
417 | You may convey a covered work in object code
418 | form under the terms
419 | of sections 4 and 5, provided that you also
420 | convey the
421 | machine-readable Corresponding Source under the
422 | terms of this License,
423 | in one of these ways:
424 |
425 | a) Convey the object code in, or embodied
426 | in, a physical product
427 | (including a physical distribution medium),
428 | accompanied by the
429 | Corresponding Source fixed on a durable
430 | physical medium
431 | customarily used for software interchange.
432 |
433 | b) Convey the object code in, or embodied
434 | in, a physical product
435 | (including a physical distribution medium),
436 | accompanied by a
437 | written offer, valid for at least three
438 | years and valid for as
439 | long as you offer spare parts or customer
440 | support for that product
441 | model, to give anyone who possesses the
442 | object code either (1) a
443 | copy of the Corresponding Source for all
444 | the software in the
445 | product that is covered by this License, on
446 | a durable physical
447 | medium customarily used for software
448 | interchange, for a price no
449 | more than your reasonable cost of
450 | physically performing this
451 | conveying of source, or (2) access to copy
452 | the
453 | Corresponding Source from a network server
454 | at no charge.
455 |
456 | c) Convey individual copies of the object
457 | code with a copy of the
458 | written offer to provide the Corresponding
459 | Source. This
460 | alternative is allowed only occasionally
461 | and noncommercially, and
462 | only if you received the object code with
463 | such an offer, in accord
464 | with subsection 6b.
465 |
466 | d) Convey the object code by offering
467 | access from a designated
468 | place (gratis or for a charge), and offer
469 | equivalent access to the
470 | Corresponding Source in the same way
471 | through the same place at no
472 | further charge. You need not require
473 | recipients to copy the
474 | Corresponding Source along with the object
475 | code. If the place to
476 | copy the object code is a network server,
477 | the Corresponding Source
478 | may be on a different server (operated by
479 | you or a third party)
480 | that supports equivalent copying
481 | facilities, provided you maintain
482 | clear directions next to the object code
483 | saying where to find the
484 | Corresponding Source. Regardless of what
485 | server hosts the
486 | Corresponding Source, you remain obligated
487 | to ensure that it is
488 | available for as long as needed to satisfy
489 | these requirements.
490 |
491 | e) Convey the object code using
492 | peer-to-peer transmission, provided
493 | you inform other peers where the object
494 | code and Corresponding
495 | Source of the work are being offered to the
496 | general public at no
497 | charge under subsection 6d.
498 |
499 | A separable portion of the object code, whose
500 | source code is excluded
501 | from the Corresponding Source as a System
502 | Library, need not be
503 | included in conveying the object code work.
504 |
505 | A "User Product" is either (1) a "consumer
506 | product", which means any
507 | tangible personal property which is normally
508 | used for personal, family,
509 | or household purposes, or (2) anything designed
510 | or sold for incorporation
511 | into a dwelling. In determining whether a
512 | product is a consumer product,
513 | doubtful cases shall be resolved in favor of
514 | coverage. For a particular
515 | product received by a particular user,
516 | "normally used" refers to a
517 | typical or common use of that class of product,
518 | regardless of the status
519 | of the particular user or of the way in which
520 | the particular user
521 | actually uses, or expects or is expected to
522 | use, the product. A product
523 | is a consumer product regardless of whether the
524 | product has substantial
525 | commercial, industrial or non-consumer uses,
526 | unless such uses represent
527 | the only significant mode of use of the
528 | product.
529 |
530 | "Installation Information" for a User Product
531 | means any methods,
532 | procedures, authorization keys, or other
533 | information required to install
534 | and execute modified versions of a covered work
535 | in that User Product from
536 | a modified version of its Corresponding Source.
537 | The information must
538 | suffice to ensure that the continued
539 | functioning of the modified object
540 | code is in no case prevented or interfered with
541 | solely because
542 | modification has been made.
543 |
544 | If you convey an object code work under this
545 | section in, or with, or
546 | specifically for use in, a User Product, and
547 | the conveying occurs as
548 | part of a transaction in which the right of
549 | possession and use of the
550 | User Product is transferred to the recipient in
551 | perpetuity or for a
552 | fixed term (regardless of how the transaction
553 | is characterized), the
554 | Corresponding Source conveyed under this
555 | section must be accompanied
556 | by the Installation Information. But this
557 | requirement does not apply
558 | if neither you nor any third party retains the
559 | ability to install
560 | modified object code on the User Product (for
561 | example, the work has
562 | been installed in ROM).
563 |
564 | The requirement to provide Installation
565 | Information does not include a
566 | requirement to continue to provide support
567 | service, warranty, or updates
568 | for a work that has been modified or installed
569 | by the recipient, or for
570 | the User Product in which it has been modified
571 | or installed. Access to a
572 | network may be denied when the modification
573 | itself materially and
574 | adversely affects the operation of the network
575 | or violates the rules and
576 | protocols for communication across the network.
577 |
578 | Corresponding Source conveyed, and
579 | Installation Information provided,
580 | in accord with this section must be in a format
581 | that is publicly
582 | documented (and with an implementation
583 | available to the public in
584 | source code form), and must require no special
585 | password or key for
586 | unpacking, reading or copying.
587 |
588 | 7. Additional Terms.
589 |
590 | "Additional permissions" are terms that
591 | supplement the terms of this
592 | License by making exceptions from one or more
593 | of its conditions.
594 | Additional permissions that are applicable to
595 | the entire Program shall
596 | be treated as though they were included in this
597 | License, to the extent
598 | that they are valid under applicable law. If
599 | additional permissions
600 | apply only to part of the Program, that part
601 | may be used separately
602 | under those permissions, but the entire Program
603 | remains governed by
604 | this License without regard to the additional
605 | permissions.
606 |
607 | When you convey a copy of a covered work, you
608 | may at your option
609 | remove any additional permissions from that
610 | copy, or from any part of
611 | it. (Additional permissions may be written to
612 | require their own
613 | removal in certain cases when you modify the
614 | work.) You may place
615 | additional permissions on material, added by
616 | you to a covered work,
617 | for which you have or can give appropriate
618 | copyright permission.
619 |
620 | Notwithstanding any other provision of this
621 | License, for material you
622 | add to a covered work, you may (if authorized
623 | by the copyright holders of
624 | that material) supplement the terms of this
625 | License with terms:
626 |
627 | a) Disclaiming warranty or limiting
628 | liability differently from the
629 | terms of sections 15 and 16 of this
630 | License; or
631 |
632 | b) Requiring preservation of specified
633 | reasonable legal notices or
634 | author attributions in that material or in
635 | the Appropriate Legal
636 | Notices displayed by works containing it;
637 | or
638 |
639 | c) Prohibiting misrepresentation of the
640 | origin of that material, or
641 | requiring that modified versions of such
642 | material be marked in
643 | reasonable ways as different from the
644 | original version; or
645 |
646 | d) Limiting the use for publicity purposes
647 | of names of licensors or
648 | authors of the material; or
649 |
650 | e) Declining to grant rights under
651 | trademark law for use of some
652 | trade names, trademarks, or service marks;
653 | or
654 |
655 | f) Requiring indemnification of licensors
656 | and authors of that
657 | material by anyone who conveys the material
658 | (or modified versions of
659 | it) with contractual assumptions of
660 | liability to the recipient, for
661 | any liability that these contractual
662 | assumptions directly impose on
663 | those licensors and authors.
664 |
665 | All other non-permissive additional terms are
666 | considered "further
667 | restrictions" within the meaning of section 10.
668 | If the Program as you
669 | received it, or any part of it, contains a
670 | notice stating that it is
671 | governed by this License along with a term that
672 | is a further
673 | restriction, you may remove that term. If a
674 | license document contains
675 | a further restriction but permits relicensing
676 | or conveying under this
677 | License, you may add to a covered work material
678 | governed by the terms
679 | of that license document, provided that the
680 | further restriction does
681 | not survive such relicensing or conveying.
682 |
683 | If you add terms to a covered work in accord
684 | with this section, you
685 | must place, in the relevant source files, a
686 | statement of the
687 | additional terms that apply to those files, or
688 | a notice indicating
689 | where to find the applicable terms.
690 |
691 | Additional terms, permissive or
692 | non-permissive, may be stated in the
693 | form of a separately written license, or stated
694 | as exceptions;
695 | the above requirements apply either way.
696 |
697 | 8. Termination.
698 |
699 | You may not propagate or modify a covered
700 | work except as expressly
701 | provided under this License. Any attempt
702 | otherwise to propagate or
703 | modify it is void, and will automatically
704 | terminate your rights under
705 | this License (including any patent licenses
706 | granted under the third
707 | paragraph of section 11).
708 |
709 | However, if you cease all violation of this
710 | License, then your
711 | license from a particular copyright holder is
712 | reinstated (a)
713 | provisionally, unless and until the copyright
714 | holder explicitly and
715 | finally terminates your license, and (b)
716 | permanently, if the copyright
717 | holder fails to notify you of the violation by
718 | some reasonable means
719 | prior to 60 days after the cessation.
720 |
721 | Moreover, your license from a particular
722 | copyright holder is
723 | reinstated permanently if the copyright holder
724 | notifies you of the
725 | violation by some reasonable means, this is the
726 | first time you have
727 | received notice of violation of this License
728 | (for any work) from that
729 | copyright holder, and you cure the violation
730 | prior to 30 days after
731 | your receipt of the notice.
732 |
733 | Termination of your rights under this section
734 | does not terminate the
735 | licenses of parties who have received copies or
736 | rights from you under
737 | this License. If your rights have been
738 | terminated and not permanently
739 | reinstated, you do not qualify to receive new
740 | licenses for the same
741 | material under section 10.
742 |
743 | 9. Acceptance Not Required for Having Copies.
744 |
745 | You are not required to accept this License
746 | in order to receive or
747 | run a copy of the Program. Ancillary
748 | propagation of a covered work
749 | occurring solely as a consequence of using
750 | peer-to-peer transmission
751 | to receive a copy likewise does not require
752 | acceptance. However,
753 | nothing other than this License grants you
754 | permission to propagate or
755 | modify any covered work. These actions
756 | infringe copyright if you do
757 | not accept this License. Therefore, by
758 | modifying or propagating a
759 | covered work, you indicate your acceptance of
760 | this License to do so.
761 |
762 | 10. Automatic Licensing of Downstream
763 | Recipients.
764 |
765 | Each time you convey a covered work, the
766 | recipient automatically
767 | receives a license from the original licensors,
768 | to run, modify and
769 | propagate that work, subject to this License.
770 | You are not responsible
771 | for enforcing compliance by third parties with
772 | this License.
773 |
774 | An "entity transaction" is a transaction
775 | transferring control of an
776 | organization, or substantially all assets of
777 | one, or subdividing an
778 | organization, or merging organizations. If
779 | propagation of a covered
780 | work results from an entity transaction, each
781 | party to that
782 | transaction who receives a copy of the work
783 | also receives whatever
784 | licenses to the work the party's predecessor in
785 | interest had or could
786 | give under the previous paragraph, plus a right
787 | to possession of the
788 | Corresponding Source of the work from the
789 | predecessor in interest, if
790 | the predecessor has it or can get it with
791 | reasonable efforts.
792 |
793 | You may not impose any further restrictions
794 | on the exercise of the
795 | rights granted or affirmed under this License.
796 | For example, you may
797 | not impose a license fee, royalty, or other
798 | charge for exercise of
799 | rights granted under this License, and you may
800 | not initiate litigation
801 | (including a cross-claim or counterclaim in a
802 | lawsuit) alleging that
803 | any patent claim is infringed by making, using,
804 | selling, offering for
805 | sale, or importing the Program or any portion
806 | of it.
807 |
808 | 11. Patents.
809 |
810 | A "contributor" is a copyright holder who
811 | authorizes use under this
812 | License of the Program or a work on which the
813 | Program is based. The
814 | work thus licensed is called the contributor's
815 | "contributor version".
816 |
817 | A contributor's "essential patent claims" are
818 | all patent claims
819 | owned or controlled by the contributor, whether
820 | already acquired or
821 | hereafter acquired, that would be infringed by
822 | some manner, permitted
823 | by this License, of making, using, or selling
824 | its contributor version,
825 | but do not include claims that would be
826 | infringed only as a
827 | consequence of further modification of the
828 | contributor version. For
829 | purposes of this definition, "control" includes
830 | the right to grant
831 | patent sublicenses in a manner consistent with
832 | the requirements of
833 | this License.
834 |
835 | Each contributor grants you a non-exclusive,
836 | worldwide, royalty-free
837 | patent license under the contributor's
838 | essential patent claims, to
839 | make, use, sell, offer for sale, import and
840 | otherwise run, modify and
841 | propagate the contents of its contributor
842 | version.
843 |
844 | In the following three paragraphs, a "patent
845 | license" is any express
846 | agreement or commitment, however denominated,
847 | not to enforce a patent
848 | (such as an express permission to practice a
849 | patent or covenant not to
850 | sue for patent infringement). To "grant" such
851 | a patent license to a
852 | party means to make such an agreement or
853 | commitment not to enforce a
854 | patent against the party.
855 |
856 | If you convey a covered work, knowingly
857 | relying on a patent license,
858 | and the Corresponding Source of the work is not
859 | available for anyone
860 | to copy, free of charge and under the terms of
861 | this License, through a
862 | publicly available network server or other
863 | readily accessible means,
864 | then you must either (1) cause the
865 | Corresponding Source to be so
866 | available, or (2) arrange to deprive yourself
867 | of the benefit of the
868 | patent license for this particular work, or (3)
869 | arrange, in a manner
870 | consistent with the requirements of this
871 | License, to extend the patent
872 | license to downstream recipients. "Knowingly
873 | relying" means you have
874 | actual knowledge that, but for the patent
875 | license, your conveying the
876 | covered work in a country, or your recipient's
877 | use of the covered work
878 | in a country, would infringe one or more
879 | identifiable patents in that
880 | country that you have reason to believe are
881 | valid.
882 |
883 | If, pursuant to or in connection with a
884 | single transaction or
885 | arrangement, you convey, or propagate by
886 | procuring conveyance of, a
887 | covered work, and grant a patent license to
888 | some of the parties
889 | receiving the covered work authorizing them to
890 | use, propagate, modify
891 | or convey a specific copy of the covered work,
892 | then the patent license
893 | you grant is automatically extended to all
894 | recipients of the covered
895 | work and works based on it.
896 |
897 | A patent license is "discriminatory" if it
898 | does not include within
899 | the scope of its coverage, prohibits the
900 | exercise of, or is
901 | conditioned on the non-exercise of one or more
902 | of the rights that are
903 | specifically granted under this License. You
904 | may not convey a covered
905 | work if you are a party to an arrangement with
906 | a third party that is
907 | in the business of distributing software, under
908 | which you make payment
909 | to the third party based on the extent of your
910 | activity of conveying
911 | the work, and under which the third party
912 | grants, to any of the
913 | parties who would receive the covered work from
914 | you, a discriminatory
915 | patent license (a) in connection with copies of
916 | the covered work
917 | conveyed by you (or copies made from those
918 | copies), or (b) primarily
919 | for and in connection with specific products or
920 | compilations that
921 | contain the covered work, unless you entered
922 | into that arrangement,
923 | or that patent license was granted, prior to 28
924 | March 2007.
925 |
926 | Nothing in this License shall be construed as
927 | excluding or limiting
928 | any implied license or other defenses to
929 | infringement that may
930 | otherwise be available to you under applicable
931 | patent law.
932 |
933 | 12. No Surrender of Others' Freedom.
934 |
935 | If conditions are imposed on you (whether by
936 | court order, agreement or
937 | otherwise) that contradict the conditions of
938 | this License, they do not
939 | excuse you from the conditions of this License.
940 | If you cannot convey a
941 | covered work so as to satisfy simultaneously
942 | your obligations under this
943 | License and any other pertinent obligations,
944 | then as a consequence you may
945 | not convey it at all. For example, if you
946 | agree to terms that obligate you
947 | to collect a royalty for further conveying from
948 | those to whom you convey
949 | the Program, the only way you could satisfy
950 | both those terms and this
951 | License would be to refrain entirely from
952 | conveying the Program.
953 |
954 | 13. Use with the GNU Affero General Public
955 | License.
956 |
957 | Notwithstanding any other provision of this
958 | License, you have
959 | permission to link or combine any covered work
960 | with a work licensed
961 | under version 3 of the GNU Affero General
962 | Public License into a single
963 | combined work, and to convey the resulting
964 | work. The terms of this
965 | License will continue to apply to the part
966 | which is the covered work,
967 | but the special requirements of the GNU Affero
968 | General Public License,
969 | section 13, concerning interaction through a
970 | network will apply to the
971 | combination as such.
972 |
973 | 14. Revised Versions of this License.
974 |
975 | The Free Software Foundation may publish
976 | revised and/or new versions of
977 | the GNU General Public License from time to
978 | time. Such new versions will
979 | be similar in spirit to the present version,
980 | but may differ in detail to
981 | address new problems or concerns.
982 |
983 | Each version is given a distinguishing
984 | version number. If the
985 | Program specifies that a certain numbered
986 | version of the GNU General
987 | Public License "or any later version" applies
988 | to it, you have the
989 | option of following the terms and conditions
990 | either of that numbered
991 | version or of any later version published by
992 | the Free Software
993 | Foundation. If the Program does not specify a
994 | version number of the
995 | GNU General Public License, you may choose any
996 | version ever published
997 | by the Free Software Foundation.
998 |
999 | If the Program specifies that a proxy can
1000 | decide which future
1001 | versions of the GNU General Public License can
1002 | be used, that proxy's
1003 | public statement of acceptance of a version
1004 | permanently authorizes you
1005 | to choose that version for the Program.
1006 |
1007 | Later license versions may give you
1008 | additional or different
1009 | permissions. However, no additional
1010 | obligations are imposed on any
1011 | author or copyright holder as a result of your
1012 | choosing to follow a
1013 | later version.
1014 |
1015 | 15. Disclaimer of Warranty.
1016 |
1017 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE
1018 | EXTENT PERMITTED BY
1019 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED
1020 | IN WRITING THE COPYRIGHT
1021 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE
1022 | PROGRAM "AS IS" WITHOUT WARRANTY
1023 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
1024 | INCLUDING, BUT NOT LIMITED TO,
1025 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1026 | FITNESS FOR A PARTICULAR
1027 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
1028 | PERFORMANCE OF THE PROGRAM
1029 | IS WITH YOU. SHOULD THE PROGRAM PROVE
1030 | DEFECTIVE, YOU ASSUME THE COST OF
1031 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
1032 |
1033 | 16. Limitation of Liability.
1034 |
1035 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW
1036 | OR AGREED TO IN WRITING
1037 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY
1038 | WHO MODIFIES AND/OR CONVEYS
1039 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO
1040 | YOU FOR DAMAGES, INCLUDING ANY
1041 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
1042 | DAMAGES ARISING OUT OF THE
1043 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING
1044 | BUT NOT LIMITED TO LOSS OF
1045 | DATA OR DATA BEING RENDERED INACCURATE OR
1046 | LOSSES SUSTAINED BY YOU OR THIRD
1047 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
1048 | WITH ANY OTHER PROGRAMS),
1049 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
1050 | ADVISED OF THE POSSIBILITY OF
1051 | SUCH DAMAGES.
1052 |
1053 | 17. Interpretation of Sections 15 and 16.
1054 |
1055 | If the disclaimer of warranty and limitation
1056 | of liability provided
1057 | above cannot be given local legal effect
1058 | according to their terms,
1059 | reviewing courts shall apply local law that
1060 | most closely approximates
1061 | an absolute waiver of all civil liability in
1062 | connection with the
1063 | Program, unless a warranty or assumption of
1064 | liability accompanies a
1065 | copy of the Program in return for a fee.
1066 |
1067 | END OF TERMS AND
1068 | CONDITIONS
1069 |
1070 | How to Apply These Terms to Your
1071 | New Programs
1072 |
1073 | If you develop a new program, and you want it
1074 | to be of the greatest
1075 | possible use to the public, the best way to
1076 | achieve this is to make it
1077 | free software which everyone can redistribute
1078 | and change under these terms.
1079 |
1080 | To do so, attach the following notices to the
1081 | program. It is safest
1082 | to attach them to the start of each source file
1083 | to most effectively
1084 | state the exclusion of warranty; and each file
1085 | should have at least
1086 | the "copyright" line and a pointer to where the
1087 | full notice is found.
1088 |
1089 |
1091 | Copyright (C)
1092 |
1093 | This program is free software: you can
1094 | redistribute it and/or modify
1095 | it under the terms of the GNU General
1096 | Public License as published by
1097 | the Free Software Foundation, either
1098 | version 3 of the License, or
1099 | (at your option) any later version.
1100 |
1101 | This program is distributed in the hope
1102 | that it will be useful,
1103 | but WITHOUT ANY WARRANTY; without even the
1104 | implied warranty of
1105 | MERCHANTABILITY or FITNESS FOR A PARTICULAR
1106 | PURPOSE. See the
1107 | GNU General Public License for more
1108 | details.
1109 |
1110 | You should have received a copy of the GNU
1111 | General Public License
1112 | along with this program. If not, see
1113 | .
1114 |
1115 | Also add information on how to contact you by
1116 | electronic and paper mail.
1117 |
1118 | If the program does terminal interaction,
1119 | make it output a short
1120 | notice like this when it starts in an
1121 | interactive mode:
1122 |
1123 | Copyright (C)
1125 | This program comes with ABSOLUTELY NO
1126 | WARRANTY; for details type `show w'.
1127 | This is free software, and you are welcome
1128 | to redistribute it
1129 | under certain conditions; type `show c' for
1130 | details.
1131 |
1132 | The hypothetical commands `show w' and `show c'
1133 | should show the appropriate
1134 | parts of the General Public License. Of
1135 | course, your program's commands
1136 | might be different; for a GUI interface, you
1137 | would use an "about box".
1138 |
1139 | You should also get your employer (if you
1140 | work as a programmer) or school,
1141 | if any, to sign a "copyright disclaimer" for
1142 | the program, if necessary.
1143 | For more information on this, and how to apply
1144 | and follow the GNU GPL, see
1145 | .
1146 |
1147 | The GNU General Public License does not
1148 | permit incorporating your program
1149 | into proprietary programs. If your program is
1150 | a subroutine library, you
1151 | may consider it more useful to permit linking
1152 | proprietary applications with
1153 | the library. If this is what you want to do,
1154 | use the GNU Lesser General
1155 | Public License instead of this License. But
1156 | first, please read
1157 | .
1158 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ## C++ için hazırlanmış bazı örnek kodlar ve açıklamalar
6 |
7 | ## Zamanla yenileri eklenecektir
8 |
9 | --------------------------
10 |
11 | **Daha Yeni Not**
12 |
13 | Sınav haftama girdiğim için bir süre duraksayacak ilerlememiz. Ancak elimden geldiğince katkı sağlamaya
14 | devam edeceğim. İyi çalışmalar.
15 |
16 | **Yeni Not:**
17 |
18 | Okulla ilgili işlerim, sosyal işlerim ve çalıştığım yerde olan işlerimden dolayı biraz yavaş ilerliyoruz.
19 | Anlayış göstereceğinizi umuyorum :)
20 |
21 | **Not:**
22 |
23 | Hatalarım olabilir tek kişi projeye destek veriyorum. Gözümden kaçan noktalar olabilir. Ancak projeye katkı
24 | sağlamakta özgürsünüz. Eğer farkettiğiniz bir hata, eksiklik vs. olursa lütfen bildirin. Anlayışınız için
25 | teşekkür ederim :)
26 |
27 | * Giriş
28 | * [Derleyici ve Editör](giris/derleyici_editor.md)
29 |
30 |
31 | * Giriş Seviye Konular
32 | * [İlk Program](giris_konular/ilk_program.md)
33 | * [Değişkenler, Veri Tipleri, Kaçış Dizgeleri, Sabitler](giris_konular/degiskenler.md)
34 | * [Operatörler](giris_konular/operatorler.md)
35 | * [Giriş ve Çıkış Alma](giris_konular/giris_cikis.md)
36 |
37 | * Orta Seviye Konular
38 | * [Koşullu İfadeler ve Döngüler](orta_konular/kosullar_donguler.md)
39 | * [Fonksiyonlar](orta_konular/fonksiyonlar.md)
40 | * [Overloads (Aşırı Yüklemeler) ve Templates (Şablonlar)](orta_konular/overloads_templates.md)
41 | * [Diziler](orta_konular/diziler.md)
42 | * [Karakter Dizileri](orta_konular/karakter_dizileri.md)
43 |
44 | * İleri Seviye Konular
45 | * [Pointers (İşaretçiler)](ileri_konular/pointers.md)
46 | * [Dinamik Hafıza](ileri_konular/dinamik_hafiza.md)
47 | * [Veri Yapıları](ileri_konular/veri_yapilari.md)
48 | * [Diğer Veri Tipleri](ileri_konular/diger_veri_tipleri.md)
49 | * [Sınıflar](ileri_konular/siniflar.md)
50 | * [Kalıtım](ileri_konular/kalitim.md)
51 | * [Polymorphism](ileri_konular/polymorphism.md)
52 | * [Tip Dönüşümleri](ileri_konular/tip_donusumleri.md)
53 | * [İstisnalar ve Hata Yakalama](ileri_konular/hata_yakalama.md)
54 | * [Önişlemci Yönergeleri](ileri_konular/onislemci.md)
55 |
56 | ## **Kaynakça:**
57 |
58 | [cplusplus.com](http://www.cplusplus.com/)
59 |
--------------------------------------------------------------------------------
/giris/derleyici_editor.md:
--------------------------------------------------------------------------------
1 | ## Derleyici ve Editör Nedir?
2 |
3 | ### Derleyici:
4 |
5 | Bilgisayarlar yalnızca tek bir dili anlar. Bu dil 1 ve 0 lardan oluşur. Bilgisayarların anladığı
6 | bu dile makine dili adı verilir. Makine dili ile yazılmış bir kodu okumak veya makine dili ile yazmak
7 | oldukça zahmetlidir. Bu yüzden yüksek seviyeli diller geliştirilmiştir. Bu dillerin özelliği anlaşılması
8 | ve yazılması kolay olmasıdır. Bu dillerin makine diline çevrilerek bilgisayarın anlaması için ise
9 | derleyiciler geliştirilmiştir.
10 |
11 | **Derleyici yazılan programın makine diline dönüştürülmesi işine yarar.**
12 |
13 | **Önerilen Derleyiciler**
14 |
15 | Derleyici | Platform | Komut
16 | --------- | -------- | -----
17 | GCC | GNU/Linux ve Diğerleri | g++ -std=c++0x ornek.cpp -o ornek
18 | Clang | OS X ve Diğerleri | clang++ -std=c++11 -stdlib=libc++ ornek.cpp -o ornek
19 |
20 | ### Editör ve IDE:
21 |
22 | Editörler yazı yazmamıza yarayan araçlardır. Sonraları gelişerek (eklentiler vs.) kod yazmamızı
23 | kolaylaştıracak eylemlerde bulunmuşlardır.
24 |
25 | IDE ise direkt derleyici ile entegre gelen, hata ayıklama yapmamızı sağlayan, otomatik düzeltme/tamamlama
26 | yapan araçlardır.
27 |
28 | Ben editör olarak Visual Studio Code, derleyici olarak g++ kullanmaktayım. Tabii siz nasıl rahat ediyorsanız
29 | onu kullanın.
30 |
31 | **Önerilen IDE'ler**
32 |
33 | IDE | Platform
34 | --- | --------
35 | Code::blocks | GNU/Linux/Windows/OS X
36 | Dec-C++ | Windows
37 | Visual Studio | Windows
--------------------------------------------------------------------------------
/giris_konular/degiskenler.md:
--------------------------------------------------------------------------------
1 | ### Bu Bölümde Değişkenlere, Veri Tiplerine, Kaçış Dizgeleri ve Sabitlere Değineceğiz
2 |
3 | #### Değişkenler ve Veri Tipleri
4 |
5 | Değişkenler programda içinde veri saklayabileceğimiz yapılardır. Mesela öğrencilerin notlarını tutacak bir program yazmak isterseniz
6 | bu notları bir değişkende tutmanız gerekir. Bu değişkenin bir tipi olması gerekir. Şimdi tiplerin bize ne ifade ettiğinden bahsedelim.
7 |
8 | Tipin Adı | Boyut
9 | --------- | -----
10 | char | 8 bit
11 | int | 16 bit
12 | float | 32 bit
13 | double | 64 bit
14 | bool | 1 bit
15 | string | Verilen Değere Göre Değişkenlik Gösterir
16 |
17 | Üsttekiler en sık kullanılan veri tipleridir. Detaylı bilgi için [şurayı](http://www.cplusplus.com/doc/tutorial/variables/) inceleyebilirsiniz.
18 |
19 | **Kullanım:**
20 |
21 | ```c++
22 | #include
23 | #include //string kullanabilmek için
24 |
25 | using namespace std;
26 |
27 | int main()
28 | {
29 | int tamsayi;
30 | float ondalikliSayi;
31 | double toplam;
32 | char karakter;
33 | string yazi;
34 |
35 | // Değişken atamaları bu şekilde yapılır ve tipleri sol tarafa isimleri sağ tarafa yazılır.
36 | }
37 | ```
38 |
39 | ```c++
40 | #include
41 |
42 | using namespace std;
43 |
44 | int main()
45 | {
46 | int sayi1 = 3;
47 | int sayi2 = 2;
48 | int toplam;
49 |
50 | toplam = sayi1 + sayi2;
51 |
52 | cout << "Sayilarin Toplami: " << toplam << endl;
53 | }
54 | ```
55 |
56 | **Ekran Çıktısı:**
57 |
58 | ```
59 | Sayilarin Toplami: 5
60 | ```
61 |
62 | ```c++
63 | #include
64 | #include
65 |
66 | using namespace std;
67 |
68 | int main()
69 | {
70 | string mesaj;
71 | mesaj = "C++ Cok Keyifli :)";
72 |
73 | cout << mesaj << endl;
74 | }
75 | ```
76 |
77 | **Ekran Çıktısı:**
78 |
79 | ```
80 | C++ Cok Keyifli :)
81 | ```
82 |
83 | #### Kaçış Dizgeleri
84 |
85 | İfade | Açıklama
86 | ----- | --------
87 | \a | Ses veya görünebilir uyarı üretir
88 | \b | İmleci bir sütun (pozisyon) geri kaydırır
89 | \f | İmleci bir sonraki sayfanın ilk pozisyonuna kaydırır
90 | \n | Yeni satıra geçer
91 | \t | İmleci bir tab boşluğu yatayda ileri kaydırır
92 | \v | İmleci bir tab boşluğu dikeyde aşağı kaydırır
93 | \' | Tekli tırnak oluşturur
94 | \" | Çiftli tırnak oluşturur
95 | \? | Soru işareti oluşturur
96 | \\ | Ters taksim oluşturur
97 | \0 | Boş karakter oluşturur
98 |
99 | Programınızda gerektiği yerlerde kolaylıklar sağlar.
100 |
101 | ```c++
102 | #include
103 |
104 | using namespace std;
105 |
106 | int main()
107 | {
108 | cout << "Yatayda \t bosluk biraktim ve \n alt satira gectim" << endl;
109 | }
110 | ```
111 | **Ekran Çıktısı:**
112 |
113 | ```
114 | Yatayda bosluk biraktim ve
115 | alt satira gectim
116 | ```
117 |
118 | #### Sabitler
119 |
120 | Programınızda bazı değerleri sabit kalması değişmemesi gerekir. Yukarıda öğrendiğimiz değişkenlere yeni atamalar yapabiliriz ancak sabitler
121 | adından anlaşılacağı gibi değiştirilemezler. Ufak bir örnek üzerinden daha iyi anlayabiliriz.
122 |
123 | ```c++
124 | #include
125 |
126 | using namespace std;
127 |
128 | const double pi = 3.14159;
129 | const char yeniSatir = '\n';
130 |
131 | int main()
132 | {
133 | double yariCap = 5.0;
134 | double daire;
135 |
136 | daire = 2 * pi * yariCap;
137 |
138 | cout << "Dairenin Cevresi: " << yeniSatir;
139 | cout << daire << yeniSatir;
140 | }
141 | ```
142 |
143 | **Ekran Çıktısı:**
144 |
145 | ```
146 | Dairenin Cevresi:
147 | 31.4159
148 | ```
149 |
150 | Örnekte görüldüğü gibi pi değeri sabittir ve değiştirilemez.
--------------------------------------------------------------------------------
/giris_konular/giris_cikis.md:
--------------------------------------------------------------------------------
1 | ### Giriş Çıkış
2 |
3 | Fonksiyon | Açıklama
4 | --------- | --------
5 | cout | standart giriş
6 | cin | standart çıkış
7 | cerr | standart error çıkış
8 | clog | standart logging çıkış
9 |
10 | **cout** fonksiyonuna artık aşina olduğumuzu düşünüyorum. Bu bölüme gelene kadar epeyce kullandık.
11 |
12 | **cin** ile ilgili henüz hiçbir örnek yapmadık. Kullanıcıyı henüz yazdığımız programlara dahil etmedik.
13 | Şimdi örneklerimizde **cin** ile kullanıcıdan veri alalım.
14 |
15 | ```c++
16 | #include
17 |
18 | using namespace std;
19 |
20 | int main()
21 | {
22 | int yas;
23 |
24 | cout << "Yasinizi Giriniz: ";
25 | cin >> yas;
26 |
27 | cout << "Yasiniz: " << yas << endl;
28 | }
29 | ```
30 |
31 | **Ekran Çıktısı**
32 |
33 | ```
34 | Yasinizi Giriniz: 20
35 | Yasiniz: 20
36 | ```
37 |
38 | Gördüğünüz gibi **cin** ile kullanıcıdan oldukça kolay bir şekilde veri aldık.
39 |
40 | **cin** ile birden fazla veri almamızda mümkündür.
41 |
42 | ```c++
43 | #include
44 |
45 | using namespace std;
46 |
47 | int main()
48 | {
49 | int sayi1, sayi2, toplam = 0;
50 |
51 | cout << "Iki adet sayi giriniz: ";
52 | cin >> sayi1 >> sayi2;
53 |
54 | toplam = sayi1 + sayi2;
55 |
56 | cout << "Sayilarin toplami: " << toplam << endl;
57 | }
58 | ```
59 |
60 | **Ekran Çıktısı:**
61 |
62 | ```
63 | Iki adet sayi giriniz: 3 5
64 | Sayilarin toplami: 8
65 | ```
66 |
67 | **Not**
68 |
69 | Sayılardan birini girdikten sonra space (boşluk) veya enter (giriş) tuşuna basıp ikinci sayıyı girmelisiniz.
70 | Ardından enter (giriş) tuşuna basınız.
71 |
72 | ----------------------
73 |
74 | **String Girişleri ve Stringstream**
75 |
76 | C++ dilinde **string** dediğimiz yapılar insanları başta ürkütür. Aslında görüdüğü gibi değildir. String kullanımı
77 | geliştiricilerin bizim için hazırladığı kütüphaneler ve fonksiyonlar yardımı ile oldukça kolaylaşmıştır.
78 |
79 | ```c++
80 | #include
81 | #include
82 | #include
83 | using namespace std;
84 |
85 | int main ()
86 | {
87 | string mesaj;
88 | string sozel;
89 | float fiyat;
90 | int miktar;
91 |
92 | cout << "Mesajiniz: ";
93 | getline(cin, mesaj);
94 | cout << mesaj << endl;
95 |
96 | cout << "Kalem fiyatini giriniz: ";
97 | getline(cin, sozel);
98 | stringstream(sozel) >> fiyat;
99 |
100 | cout << "Alacaginiz kalem miktarini giriniz: ";
101 | getline(cin, sozel);
102 | stringstream(sozel) >> miktar;
103 |
104 | cout << "Toplam Fiyat: " << miktar * fiyat << endl;
105 | }
106 | ```
107 |
108 | **Ekran Çıktısı:**
109 |
110 | ```
111 | Mesajiniz: Merhaba C++
112 | Merhaba C++
113 | Kalem fiyatini giriniz: 10.5
114 | Alacaginiz kalem miktarini giriniz: 3
115 | Toplam Fiyat: 31.5
116 | ```
117 |
118 | Örnekte gördüğünüz gibi string alınan bir veriyi **stringstream** ile sayısal bir veriye atadık.
--------------------------------------------------------------------------------
/giris_konular/ilk_program.md:
--------------------------------------------------------------------------------
1 | ### Hazırsak İlk Programımızı Yazalım
2 |
3 | ```c++
4 | #include
5 |
6 | int main()
7 | {
8 | std::cout << "Merhaba C++";
9 | }
10 | ```
11 |
12 | Bu kodu satır satır inceleyelim.
13 |
14 | * Birinci satırda **include** ifadesi kütüphaneleri programımıza eklemeye yarar. Yani ilk satırda **iostream** kütüphanesini ekledik.
15 | Bu kütüphane standart giriş çıkış kütüphanesidir. Kullanıcıdan veri alma veya kullanıcıya veri göstermeye yarar.
16 | * İkinci satırda **int main()** ifadesi bizim kodumuzun çalışacağı ana bölümdür. Bu kısımla ilgili ileride daha fazla anlatım yapılacaktır.
17 | * Üçüncü ve Beşinci satırlar main kısmının parantezleridir. Bunlar zorunlu parantezlerdir. Kodlarımız bunlar arasında yazılmalıdır.
18 | * Dördüncü satırda **std::cout** standart veri çıkışı (kullanıcıya bilgi göstermek) için kullanılır. << ifadesi yazılanların **cout**'a
19 | eklendiğini belirtir. Ve ifademiz "çift tırnak içinde yazılmalıdır." **Noktalı Virgül (;)** ise c++ dilinde o satırın sonlandığını belirten
20 | bir işarettir. Kullanılması zorunludur. Unutulması halinde derleyici hata verir.
21 |
22 | **Üstteki kod parçasını okunaklı olsun diye o şekilde yazdık. İsteğinize göre main bölümünü tek satırda da yazabilirsiniz.**
23 |
24 | ```c++
25 | #include
26 | int main () { std::cout << "Merhaba C++"; }
27 | ```
28 |
29 | Artık std::cout ifadesindeki std komutunu kullanmayacağız. Yeni bir şey olan **using namespace std** isim uzayını göreceğiz.
30 |
31 | ```c++
32 | #include
33 |
34 | using namespace std;
35 |
36 | int main()
37 | {
38 | cout << "Merhaba C++"";
39 | cout << "Programlama Cok Zevkli";
40 | }
41 | ```
42 |
43 | **Ekran Çıktısı:**
44 |
45 | ```
46 | Merhaba C++Programlama Cok Zevkli
47 | ```
48 |
49 | * İlk olarak **using namespace std** ifadesi bir isim uzayıdır ve her fonksiyonun başına std:: yazma zahmetinden sizi kurtarır.
50 | * İkinci olarak burada bir sorun var. Alt satıra geçemedik ve bitişik yazdık iki cümleyi.
51 | * Üçüncü olarak Türkçe karakter kullanmıyoruz. Yoksa hata alırız. Elbet çözümü var ve oldukça kolay. Araştırma yapmaya elinizin alışması için sizin
52 | arayıp bulmanızı istiyorum.
53 |
54 | **Alt Satıra Geçmek**
55 |
56 | Bunun birden fazla yolu var. Örneğimizi inceleyelim.
57 |
58 | ```c++
59 | #include
60 |
61 | using namespace std;
62 |
63 | int main()
64 | {
65 | cout << "Merhaba C++" << endl;
66 | cout << "Programlama Cok Zevkli \n";
67 | cout << "Alt satira geciyoruz";
68 | }
69 | ```
70 |
71 | ```c++
72 | #include
73 |
74 | using namespace std;
75 |
76 | int main()
77 | {
78 | cout << "Merhaba C++" << endl << "Programlama Cok Zevkli \n" << "Alt satira geciyoruz";
79 | }
80 | ```
81 |
82 | Üstteki iki kod parçası aynı çıktıyı verecektir bize. yani **endl ve \n** ifadeleri aynı işi görüyor.
83 |
84 | **Ekran Çıktısı:**
85 |
86 | ```
87 | Merhaba C++
88 | Programlama Cok Zevkli
89 | Alt satira geciyoruz
90 | ```
91 |
92 | **Yorum Satırları**
93 |
94 | Yorum satırları programda bir şey anlatacağımız zaman veya bir şey ifade edeceğimiz zaman kullandığımız, programın çalıştırmadığı
95 | satırlardır.
96 |
97 | ```c++
98 | #include
99 |
100 | using namespace std;
101 |
102 | int main()
103 | {
104 | cout << "Merhaba C++" << endl; // Tekli Yorum Satırı Yazıyoruz
105 | /*
106 | Çoklu
107 | Yorum
108 | Satırı
109 | Yazıyoruz
110 | */
111 | }
112 | ```
113 |
114 | **Ekran Çıktısı:**
115 |
116 | ```
117 | Merhaba C++
118 | ```
119 |
120 | Gördüğünüz gibi yorum satırlarının programımıza hiçbir etkisi olmadı.
--------------------------------------------------------------------------------
/giris_konular/operatorler.md:
--------------------------------------------------------------------------------
1 | ### Operatörler
2 |
3 | Operatör dediğimiz şeyler bazı işlemleri yapmamızı sağlayan evresel sembollerdir.
4 |
5 | **Aritmatik Operatörler**
6 |
7 | Operatör | Açıklama
8 | -------- | --------
9 | (=) | Atama Operatörü
10 | (+) | Toplama Operatörü
11 | (-) | Çıkarma Operatörü
12 | (*) | Çarpma Operatörü
13 | (/) | Bölme Operatörü
14 | (%) | Mod Operatörü
15 |
16 | ```c++
17 | #include
18 |
19 | using namespace std;
20 |
21 | int main()
22 | {
23 | int sayi1 = 10, sayi2 = 5;
24 |
25 | cout << "Sayi1 ve Sayi2 nin Toplami: " << sayi1 + sayi2 << endl;
26 | cout << "Sayi1 ve Sayi2 nin Farki : " << sayi1 - sayi2 << endl;
27 | cout << "Sayi1 ve Sayi2 nin Carpimi: " << sayi1 * sayi2 << endl;
28 | cout << "Sayi1 ve Sayi2 nin Bolumu : " << sayi1 / sayi2 << endl;
29 | cout << "Sayi1 ve Sayi2 nin Modu : " << sayi1 % sayi2 << endl;
30 | }
31 | ```
32 |
33 | ```
34 | Sayi1 ve Sayi2 nin Toplami: 15
35 | Sayi1 ve Sayi2 nin Farki : 5
36 | Sayi1 ve Sayi2 nin Carpimi: 50
37 | Sayi1 ve Sayi2 nin Bolumu : 2
38 | Sayi1 ve Sayi2 nin Modu : 0
39 | ```
40 |
41 | Yukarıdaki örnekten anlaşılacağı üzere = operatörü değişkene bir değer atamaya yararken diğer operatörler matematiksel ifadeler
42 | için kullanılır.
43 |
44 | ------------------------------
45 |
46 | **Bileşik Operatörler**
47 |
48 | Operatör | Açıklama
49 | -------- | --------
50 | (==) | Eşit mi?
51 | (!=) | Eşit Değil mi?
52 | (<) | Küçük mü?
53 | (>) | Büyük mü?
54 | (<=) | Küçük veya Eşit mi?
55 | (>=) | Büyük veya Eşit mi?
56 |
57 | **Az Önemli Not**
58 |
59 | Bu operatörler ile ilgili detaylı örnekler ileride yapılacaktır sakinliğinizi koruyun :)
60 |
61 | **Biraz Daha Fazla Önemli Not**
62 |
63 | Operatörlerin başında ve sonunda parantez işaretli yoktur. Markdown'un azizliği :)
--------------------------------------------------------------------------------
/orta_konular/diziler.md:
--------------------------------------------------------------------------------
1 | ### Diziler
2 |
3 | Diziler içinde aynı tipte bir veya daha fazla veri tutmamızı, üzerinde işlemler
4 | yapmamızı sağlayan yapılardır.
5 |
6 | Dizinin boyutunu;
7 |
8 | ```c++
9 | int dizi[5];
10 | ```
11 |
12 | şeklinde belirleriz. Bu gösterim dizimiz 5 eleman alabilir demektir.
13 |
14 | Hadi şimdide ilk değer atayalım.
15 |
16 | ```c++
17 | int dizi[5] = {10, 20, 30, 40, 50};
18 | ```
19 |
20 | Yukarıdaki örneği bir kod parçası olarak yazalım.
21 |
22 | ```c++
23 | #include
24 |
25 | using namespace std;
26 |
27 | int main()
28 | {
29 | int dizi[5] = {10, 20, 30, 40, 50};
30 | int dizi2[2] = {};
31 |
32 | cout << "Birinci dizinin 2. elemani: " << dizi[1] << '\n';
33 | cout << "Birinci dizinin 1. elemani: " << dizi[0] << '\n';
34 | cout << "Ikinci dizinin 2. elemani: " << dizi2[1] << '\n';
35 |
36 | return 0;
37 | }
38 | ```
39 |
40 | Örneği incelediğimizde dizi elemanlarının indislerinin 0'dan başladığını
41 | görürüz. Yani **dizi[0]** demek **dizinin 1. elemanı** demektir.
42 |
43 | Eğer dizinin boyutunu belirledikten sonra değer atamazsanız o dizinin
44 | elemanları varsayılan olarak 0 atanacaktır.
45 |
46 | ------------------------------
47 |
48 | ```c++
49 | #include
50 |
51 | using namespace std;
52 |
53 | int main()
54 | {
55 | int yeni_dizi [] = {16, 4, 32, 48, 120};
56 | int n, sonuc = 0;
57 |
58 | for(n = 0 ; n < 5 ; ++n)
59 | {
60 | sonuc += yeni_dizi[n];
61 | }
62 | cout << sonuc << endl;
63 | }
64 | ```
65 |
66 | Örneği inceleyelim. Bir dizi oluşturduk ve dizinin eleman sayısı kadar
67 | **for** döngüsüne soktuk. Bu durumda dizinin tüm elemanları sırasıyla
68 | toplandı. En son döngü tamamlandıktan sonra ekrana toplam değeri yazdırdık.
69 |
70 | ------------------------
71 |
72 | ### Çok Boyutlu Diziler
73 |
74 | ```
75 | int dizi[3][5]
76 | ```
77 |
78 | 0 | 1 | 2 | 3 | 4
79 | --|---|---|---|---
80 | **1** | | | |
81 | **2** | | | |
82 |
83 | Yukarıdaki dizi tanımı tablodaki gibi 3 satır, 5 sütunluk bir dizi oluşturmamızı
84 | sağlar.
85 |
86 | ```c++
87 | #include
88 |
89 | using namespace std;
90 |
91 | void printarray (int arg[], int length) {
92 | for (int n=0; n
9 |
10 | using namepsace std;
11 |
12 | int toplama(int sayi1, int sayi2)
13 | {
14 | int toplam;
15 | toplam = sayi1 + sayi2;
16 | return toplam;
17 | }
18 |
19 | int main()
20 | {
21 | int a;
22 | a = toplama(4, 3);
23 |
24 | cout << "Toplam: " << a << endl;
25 | }
26 | ```
27 |
28 | **Ekran Çıktısı:**
29 |
30 | ```
31 | Toplam: 7
32 | ```
33 |
34 | Örneği adım adım anlatalım. **main** kısmı tüm fonksiyonlarımızın çalıştığı yerdir. Bizim
35 | ana fonksiyonumuzdur. **main** fonksiyonunda **toplama** fonksiyonunu çağırıyoruz. **Toplama**
36 | fonksiyonunun yapısı **int toplama(int sayi1, int sayi2)** şeklindedir. Bunu biraz açalım.
37 |
38 | Baştaki **int** fonksiyonun bize geri döndüreceği tipi belirtir. **toplama** fonksiyonun ismini belirtir.
39 | Parantez içindeki değerler ise fonksiyona vereceğimiz değişkenleri belirler.
40 |
41 | ```c++
42 | #include
43 |
44 | using namepsace std;
45 |
46 | int toplama(int, int); //Fonksiyon prototipi
47 |
48 | int main()
49 | {
50 | int a;
51 | a = toplama(4, 3);
52 |
53 | cout << "Toplam: " << a << endl;
54 | }
55 |
56 | int toplama(int sayi1, int sayi2)
57 | {
58 | int toplam;
59 | toplam = sayi1 + sayi2;
60 | return toplam;
61 | }
62 | ```
63 |
64 | **Ekran Çıktısı:**
65 |
66 | ```
67 | Toplam: 7
68 | ```
69 |
70 | Arkadaşlar bu kod diğeri ile aynı işi yapar. Fark ise kodunuzun daha okunaklı olması için **toplama** fonksiyonu
71 | **main** fonksiyonunun altına yazılmıştır. Yorum satırı ile belirtilen **Fonksiyon Prototipi** ise bize kodu
72 | incelerken programda kullandığımız fonksiyonun ismini, dönüş tipini, aldığı **parametreleri** (sayi1, sayi2)
73 | gösterir. Böylece kod daha okunaklı bir hale gelmiş olur.
74 |
75 | **Soru:**
76 |
77 | Fonksiyonlardan geriye yalnızca bir tane değer mi döndürebiliriz?
78 |
79 | bknz. [Tuple](Örnekler/tuple)
80 |
81 | ---------------------------
82 |
83 | ### Geriye Değer Döndürmeyen Fonksiyonlar (Tipsiz Fonksiyonlar - Void)
84 |
85 | ```c++
86 | #include
87 |
88 | using namespace std;
89 |
90 | void printmessage();
91 |
92 | int main ()
93 | {
94 | printmessage();
95 | }
96 |
97 | void printmessage()
98 | {
99 | cout << "Geriye bir deger donmuyor!" << endl;
100 | }
101 | ```
102 |
103 | **Ekran Çıktısı:**
104 |
105 | ```
106 | Geriye bir deger donmuyor!
107 | ```
108 |
109 | Örnekte görüldüğü gibi eğer **void** tipinde bir fonksiyon yazıyor isek **return** fonksiyonu ile
110 | geriye değer döndürmez. Ekrana bir çıktı verebilir.
111 |
112 | ### Ana Dönüş Değeri (return 0)
113 |
114 | Şuana kadar programlarımızda geriye bir şey döndürmedik. C++ dilinde programın hatasız bir şekilde
115 | sonlandığını belirtmek için **return 0** ifadesi kullanılır.
116 |
117 | ```c++
118 | #include
119 |
120 | using namespace std;
121 |
122 | int main ()
123 | {
124 | cout << "Hatasiz bir sekilde sonlandi." << endl;
125 |
126 | return 0;
127 | }
128 | ```
129 |
130 | **Ekran Çıktısı:**
131 |
132 | ```
133 | Hatasiz bir sekilde sonlandi.
134 | ```
135 |
136 | Değer | Açıklama
137 | --------- | --------
138 | 0 | Program başarılı oldu
139 | [EXIT_SUCCESS](www.cplusplus.com/EXIT_SUCCESS) | Program başarılı oldu. **cstdlib** kütüphanesi kullanılmalıdır.
140 | [EXIT_FAILURE](http://www.cplusplus.com/reference/cstdlib/EXIT_FAILURE/) | Program başarısız oldu. **cstdlib** kütüphanesi kullanılmalıdır.
141 |
142 | ### Değere ve Referansa Göre Gönderilen Değişkenler
143 |
144 | ```c++
145 | #include
146 | using namespace std;
147 |
148 | void ciftle (int& a, int& b, int& c)
149 | {
150 | a*=2;
151 | b*=2;
152 | c*=2;
153 | }
154 |
155 | int main ()
156 | {
157 | int x=1, y=3, z=7;
158 |
159 | ciftle (x, y, z);
160 | cout << "x=" << x << ", y=" << y << ", z=" << z;
161 |
162 | return 0;
163 | }
164 | ```
165 |
166 | **Ekran Çıktısı:**
167 |
168 | ```
169 | x = 2 y = 6 z = 14
170 | ```
171 |
172 | Örnekte görüldüğü gibi eğer fonksiyonda uygulanan değişikliği mainde uygulayabilmek için
173 | parametrelerin referanslarını gönderdik.
174 |
175 |
176 |
177 |
178 | ```c++
179 | #include
180 | using namespace std;
181 |
182 | void ciftle (int a, int b, int c)
183 | {
184 | a*=2;
185 | b*=2;
186 | c*=2;
187 | }
188 |
189 | int main ()
190 | {
191 | int x=1, y=3, z=7;
192 |
193 | ciftle (x, y, z);
194 | cout << "x=" << x << ", y=" << y << ", z=" << z;
195 |
196 | return 0;
197 | }
198 | ```
199 |
200 | **Ekran Çıktısı:**
201 |
202 | ```
203 | x = 1 y = 3 z = 7
204 | ```
205 |
206 | Bu örnekte ise parametreler referans ile gönderilmediği için mainde **ciftle** fonksiyonu etki etmedi.
207 |
208 | ### Recursive Fonksiyonlar (Özyinelenebilir Fonksiyonlar)
209 |
210 | Bu fonksiyonların performans açısından bellekte bir yığın işlemi yaptığı için optimize edilmediğinde
211 | normal fonksiyonlara göre biraz daha yavaş kalabilir. Ancak bu fark oldukça azdır ve sizi pek
212 | etkileyeceğini sanmıyorum.
213 |
214 | Peki biz neden **recursive** fonksiyonlar kullanmalıyız? Kullanmak zorunde değilsiniz ancak bazı durumlarda
215 | kolaylık sağlar. Biz faktöriyel hesaplama programı ile örneklendireceğiz konuyu.
216 |
217 | **Faktöriyel:**
218 |
219 | * n! = n * (n-1) * (n-2) * (n-3) ... * 1
220 |
221 | * 5! = 5 * 4 * 3 * 2 * 1 = 120
222 |
223 | ```c++
224 | #include
225 | using namespace std;
226 |
227 | long factorial(long a)
228 | {
229 | if (a > 1)
230 | return (a * factorial (a-1));
231 | else
232 | return 1;
233 | }
234 |
235 | int main ()
236 | {
237 | long number = 5;
238 |
239 | cout << number << "! = " << factorial(number);
240 | return 0;
241 | }
242 | ```
243 |
244 | **Ekran Çıktısı:**
245 |
246 | ```
247 | 5! = 120
248 | ```
249 |
250 | Gördüğünüz gibi fonksiyon kendini tekrarlayarak bir sayının faktöriyelini
251 | hesaplamayı başardı.
--------------------------------------------------------------------------------
/orta_konular/karakter_dizileri.md:
--------------------------------------------------------------------------------
1 | ### Karakter Dizileri
2 |
3 | **string** den önceki konularda üstü kapalı bir şekilde bahsetmiştik. **string** ler
4 | karakter dizilerini işlemek için çok güçlü bir sınıftır aslında. Normal dizi tanımlar gibi
5 | tanımlamamız mümkündür.
6 |
7 | ```c++
8 | char dizi[20];
9 | ```
10 |
11 | ```c++
12 | char kelime[] = {'M', 'e', 'r', 'h', 'a', 'b', 'a', '\0'};
13 | char kelime[] = "Merhaba";
14 | ```
15 |
16 | Yukarıdaki iki karakter dizisi tanımlama işlemi aynıdır.
17 |
18 | ```c++
19 | #include
20 | #include
21 |
22 | using namespace std;
23 |
24 | int main ()
25 | {
26 | char question1[] = "Adın ne? ";
27 | string question2 = "Nerede yaşıyorsun? ";
28 | char answer1 [80];
29 | string answer2;
30 | cout << question1;
31 | cin >> answer1;
32 | cout << question2;
33 | cin >> answer2;
34 | cout << "Merhaba, " << answer1;
35 | cout << " senin şehrin " << answer2 << "!\n";
36 | return 0;
37 | }
38 | ```
39 |
40 | **Ekran Çıktısı:**
41 |
42 | ```
43 | Adın ne? İlteriş
44 | Nerede yaşıyorsun? Samsun
45 | Merhaba, İlteriş senin şehrin Samsun!
46 | ```
47 |
--------------------------------------------------------------------------------
/orta_konular/kosullar_donguler.md:
--------------------------------------------------------------------------------
1 | ### Koşullu İfadeler ve Döngüler
2 |
3 | Buraya kadar geldiyseniz eğer epey bir yol kat ettiniz demektir. Sabırla okumaya devam ediniz.
4 | Yazdığımız programların tamamı dümdüz programdı. Artık bunları biraz daha dinamik hale getirmenin
5 | vakti geldi.
6 |
7 | **Koşullu İfadeler**
8 |
9 | Karar verme durumu olan bir program yazacaksak (10, 5'ten büyük müdür? vb.) **if - else** yapısını
10 | kullanmalıyız.
11 |
12 | ```c++
13 | #include
14 |
15 | using namespace std;
16 |
17 | int main()
18 | {
19 | int x = 100;
20 |
21 | if(x == 100)
22 | cout << "x = 100" << endl;
23 |
24 | if(x == 100)
25 | {
26 | cout << "x = ";
27 | cout << x << endl;
28 | }
29 |
30 | if(x == 100) { cout << "x = "; cout << x << endl;}
31 | }
32 | ```
33 |
34 | **Ekran Çıktısı:**
35 |
36 | ```
37 | x = 100
38 | x = 100
39 | x = 100
40 | ```
41 |
42 | Yukarıdaki örneklerde görüldüğü gibi tek satır bir if bloğunda süslü parantez açmamıza gerek yoktur. Ancak
43 | bir satırdan fazla olan tüm if bloklarında süslü parantez açmalıyız.
44 |
45 | ```c++
46 | #include
47 |
48 | using namespace std;
49 |
50 | int main()
51 | {
52 | int x = -4;
53 |
54 | if(x > 0)
55 | cout << "x pozitif" << endl;
56 | else if( x < 0)
57 | cout << "x negatif" << endl;
58 | else
59 | cout << "x = 0" << endl;
60 | }
61 | ```
62 |
63 | **Ekran Çıktısı:**
64 |
65 | ```
66 | x negatif
67 | ```
68 |
69 | ------------------------------------
70 |
71 | ### DÖngüler
72 |
73 | Arkadaşlar bazı programlarda birden fazla işlem yapmamız gerekir. Örneğin ekrana 1 ile 100 arasındaki sayıları
74 | yazdırmak istediğimizde tek tek **cout** ile yazdırmamız oldukça zordur. C++ ile döngü kavramını öğrenmeye **while**
75 | döngüsü ile başlayacağız.
76 |
77 | **While Döngüsü**
78 |
79 | ```c++
80 | #include
81 |
82 | using namespace std;
83 |
84 | int main()
85 | {
86 | int n = 10;
87 |
88 | while (n>0)
89 | {
90 | cout << n << ", ";
91 | --n; // n = n - 1 ifadesi ile aynı işi görmektedir.
92 | }
93 |
94 | cout << "Ucusss!!\n";
95 | }
96 | ```
97 |
98 | **Ekran Çıktısı**
99 |
100 | ```
101 | 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, Ucusss!!
102 | ```
103 |
104 | Yukarıda örnekte **n** değişkenine başlangıçta 10 sayısı atanmış. Ardından n değişkeni **sıfırdan** büyük
105 | olduğu sürece ilk olarak ekrana **n** değişkeninin değeri yazdırılmış sonra --n işlemine tabii tutulmuştur.
106 | Döngü sonlandıktan sonra yani **n** değişkeni **sıfıra** eşit oldukan sonra döngüden çıkılmış ve ekrana
107 | **Uçuşşş!!** yazdırılmıştır.
108 |
109 | **Do-While Döngüsü**
110 |
111 | ```c++
112 | #include
113 | #include
114 | using namespace std;
115 |
116 | int main ()
117 | {
118 | string str;
119 |
120 | do
121 | {
122 | cout << "Bir mesaj giriniz: ";
123 | getline (cin,str);
124 | cout << "Mesajiniz : " << str << '\n';
125 | }
126 | while (str != "hoscakal");
127 | }
128 | ```
129 |
130 | **Ekran Çıktısı**
131 |
132 | ```
133 | Bir mesaj giriniz: Merhaba Dünya
134 | Mesajiniz : Merhaba Dünya
135 | Bir mesaj giriniz: hoscakal
136 | Mesajiniz : hoscakal
137 | ```
138 |
139 | Bu döngüde **while döngüsü** ile belirtilen şart sağlandığı sürece **do** bloğunun içindeki
140 | komutlar çalıştırılır. Programa **hoscakal** kelimesi girildiğinde yani **str == hoscakal**
141 | olduğunda son kez mesajınız yazar ve program sonlandırılır.
142 |
143 | **For Döngüsü**
144 |
145 | ```c++
146 | #include
147 | using namespace std;
148 |
149 | int main ()
150 | {
151 | for (int n = 10; n > 0; n--)
152 | {
153 | cout << n << ", ";
154 | }
155 |
156 | cout << "Ucusss!!\n";
157 | }
158 | ```
159 |
160 | **Ekran Çıktısı:**
161 |
162 | ```
163 | 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, Ucusss!!
164 | ```
165 |
166 | Yani **while dönügü** ile yaptığımız şeyi biraz daha farklı bir yöntemle yaptık. Döngümüzde
167 | int n = 10 ifadesi **n** değişkeninin ilk değerini atadık. Ardından **sıfıra** eşit olana kadar n--
168 | işlemini yani **n** değişkeninin değerini 1 azaltma işlemini yaptık. Sonra ekrana yazdırdık.
169 |
170 | ```c++
171 | #include
172 | #include
173 |
174 | using namespace std;
175 |
176 | int main()
177 | {
178 | string str2 {"Merhaba"};
179 |
180 | for (char c : str2)
181 | {
182 | cout << "[" << c << "]";
183 | }
184 |
185 | cout << '\n';
186 | }
187 | ```
188 |
189 | **Ekran Çıktısı:**
190 |
191 | ```
192 | [M][e][r][h][a][b][a]
193 | ```
194 |
195 | Yukarıdaki kod parçasında for döngüsünü biraz daha efektif kullandık ve **str2** değişkenimizin harfleri
196 | bitene kadar döngümüz döndü ve ekrana bu çıktıyı verdi.
197 |
198 | **Break-Continue**
199 |
200 | ```c++
201 | #include
202 |
203 | using namespace std;
204 |
205 | int main()
206 | {
207 | for (int n = 10; n > 0; n--)
208 | {
209 | cout << n << ", ";
210 | if (n == 3)
211 | {
212 | cout << "Sayaç durdu" << endl;
213 | break;
214 | }
215 | }
216 | }
217 | ```
218 |
219 | **Ekran Çıktısı:**
220 |
221 | ```
222 | 10, 9, 8, 7, 6, 5, 4, 3, Sayaç durdu
223 | ```
224 |
225 | Bu örnekte **break** deyimini gördük. **break** belirtilen şart sağlandığı durumda
226 | (**n** değişkeninin 3 olması) döngüyü sonlandırır.
227 |
228 | ```c++
229 | #include
230 |
231 | using namespace std;
232 |
233 | int main()
234 | {
235 | for (int n = 10; n > 0; n--)
236 | {
237 | if (n == 5) continue;
238 | cout << n << ", ";
239 | }
240 | cout << "Ucusss!!\n";
241 | }
242 | ```
243 |
244 | **Ekran Çıktısı:**
245 |
246 | ```
247 | 10, 9, 8, 7, 6, 4, 3, 2, 1, Ucusss!!
248 | ```
249 |
250 | Burada ise **continue** deyimi **n** değişkeni 5 olduğu durumda devreye girdi
251 | ve 5 sayısını atlayıp döngüye devam etti. Gördüğünüz gibi ekran çıktısında 5
252 | sayısı bulunmamaktadır.
253 |
254 | **Switch Deyimi**
255 |
256 | ```c++
257 | #include
258 |
259 | using namespace std;
260 |
261 | int main()
262 | {
263 | int x = 2;
264 |
265 | switch (x)
266 | {
267 | case 1:
268 | case 2:
269 | case 3:
270 | cout << "x = 1, 2 ya da 3";
271 | break;
272 | default:
273 | cout << "x != 1, 2 ya da 3";
274 | }
275 | }
276 | ```
277 |
278 | **Ekran Çıktısı:**
279 |
280 | ```
281 | x = 1, 2 ya da 3
282 | ```
283 |
284 | Örnekten anlaşıldığı gibi x değerimiz **case 1,2,3** içine giriyorsa o bölümdeki
285 | komut çağırılıyor. Girmiyorsa **defaul** bölümündeki komut çağırılıyor.
--------------------------------------------------------------------------------
/orta_konular/overloads_templates.md:
--------------------------------------------------------------------------------
1 | ### Overloads ve Templates (Aşırı Yüklemeler ve Şablonlar)
2 |
3 | Fonksiyonları geçtiğimiz derste öğrendik. Peki biz iki tane aynı isimde fakat farklı tiplerde fonksiyonlar
4 | yazdığımızda ne olacak? Bunun cevabını **overloads** kısmında öğreneceğiz.
5 |
6 | ---------------------
7 |
8 | ### Overloaded Fonksiyonlar (Aşırı Yüklenmiş Fonksiyonlar)
9 |
10 | ```c++
11 | int overloaded(int a, int b)
12 | {
13 | return (a*b);
14 | }
15 |
16 | double overloaded(double a, double b)
17 | {
18 | return (a/b);
19 | }
20 |
21 | int main ()
22 | {
23 | int x=5,y=2;
24 | double n=5.0,m=2.0;
25 |
26 | cout << overloaded(x,y) << '\n';
27 | cout << overloaded(n,m) << '\n';
28 |
29 | return 0;
30 | }
31 | ```
32 |
33 | **Ekran Çıktısı:**
34 |
35 | ```
36 | 10
37 | 2.5
38 | ```
39 |
40 | Örnekte gördüğümüz gibi iki tane aynı isimde, farklı tipte fonksiyon var. **main**de çağırıldığında aldıkları
41 | parametre değerlerine göre program bir ayrım yapıyor. **double** tipindeki fonksiyonun çıktısı **double** tipinde,
42 | **int** tipindeki fonksiyonun çıktısı **int** tipindedir.
43 |
44 | ---------------------------
45 |
46 | ### Templates (Şablonlar)
47 |
48 | Fonksiyonların parametreleri farklı tiplerde ancak fonksiyon isimleri aynı olabilir bunu öğrendik. Ancak hem fonksiyon
49 | parametreleri hem isimleri de aynı tipte olabilir. Bunun için C++ dilinde **template**ler geliştirilmiştir. Örnek ile
50 | daha iyi anlamaya çalışalım.
51 |
52 | ```c++
53 | #include
54 |
55 | using namespace std;
56 |
57 | template
58 | T sum(T x, T y)
59 | {
60 | T result;
61 | result = x + y;
62 | return result;
63 | }
64 |
65 | int main(int argc, char const *argv[])
66 | {
67 |
68 | int a = 3, b = 2, c;
69 | double d = 7.12, e = 2.4, f;
70 |
71 | c = sum(a,b);
72 | f = sum(d,e);
73 |
74 | cout << c << endl << f << endl;
75 |
76 | return 0;
77 | }
78 | ```
79 |
80 | **Ekran Çıktısı:**
81 |
82 | ```
83 | 5
84 | 9.52
85 | ```
86 |
87 | Örneği inceleyelim. sum adında bir template fonksiyonumuz var. **sum** fonksiyonunun tipi ve alacağı parametrelerin
88 | tipi belli değil. **main** kısmında **double** ve **int** tipinde değişkenlerimiz var. **sum** fonksiyonu önce **int**
89 | değişkenlerini çağırıyor ardından **double** değişkenlerini çağırıyor. Böylece tipi belli olmayan fonksiyonumuz farklı
90 | tiplerde değişkenler ile işlem yapabiliyor.
--------------------------------------------------------------------------------
/Örnekler/arrays/array.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | int main()
6 | {
7 | int dizi[5] = {10, 20, 30, 40, 50};
8 | int dizi2[2] = {};
9 |
10 | cout << "Birinci dizinin 2. elemani: " << dizi[1] << '\n';
11 | cout << "Birinci dizinin 1. elemani: " << dizi[0] << '\n';
12 | cout << "Ikinci dizinin 2. elemani: " << dizi2[1] << '\n';
13 |
14 |
15 | int yeni_dizi [] = {16, 4, 32, 48, 120};
16 | int n, sonuc = 0;
17 |
18 | for ( n=0 ; n<5 ; ++n )
19 | {
20 | sonuc += foo[n];
21 | }
22 | cout << sonuc << endl;
23 |
24 | return 0;
25 | }
26 |
--------------------------------------------------------------------------------
/Örnekler/arrays/multiarray.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | void printarray (int arg[], int length) {
6 | for (int n=0; n
2 | #include
3 |
4 | using namespace std;
5 |
6 | int main ()
7 | {
8 | char question1[] = "Adın ne? ";
9 | string question2 = "Nerede yaşıyorsun? ";
10 | char answer1 [80];
11 | string answer2;
12 | cout << question1;
13 | cin >> answer1;
14 | cout << question2;
15 | cin >> answer2;
16 | cout << "Merhaba, " << answer1;
17 | cout << " senin şehrin " << answer2 << "!\n";
18 | return 0;
19 | }
20 |
--------------------------------------------------------------------------------
/Örnekler/class/dikdortgen.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | class Dikdortgen
6 | {
7 | public:
8 | int yukseklik, genislik, alan;
9 |
10 | void veriGir()
11 | {
12 | cout << "Yukseklik gir: ";
13 | cin >> yukseklik;
14 | cout << "Genislik gir : ";
15 | cin >> genislik;
16 | }
17 |
18 | void alanBul()
19 | {
20 | alan = genislik * yukseklik;
21 | cout << "Dikdortgenin alani: " << alan << endl;
22 | }
23 | };
24 |
25 | int main()
26 | {
27 | Dikdortgen dikd1;
28 |
29 | dikd1.veriGir();
30 | dikd1.alanBul();
31 | }
32 |
--------------------------------------------------------------------------------
/Örnekler/class/dort_islem/dort.cpp:
--------------------------------------------------------------------------------
1 | #include "dort.h"
2 | #include "iostream"
3 |
4 | using namespace std;
5 |
6 | void Dort::topla(int sayi1, int sayi2)
7 | {
8 | int toplam = sayi1 + sayi2;
9 |
10 | cout << "Toplam: " << toplam << endl;
11 | }
12 |
13 | void Dort::cikar(int sayi1, int sayi2)
14 | {
15 | int fark = sayi1 - sayi2;
16 |
17 | cout << "Fark: " << fark << endl;
18 | }
19 |
20 | void Dort::carp(int sayi1, int sayi2)
21 | {
22 | int carpim = sayi1 * sayi2;
23 |
24 | cout << "Carpim: " << carpim << endl;
25 | }
26 |
27 | void Dort::bol(int sayi1, int sayi2)
28 | {
29 | int bolum = sayi1 / sayi2;
30 |
31 | cout << "Bolum: " << bolum << endl;
32 | }
33 |
--------------------------------------------------------------------------------
/Örnekler/class/dort_islem/dort.h:
--------------------------------------------------------------------------------
1 | #ifndef DORT_H
2 | #define DORT_H
3 |
4 | class Dort
5 | {
6 | public:
7 | void topla(int, int);
8 | void carp(int, int);
9 | void cikar(int, int);
10 | void bol(int, int);
11 | };
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/Örnekler/class/dort_islem/main.cpp:
--------------------------------------------------------------------------------
1 | #include "dort.h"
2 | #include
3 |
4 | using namespace std;
5 |
6 | int main()
7 | {
8 | Dort islem; // Dort sınıfından islem adında nesne oluşturduk
9 |
10 | int secim, sayi1, sayi2;
11 |
12 | cout << "1-Toplama" << endl
13 | << "2-Cikarma" << endl
14 | << "3-Carpma" << endl
15 | << "4-Bolme" << endl
16 | << "5-Cikis" << endl;
17 |
18 | cin >> secim;
19 |
20 | cout << "Birinci sayiyi giriniz: ";
21 | cin >> sayi1;
22 | cout << "Ikinci sayiyi giriniz : ";
23 | cin >> sayi2;
24 |
25 | while(1)
26 | {
27 | if(secim == 1){
28 | islem.topla(sayi1, sayi2);
29 | break;
30 | }
31 | else if(secim == 2){
32 | islem.cikar(sayi1, sayi2);
33 | break;
34 | }
35 | else if(secim == 3){
36 | islem.carp(sayi1, sayi2);
37 | break;
38 | }
39 | else if(secim == 4){
40 | islem.bol(sayi1, sayi2);
41 | break;
42 | }
43 | else if(secim == 5){
44 | cout << "Cikis Yapiliyor..." << endl;
45 | break;
46 | }
47 | else{
48 | cout << "Hatali secim!" << endl;
49 | break;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Örnekler/class/header_files_example1/Dog.cpp:
--------------------------------------------------------------------------------
1 | #include "Dog.h"
2 | #include
3 |
4 | using namespace std;
5 |
6 | Dog::Dog()
7 | {
8 | cout << "Dog objesi olusturuldu" << endl;
9 | }
10 |
--------------------------------------------------------------------------------
/Örnekler/class/header_files_example1/Dog.h:
--------------------------------------------------------------------------------
1 | #ifndef DOG_H
2 | #define DOG_H
3 |
4 | class Dog
5 | {
6 | public:
7 | Dog();
8 |
9 | };
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/Örnekler/class/header_files_example1/Makefile:
--------------------------------------------------------------------------------
1 | build: main.cpp
2 | g++ -o program main.cpp Dog.h Dog.cpp
3 |
4 | run: program
5 | ./program
6 |
--------------------------------------------------------------------------------
/Örnekler/class/header_files_example1/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "Dog.h"
3 |
4 | using namespace std;
5 |
6 | int main()
7 | {
8 | Dog d;
9 |
10 | return 0;
11 | }
12 |
--------------------------------------------------------------------------------
/Örnekler/class/header_files_example2/Makefile:
--------------------------------------------------------------------------------
1 | build: main.cpp
2 | g++ main.cpp Person.h Person.cpp
3 |
4 | run: a.out
5 | ./a.out
6 |
--------------------------------------------------------------------------------
/Örnekler/class/header_files_example2/Person.cpp:
--------------------------------------------------------------------------------
1 | #include "Person.h"
2 |
3 | Person::Person()
4 | {
5 | newHeight = 0;
6 | newWeight = 0.0;
7 | }
8 |
9 | Person::Person(string name, int height, double weight)
10 | {
11 | newName = name;
12 | newHeight = height;
13 | newWeight = weight;
14 | }
15 |
16 | Person::~Person()
17 | {
18 |
19 | }
20 |
21 | string Person:: getName() const
22 | {
23 |
24 | return newName;
25 | }
26 |
27 | int Person::getHeight() const
28 | {
29 |
30 | return newHeight;
31 | }
32 |
33 | double Person::getWeight() const
34 | {
35 |
36 | return newWeight;
37 | }
38 |
39 | void Person::setName(string name)
40 | {
41 | newName = name;
42 | }
43 |
44 | void Person::setHeight(int height)
45 | {
46 | newHeight = height;
47 | }
48 |
49 | void Person::setWeight(double weight)
50 | {
51 | newWeight = weight;
52 | }
53 |
54 | double Person::calculateBMI()
55 | {
56 |
57 | return ((newWeight * 703) / (newHeight * newHeight));
58 | }
59 |
--------------------------------------------------------------------------------
/Örnekler/class/header_files_example2/Person.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using namespace std;
5 |
6 | #ifndef PERSON_H
7 | #define PERSON_H
8 |
9 | class Person
10 | {
11 | public:
12 | //Default Constructor
13 | Person();
14 |
15 | //Overload Constructor
16 | Person(string, int, double);
17 |
18 | //Destructor
19 | ~Person();
20 |
21 | //Accessor Functions
22 | string getName() const;
23 |
24 | int getHeight() const;
25 |
26 | double getWeight() const;
27 |
28 | void setName(string);
29 |
30 | void setHeight(int);
31 |
32 | void setWeight(double);
33 |
34 | double calculateBMI();
35 |
36 | private:
37 | string newName;
38 | int newHeight;
39 | double newWeight;
40 |
41 | };
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/Örnekler/class/header_files_example2/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "Person.h"
4 |
5 | using namespace std;
6 |
7 | int main()
8 | {
9 | string name;
10 | int height;
11 | double weight;
12 |
13 | cout << "Ziyaretcinin ismini giriniz: ";
14 | cin >> name;
15 |
16 | cout << "Ziyaretcinin boyunu giriniz (cm biciminde): ";
17 | cin >> height;
18 |
19 | cout << "Ziyaretcinin kilosunu giriniz (kg biciminde): ";
20 | cin >> weight;
21 |
22 | /*
23 | Person person1(name, height, weight);
24 |
25 | cout << endl <<
26 | "Ziyaretcinin Ismi : " << person1.getName() << endl <<
27 | "Ziyaretcinin Boyu : " << person1.getHeight() << endl <<
28 | "Ziyaretcinin Kilosu: " << person1.getWeight() << endl;
29 | */
30 |
31 | Person person2;
32 |
33 | person2.setName(name);
34 | person2.setHeight(height);
35 | person2.setWeight(weight);
36 |
37 | cout << endl <<
38 | "Ziyaretcinin Ismi : " << person2.getName() << endl <<
39 | "Ziyaretcinin Boyu : " << person2.getHeight() << endl <<
40 | "Ziyaretcinin Kilosu: " << person2.getWeight() << endl <<
41 | "BMI : " << person2.calculateBMI() << endl;
42 |
43 |
44 | return 0;
45 | }
46 |
--------------------------------------------------------------------------------
/Örnekler/class/ornek.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | class Sinif
6 | {
7 | private:
8 | int x, y;
9 |
10 | public:
11 | void get_xy(int a, int b)
12 | {
13 | x = a;
14 | y = b;
15 | }
16 |
17 | void xy_yazdir()
18 | {
19 | cout << "x = " << x << endl;
20 | cout << "y = " << y << endl;
21 | }
22 | };
23 |
24 | int main(int argc, char *argv[])
25 | {
26 |
27 | int x, y;
28 | Sinif nesne1;
29 |
30 |
31 | cout << "x: ";
32 | cin >> x;
33 | cout << "y: ";
34 | cin >> y;
35 |
36 | nesne1.get_xy(x, y);
37 |
38 | nesne1.xy_yazdir();
39 |
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/Örnekler/dynamic_memory/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using namespace std;
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | int a;
9 | int * p;
10 | int i;
11 |
12 | cout << "Dizinin boyutunu giriniz: ";
13 | cin >> a;
14 |
15 | p = new int[a];
16 |
17 | for(i = 0; i < a; i++)
18 | {
19 | p[i] = i * i;
20 | }
21 |
22 | for(i = 0; i < a; i++)
23 | {
24 | cout << "p[" << i << "] = " << p[i] << endl;
25 | }
26 |
27 | delete[] p;
28 |
29 | return 0;
30 | }
31 |
--------------------------------------------------------------------------------
/Örnekler/functions/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | void printmessage();
6 | int toplama(int, int);
7 | void ciftle(int&, int&, int&);
8 | void cift(int, int, int);
9 | long factorial(long);
10 |
11 | int main()
12 | {
13 | int a;
14 | int x=1, y=3, z=7;
15 | long number = 5;
16 |
17 | a = toplama(4, 3);
18 |
19 | cout << "Toplam: " << a << endl;
20 |
21 | printmessage();
22 |
23 | cift(x, y, z);
24 |
25 | cout << "x = " << x << " y = " << y << " z = " << z << endl;
26 |
27 | ciftle(x, y, z);
28 |
29 | cout << "x = " << x << " y = " << y << " z = " << z << endl;
30 |
31 | cout << number << "! = " << factorial(number) << endl;
32 |
33 | return 0;
34 | }
35 |
36 | void printmessage()
37 | {
38 | cout << "Geriye bir deger donmuyor!" << endl;
39 | }
40 |
41 | int toplama(int sayi1, int sayi2)
42 | {
43 | int toplam;
44 | toplam = sayi1 + sayi2;
45 | return toplam;
46 | }
47 |
48 | void ciftle(int& a, int& b, int& c)
49 | {
50 | a*=2;
51 | b*=2;
52 | c*=2;
53 | }
54 |
55 | void cift(int a, int b, int c)
56 | {
57 | a *= 2;
58 | b *= 2;
59 | c *= 2;
60 | }
61 |
62 | long factorial(long a)
63 | {
64 | if (a > 1)
65 | return (a * factorial(a-1));
66 | else
67 | return 1;
68 | }
--------------------------------------------------------------------------------
/Örnekler/helloCpp/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 |
6 | int main(int argc, char const *argv[])
7 | {
8 | cout << "Hello C++" << endl;
9 |
10 | return 0;
11 | }
12 |
--------------------------------------------------------------------------------
/Örnekler/if-else/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | int main()
6 | {
7 | int x = 100;
8 |
9 | if(x == 100)
10 | cout << "x = 100" << endl;
11 |
12 | if(x == 100)
13 | {
14 | cout << "x = ";
15 | cout << x << endl;
16 | }
17 | }
--------------------------------------------------------------------------------
/Örnekler/input_output/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | using namespace std;
5 |
6 | int main ()
7 | {
8 | string mesaj;
9 | string sozel;
10 | float fiyat;
11 | int miktar;
12 |
13 | cout << "Mesajiniz: ";
14 | getline(cin, mesaj);
15 | cout << mesaj << endl;
16 |
17 | cout << "Kalem fiyatini giriniz: ";
18 | getline(cin, sozel);
19 | stringstream(sozel) >> fiyat;
20 |
21 | cout << "Alacaginiz kalem miktarini giriniz: ";
22 | getline(cin, sozel);
23 | stringstream(sozel) >> miktar;
24 |
25 | cout << "Toplam Fiyat: " << miktar * fiyat << endl;
26 | }
--------------------------------------------------------------------------------
/Örnekler/overloaded/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | int func(int, int);
6 | double func(double, double);
7 |
8 | int main(int argc, char const *argv[])
9 | {
10 | int x = 3, y = 5;
11 | double n = 3.4, m = 1.47;
12 |
13 | cout << func (x,y) << endl;
14 | cout << func (n,m) << endl;
15 |
16 | return 0;
17 | }
18 |
19 | int func(int x, int y)
20 | {
21 | return x + y;
22 | }
23 |
24 | double func(double a, double b)
25 | {
26 | return a / b;
27 | }
--------------------------------------------------------------------------------
/Örnekler/pointers/call_by_referance.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | void Arttir(int *);
6 |
7 | int main()
8 | {
9 | int sayi = 12;
10 |
11 | cout << "Fonksiyondan once : " << sayi << endl;
12 | Arttir(&sayi);
13 | cout << "Fonksiyondan sonra: " << sayi << endl;
14 | }
15 |
16 | void Arttir(int *a)
17 | {
18 | (*a)++;
19 | }
20 |
--------------------------------------------------------------------------------
/Örnekler/pointers/call_by_referance2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | int Degistir(int *, int *);
6 |
7 | int main()
8 | {
9 | int sayi1 = 3;
10 | int sayi2 = 5;
11 |
12 | int sonuc = Degistir(&sayi1, &sayi2);
13 | cout << "Sonuc: " << sonuc << endl;
14 | }
15 |
16 | int Degistir(int *sayi1, int *sayi2)
17 | {
18 | cout << "ilk sayi1 : " << sayi1 << endl;
19 | cout << "ilk sayi2 : " << sayi2 << endl;
20 | cout << "ilk *sayi1: " << *sayi1 << endl;
21 | cout << "ilk *sayi2: " << *sayi2 << endl;
22 |
23 | *sayi1 = 20;
24 | *sayi2 = 40;
25 |
26 | cout << "son sayi1 : " << sayi1 << endl;
27 | cout << "son sayi2 : " << sayi2 << endl;
28 | cout << "son *sayi1: " << *sayi1 << endl;
29 | cout << "son *sayi2: " << *sayi2 << endl;
30 |
31 | return *sayi1 + *sayi2;
32 | }
33 |
--------------------------------------------------------------------------------
/Örnekler/pointers/pointer1.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | int main()
6 | {
7 | int a = 12;
8 |
9 | int* p = &a;
10 |
11 | cout << "p : " << p << endl;
12 | cout << "&a : " << &a << endl;
13 | cout << "*p : " << *p << endl;
14 | cout << "a : " << a << endl;
15 |
16 | // Yeni değer atanıyor. a = 25
17 |
18 | *p = 25;
19 |
20 | cout << "p : " << p << endl;
21 | cout << "&a : " << &a << endl;
22 | cout << "*p : " << *p << endl;
23 | cout << "a : " << a << endl;
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/Örnekler/pointers/pointer2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | int* genislet(int *, int, int);
6 |
7 | int* kucult(int*, int);
8 |
9 | int main()
10 | {
11 | int *p = new int[5];
12 |
13 | for(int i = 0; i < 5; i++)
14 | {
15 | p[i] = i;
16 |
17 | cout << "Eski Alan Deger: " << p[i] << endl;
18 | cout << "Eski Alan Adres: " << &p[i] << endl;
19 | }
20 |
21 | p = genislet(p,5,5);
22 |
23 | for(int i = 5; i < 10; i++)
24 | {
25 | p[i] = i;
26 |
27 | cout << "Yeni Alan Deger: " << p[i] << endl;
28 | cout << "Yeni Alan Adres: " << &p[i] << endl;
29 | }
30 |
31 | p = kucult(p, 2);
32 |
33 | for(int i = 0; i < 2; i++)
34 | {
35 | p[i] = i;
36 |
37 | cout << "Kucuk Alan Deger: " << p[i] << endl;
38 | cout << "Kucuk Alan Adres: " << &p[i] << endl;
39 | }
40 | }
41 |
42 | int* genislet(int *eskiAlan, int eskiBoyut, int eklenecek)
43 | {
44 | int *yeniAlan = new int[eskiBoyut + eklenecek];
45 |
46 | for(int i = 0; i < eskiBoyut; i++)
47 | yeniAlan[i] = eskiAlan[i];
48 |
49 | delete [] eskiAlan;
50 |
51 | return yeniAlan;
52 | }
53 |
54 | int* kucult(int *eskiAlan, int tasinacak)
55 | {
56 | int *yeni = new int[tasinacak];
57 |
58 | for(int i = 0; i < tasinacak; i++)
59 | yeni[i] = eskiAlan[i];
60 |
61 | delete [] eskiAlan;
62 |
63 | return yeni;
64 | }
65 |
--------------------------------------------------------------------------------
/Örnekler/shapes/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using namespace std;
5 |
6 | void draw(int, int);
7 |
8 | int main(int argc, char const *argv[])
9 | {
10 |
11 | int kenar1, kenar2;
12 |
13 | cout << "1. Kenari giriniz: ";
14 | cin >> kenar1;
15 | cout << "2. Kenari giriniz: ";
16 | cin >> kenar2;
17 |
18 | draw(kenar1, kenar2);
19 |
20 | cout << endl;
21 |
22 | return 0;
23 | }
24 |
25 | void draw(int kenar1, int kenar2)
26 | {
27 |
28 | for(int i = 1; i <= kenar1; i++)
29 | cout << "*";
30 | cout << endl;
31 |
32 | for(int j = 1; j < kenar2 - 1; j++)
33 | cout << "*" << string(kenar1 - 2, ' ') << "*" << endl;
34 |
35 | for(int k = 1; k <= kenar1; k++)
36 | cout << "*";
37 | cout << endl;
38 | }
39 |
--------------------------------------------------------------------------------
/Örnekler/switch/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 |
6 | int main()
7 | {
8 | int x = 2;
9 |
10 | switch (x)
11 | {
12 | case 1:
13 | case 2:
14 | case 3:
15 | cout << "x = 1, 2 ya da 3";
16 | break;
17 | default:
18 | cout << "x != 1, 2 ya da 3";
19 | }
20 | }
--------------------------------------------------------------------------------
/Örnekler/templates/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | template
6 | T sum(T x, T y)
7 | {
8 | T result;
9 | result = x + y;
10 | return result;
11 | }
12 |
13 | int main(int argc, char const *argv[])
14 | {
15 |
16 | int a = 3, b = 2, c;
17 | double d = 7.12, e = 2.4, f;
18 |
19 | c = sum(a,b);
20 | f = sum(d,e);
21 |
22 | cout << c << endl << f << endl;
23 |
24 | return 0;
25 | }
26 |
--------------------------------------------------------------------------------
/Örnekler/tuple/tuple.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using namespace std;
6 |
7 | tuple returnTwoValue(){
8 |
9 | int num1 = 10;
10 | double num2 = 20;
11 |
12 | return make_tuple(num1, num2);
13 | }
14 |
15 | int main(){
16 | auto t = returnTwoValue();
17 |
18 | cout << get<0>(t) << endl << get<1>(t) << endl;
19 | }
--------------------------------------------------------------------------------
/Örnekler/vector/a.out:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilteriskeskin/cpp_ornekler/2ff964845ec7244c39fa926477b7aa1e63f463b1/Örnekler/vector/a.out
--------------------------------------------------------------------------------
/Örnekler/vector/vector1.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using namespace std;
5 |
6 | int main()
7 | {
8 | vector sayiVektor;
9 |
10 | cout << "Ilk boyut : " << sayiVektor.size() << endl;
11 |
12 | sayiVektor.push_back(1);
13 |
14 | cout << "Yeni Boyut: " << sayiVektor.size() << endl;
15 |
16 | cout << "Vektorun 0. elemani: " << sayiVektor[0] << endl;
17 |
18 | sayiVektor.push_back(-1);
19 | cout << "Yeni Boyut: " << sayiVektor.size() << endl;
20 | cout << "Vektorun 1. elemani: " << sayiVektor[1] << endl;
21 |
22 | return 0;
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/Örnekler/vector/vector2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using namespace std;
5 |
6 | int main()
7 | {
8 | vector sayiVektor(10);
9 | for(int i = 0; i < 10; i++)
10 | cout << sayiVektor[i] << " ";
11 | cout << endl;
12 |
13 | cout << "--------------------------------" << endl;
14 |
15 | vector sayiVektor2(10, -2);
16 | for(int i = 0; i < 10; i++)
17 | cout << sayiVektor2[i] << " ";
18 | cout << endl;
19 |
20 | cout << "--------------------------------" << endl;
21 |
22 | vector sayiVektor3;
23 | sayiVektor3.assign(5,23);
24 | for(int i = 0; i < 5; i++)
25 | cout << sayiVektor3[i] << " ";
26 | cout << endl;
27 |
28 | cout << "--------------------------------" << endl;
29 |
30 | int a = sayiVektor3.back();
31 | cout << a << endl;
32 |
33 | return 0;
34 | }
35 |
--------------------------------------------------------------------------------
/Örnekler/vector/vector3.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using namespace std;
5 |
6 | int main()
7 | {
8 | vector sayiVektor;
9 | float toplam = 0, c, sayi = 0;
10 |
11 | while(sayi != -1)
12 | {
13 | cout << "Bir sayi girin, cikis icin -1: ";
14 | cin >> sayi;
15 | if(sayi == -1)
16 | continue;
17 | else
18 | sayiVektor.push_back(sayi);
19 | }
20 |
21 | while(!sayiVektor.empty())
22 | {
23 | c = sayiVektor.back();
24 | toplam += c;
25 | sayiVektor.pop_back();
26 | }
27 | cout << "Girilen sayilarin toplami: " << toplam << endl;
28 |
29 | return 0;
30 | }
31 |
--------------------------------------------------------------------------------
/Örnekler/while-for/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using namespace std;
4 |
5 | int main()
6 | {
7 | int n = 10;
8 | string str;
9 | string str2 {"Merhaba!"};
10 | int x = 1;
11 |
12 | while (n>0)
13 | {
14 | cout << n << ", ";
15 | --n;
16 | }
17 |
18 | cout << "Ucusss!!\n";
19 |
20 | do
21 | {
22 | cout << "Bir mesaj giriniz: ";
23 | getline (cin,str);
24 | cout << "Mesajiniz : " << str << '\n';
25 | }
26 | while (str != "hoscakal");
27 |
28 | for (int n=10; n>0; n--)
29 | {
30 | cout << n << ", ";
31 | }
32 |
33 | cout << "Ucusss!!\n";
34 |
35 | for (char c : str2)
36 | {
37 | cout << "[" << c << "]";
38 | }
39 |
40 | cout << '\n';
41 |
42 | for (int n=10; n>0; n--)
43 | {
44 | cout << n << ", ";
45 | if (n==3)
46 | {
47 | cout << "Sayaç durdu" << endl;
48 | break;
49 | }
50 | }
51 |
52 | for (int n = 10; n > 0; n--)
53 | {
54 | if (n == 5) continue;
55 | cout << n << ", ";
56 | }
57 | cout << "Ucusss!!\n";
58 | }
--------------------------------------------------------------------------------