24
Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

Embed Size (px)

Citation preview

Page 1: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

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 ?

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 ?

How to make an Algorithm ?

• Flowcharts

• Pseudocodes

Page 4: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

Flowcharts

Page 5: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

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 ?

• Sequence

• Selection

• Loop

Types of Flowcharts

Page 7: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

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 ?

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 ?

• 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 ?

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 ?

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 ?

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 ?

Standart Input / Output Functions

• Printf

• Scanf

Page 14: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

Printf

1)Single Text;

• printf("Hello World !");

Page 15: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

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 ?

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 ?

#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 ?

Scanf

• scanf("%Conversion_specifier",&Variable _name);

Page 19: Algorithm, is a work plan that shows the sections of a duty. What is Algorithm ?

#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 ?

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 ?

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 ?

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 ?

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 ?

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?