Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first...

17
program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second number: '); readln(second_num); total := first_num + second_num; write('Total: ',total); end. SPOT THE BUG No variable declarations

Transcript of Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first...

Page 1: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUG

No variable declarations

Page 2: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integertotal : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUG; No semi colon

Page 3: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUG

{Missing curly bracket

Page 4: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(first_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUG

Incorrect variable used

Page 5: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite(Enter first number: );readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUGNo quotes around text

Page 6: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end

SPOT THE BUG

. Missing full stop

Page 7: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',first_num);

end.

SPOT THE BUG

Incorrect variable used

Page 8: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ' total);

end.

SPOT THE BUG

,Missing comma

Page 9: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integersecond_num : integertotal : integer

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUG

;; Missing semi colons;

Page 10: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;secon_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUGVariable names inconsistent

Page 11: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readl(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUGKeyword not correct

Page 12: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

startwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUGIncorrect keyword

Page 13: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total := firstnum + second_num;write('Total: ',total);

end.

SPOT THE BUG2 errors

Page 14: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ')readln(first_num);write('Enter second number: ')readln(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUG2 errors

Page 15: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;var

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readln(second_num);total = first_num / second_num;write('Total: ',total);

end.

SPOT THE BUG2 errors

Page 16: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

program add;{program to add 2 numbers and output the result}uses wincrt;va

first_num : integer;second_num : integer;total : integer;

beginwrite('Enter first number: ');readln(first_num);write('Enter second number: ');readl(second_num);total := first_num + second_num;write('Total: ',total);

end.

SPOT THE BUG2 errors

Page 17: Program add; {program to add 2 numbers and output the result} uses wincrt; begin write('Enter first number: '); readln(first_num); write('Enter second.

That’s all folks!