![Page 1: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/1.jpg)
Algorithm, is a work plan that shows the sections of a duty.
What is Algorithm ?
![Page 2: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/2.jpg)
Example • Join Hacettepe Robotics Community.• Study hard.• Join Robot Projects.• Graduate from Hacettepe.• Find a Job with high salary.• Enjoy ! ☻
![Page 3: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/3.jpg)
How to make an Algorithm ?
• Flowcharts
• Pseudocodes
![Page 4: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/4.jpg)
Flowcharts
![Page 5: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/5.jpg)
Start
Tap Temperature
Temp.<25 ?
Print ‘Cold’.Print ‘hot’.
End
YesNo
![Page 6: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/6.jpg)
• Sequence
• Selection
• Loop
Types of Flowcharts
![Page 7: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/7.jpg)
Start
End
Process
Process
Process
Start Start
Decision
Process
End
Decision
Process
Process
End
Sequence Selection Loop
![Page 8: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/8.jpg)
Pseudocodes
• Have a usage like routine speaking.
• No syntax.
• Aims to understand how program works.
![Page 9: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/9.jpg)
• 1 if
• 2 students grade > 60
• 3 print ‘PASSED’
• 4 else
• 5 print ‘FAILED’
Example
![Page 10: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/10.jpg)
Introduction to C Programming• Standart libraries
• Standart input/output functions
• Data types
• Variable declarations
• Operators
![Page 11: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/11.jpg)
Standart Libraries
• Stdio.h ( Standart input/output) :• Defines variable types• Various functions for performing input / output
• Stdlib.h ( Standart Library) :• Various functions for performing general functions
![Page 12: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/12.jpg)
Standart Libraries
• Define Library;
• #include<stdio.h>
• #include<stdlib.h>
![Page 13: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/13.jpg)
Standart Input / Output Functions
• Printf
• Scanf
![Page 14: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/14.jpg)
Printf
1)Single Text;
• printf("Hello World !");
![Page 15: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/15.jpg)
Printf
2)Control Characters;
Character Meaning
\n New line
\a Alert
\t TAB
![Page 16: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/16.jpg)
Printf
Conversion Specifier Character
Meaning Data Type
%c Single character Char
%s String Char
%d Integer İnt
%f Reel number float
%lf Double double
3)Conversion Specifier(Place Holder);
![Page 17: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/17.jpg)
#include <stdio.h>int main(){printf("Welcome to Hacettepe Robotics Community!\n");}
![Page 18: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/18.jpg)
Scanf
• scanf("%Conversion_specifier",&Variable _name);
![Page 19: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/19.jpg)
#include <stdio.h>int main(){int x,y,sum;printf("Insert x and y>> !\n"); scanf("%d%d",&x,&y);sum=x+y; printf("Sum is >> %d",sum); }
![Page 20: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/20.jpg)
Data Type Information Size kept in the memory
Char Single character or string 1
int Integer 2
Float Fractional numbers (7 digits) 4
Double Fractional numbers (15 digits) 8
![Page 21: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/21.jpg)
Data Type
char %c ve %s
int %d
float %f
double %lf
For a single character
For a string
Conversion Specifier
![Page 22: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/22.jpg)
Aritmetic OperatorsOperator Information Example Meaning
+ Addition x + y Sum of x and y
- Subtraction x – y Difference of x and y
* Multiplication x * y Product of x and y
/ Division x / y Quotient of x and y
% Mod x % y Remainder of x/y
![Page 23: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/23.jpg)
Assignment OperatorsOperator Information Example Meaning
= Assignment x=7; x=7;
+= Assignment with additon x+=3; x=x+3;
-= Assignment with subtraction x-=4; x=x-4;
*= Assignment with multiplication x*=5; x=x*5;
/= Assignment with division x/=3; x=x/3;
%= Assignment of remainder from a division x%=9; x=x%9;
++ One increasing x++; or ++x; x=x+1;
-- One decreasing x--; or --x; x=x-1;
![Page 24: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?](https://reader036.vdocuments.site/reader036/viewer/2022062423/5697bfc31a28abf838ca5256/html5/thumbnails/24.jpg)
Compare OperatorsOperator Information Example Meaning
> Greater than x>y Is x, greater than y ?
< Less than x<y Is x, less than y ?
== Equal x==y Is x, equal to y ?
>= Greater than or equal to x>=y Is x, greater than or equal to y ?
<= Less than or equal to x<=y Is x, less than or equal to y ?
!= Not equal x!=y Is x, not equal to y ?
&& Logical and x>2 && x<y Is x, greater than 2 and less than y?
|| Logical or x>2 || x<y Is x, greater than 2 or less than y?