Vous êtes sur la page 1sur 6

Algorithm - Program logic written as statements - Can be written in simple English - Algorithm must be written before doing the

program

- Algorithm is language independent - Algorithm is machine independent

Algorithm to ADD 2 integers - Take value of first number - Store it in A - Take value of Second number - Store it in B - Add A and B - Store the added result in C - Display the value of C

Algorithm to Swap 2 numbers using a third variable Take 2 numbers from user and store it in A and B Lets take another variable C C=A A=B B=C Now display the values of A and B

Algorithm to Swap 2 numbers without using a third variable Take 2 numbers from user and store it in A and B A=A+B B=A-B A=A-B Now display the values of A and B

Vous aimerez peut-être aussi