.rh-w{background:#fff;border:1px solid #E3E8F0;border-radius:16px;padding:20px;margin:24px 0}.rh-w h3{margin:0 0 14px;font-size:20px}.rh-w .row{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:14px 0}.rh-w button,.rh-w input{font:inherit;font-size:15px;border:1px solid #D6DCE7;border-radius:10px;padding:9px 14px;background:#fff;color:#12203F}.rh-w button{font-weight:700;cursor:pointer}.rh-w button:hover{background:#F4F7FB}.rh-w button:disabled{opacity:.45;cursor:default}.rh-w code{font-family:monospace;font-weight:700}.rh-q{border-top:1px solid #E3E8F0;padding-top:14px;margin-top:14px}.rh-q label{display:block;margin-bottom:6px}.rh-q input{width:240px}.rh-q .fb{font-weight:700;margin-left:8px}.rh-q .fb.ok{color:#0B6F3C}.rh-q .fb.no{color:#B42318}.rh-w details{margin-top:10px}.rh-w summary{cursor:pointer;font-weight:700;color:#0B7C86}.fde-grid{display:grid;grid-template-columns:1.3fr 1fr;gap:16px}.fde-regs{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:8px}.fde-reg{border:1px solid #D6DCE7;border-radius:10px;padding:8px 10px;transition:background .3s,border-color .3s}.fde-reg small{display:block;font-size:12px;color:#4A5878;font-weight:700}.fde-reg b{font-family:monospace;font-size:18px}.fde-reg.hl{background:#E6F7F8;border-color:#0B7C86}.fde-mem{width:100%;border-collapse:collapse;font-family:monospace;font-size:14px}.fde-mem td,.fde-mem th{border:1px solid #E3E8F0;padding:5px 8px;text-align:left}.fde-mem th{background:#12203F;color:#fff;font-family:inherit}.fde-mem tr.hl td{background:#FFF4D6}.fde-msg{background:#F4F7FB;border-radius:10px;padding:12px 16px;margin-top:12px;min-height:72px}.fde-msg strong{color:#0B7C86}.rh-tq{border:1px solid #E3E8F0;border-radius:12px;padding:12px 16px;margin:0 0 12px}.rh-tq legend{padding:0 6px}.rh-tq label{display:block;padding:6px 4px;cursor:pointer}.rh-tq.ok{border-color:#0B6F3C;background:#F0FAF4}.rh-tq.no{border-color:#B42318;background:#FEF3F2}.rh-tq .ex{margin:6px 0 0;font-size:14px;color:#4A5878}.rh-grade{display:none;background:#12203F;color:#fff;border-radius:14px;padding:20px 24px;margin-top:16px}.rh-grade .g{font-size:44px;font-weight:800;color:#3FD0DB;line-height:1}.rh-grade p{margin:6px 0}@media(max-width:700px){.fde-grid{grid-template-columns:1fr}}

Paper 2 ends with a 15-mark programming scenario. Everything here, plus the runner below, helps you write it confidently.

▶ Watch: IGCSE 0478: Programming concepts (10 min)

(function(){var b=document.getElementById(“rhyt-smPYRJbj9zE”);if(!b)return;b.addEventListener(“click”,function(){var f=document.createElement(“iframe”);f.src=”https://www.youtube-nocookie.com/embed/”+b.dataset.id+”?autoplay=1″;f.title=b.getAttribute(“aria-label”);f.setAttribute(“allow”,”accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture”);f.setAttribute(“allowfullscreen”,””);f.style.cssText=”position:absolute;inset:0;width:100%;height:100%;border:0″;b.replaceWith(f);});})(); {“@context”:”https://schema.org”,”@type”:”VideoObject”,”name”:”Programming Concepts | IGCSE Computer Science 0478 Paper 2 Full Lesson (Pseudocode Explained)”,”description”:”The full lesson on Cambridge IGCSE Computer Science 0478 Unit 8 Programming for Paper 2: variables and constants, data types, operators, selection (IF and CASE), iteration (FOR, WHILE, REPEAT), string handling and more, with pseudocode explained.”,”thumbnailUrl”:”https://i.ytimg.com/vi/smPYRJbj9zE/hqdefault.jpg”,”uploadDate”:”2026-11-27″,”duration”:”PT10M18S”,”embedUrl”:”https://www.youtube-nocookie.com/embed/smPYRJbj9zE”,”contentUrl”:”https://www.youtube.com/watch?v=smPYRJbj9zE”,”publisher”:{“@type”:”Organization”,”name”:”Revision Hub”,”url”:”https://revisionhub.online/”}}

▶ Lesson slides: swipe or tap

(function(){var f=document.getElementById(“rhs-ig8”);if(!f)return;var h=null;function go(){if(h===null)return;if(!f.srcdoc)f.srcdoc=h;}var b=Uint8Array.from(atob(“H4sIAO3qA2sC/7Vb63LiSJb+z1Pk4Ng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(new Blob([b]).stream().pipeThrough(new DecompressionStream(“gzip”))).text().then(function(t){h=t;if(“IntersectionObserver” in window){var o=new IntersectionObserver(function(e){if(e[0].isIntersecting){go();o.disconnect();}},{rootMargin:”400px”});o.observe(f);}else{go();}});})();

▶ Watch first: Programming concepts in 4 minutes

document.querySelectorAll(‘.rh-yt’).forEach(function(b){b.addEventListener(‘click’,function(){var f=document.createElement(‘iframe’);f.src=’https://www.youtube-nocookie.com/embed/’+b.dataset.id+’?autoplay=1′;f.title=b.getAttribute(‘aria-label’);f.setAttribute(‘allow’,’accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture’);f.setAttribute(‘allowfullscreen’,”);f.style.cssText=’position:absolute;inset:0;width:100%;height:100%;border:0′;b.replaceWith(f);});}); {“@context”:”https://schema.org”,”@type”:”VideoObject”,”name”:”Programming Concepts | IGCSE Computer Science 0478 (Unit 8)”,”description”:”Variables, constants, data types, selection, iteration, operators, string handling, procedures and functions, arrays and file handling in Cambridge pseudocode for IGCSE Computer Science 0478.”,”thumbnailUrl”:”https://i.ytimg.com/vi/msGMSrJ5oqU/hqdefault.jpg”,”uploadDate”:”2026-11-22″,”duration”:”PT3M59S”,”embedUrl”:”https://www.youtube-nocookie.com/embed/msGMSrJ5oqU”,”contentUrl”:”https://www.youtube.com/watch?v=msGMSrJ5oqU”,”publisher”:{“@type”:”Organization”,”name”:”Revision Hub”,”url”:”https://revisionhub.online/”}}
Free printable worksheet
Original exam-style questions (32 marks) with a full mark scheme. Use it for homework, revision or a quick test.
Download PDF

1. Variables and constants

A variable is a named memory location whose value can change while the program runs. A constant is a named value that cannot change, which makes programs easier to update and read.

DECLARE PlayerName : STRING
DECLARE Score : INTEGER
CONSTANT MaxLives ← 3
PlayerName ← "Ela"
Score ← 0

2. Data types

Data typeStoresExample
INTEGERWhole numbersScore ← 42
REALNumbers with a decimal partPrice ← 3.99
CHARA single characterGrade ← ‘A’
STRINGText (zero or more characters)Name ← “Ela”
BOOLEANTRUE or FALSEGameOver ← FALSE

3. Input and output

Use OUTPUT to display values and prompts, and INPUT to read a value from the user into a variable.

OUTPUT "Enter your age"
INPUT Age
OUTPUT "In 5 years you will be ", Age + 5

4. Sequence and selection

Sequence means statements run one after another in order. Selection chooses which statements run, using IF or CASE. The example below also shows nested selection: an IF inside another IF.

IF Temperature > 30
  THEN
    OUTPUT "Hot"
  ELSE
    IF Temperature > 15
      THEN
        OUTPUT "Warm"
      ELSE
        OUTPUT "Cold"
    ENDIF
ENDIF

CASE OF Choice
  1 : OUTPUT "Play"
  2 : OUTPUT "Settings"
  3 : OUTPUT "Quit"
  OTHERWISE OUTPUT "Invalid choice"
ENDCASE

5. Iteration

LoopPseudocodeWhen to use it
Count-controlledFOR … TO … NEXTWhen you know how many times to repeat
Pre-conditionWHILE … DO … ENDWHILEWhen the condition is checked before each repeat; it may run zero times
Post-conditionREPEAT … UNTILWhen the code must run at least once, e.g. validating input

Totalling (Total ← Total + Value) and counting (Count ← Count + 1) are done inside loops; see Unit 7 for full examples.

6. String handling

Word ← "Computer"
OUTPUT LENGTH(Word)              // 8
OUTPUT SUBSTRING(Word, 1, 4)     // "Comp"
OUTPUT UCASE(Word)               // "COMPUTER"
OUTPUT LCASE(Word)               // "computer"

In Cambridge pseudocode the first character is at position 1. Some programming languages start at 0.

7. Operators

TypeOperators
Arithmetic+ − * / ^ (power), MOD (remainder), DIV (whole-number division)
Relational= < <= > >= <> (not equal to)
LogicalAND, OR, NOT

8. Procedures, functions and parameters

A procedure is a named block of code that performs a task; it is run with CALL. A function is similar but always returns a value, so it is used inside an expression. Parameters pass values into them (up to three in the exam).

PROCEDURE ShowLine(Size : INTEGER)
  FOR Count ← 1 TO Size
    OUTPUT "-"
  NEXT Count
ENDPROCEDURE

FUNCTION Area(Length : REAL, Width : REAL) RETURNS REAL
  RETURN Length * Width
ENDFUNCTION

CALL ShowLine(10)
OUTPUT Area(4.5, 2)

A local variable exists only inside the procedure or function where it is declared. A global variable can be used anywhere in the program.

9. Library routines

OUTPUT MOD(17, 5)                // 2: the remainder
OUTPUT DIV(17, 5)                // 3: whole-number division
OUTPUT ROUND(3.14159, 2)         // 3.14
Dice ← ROUND(RANDOM() * 5, 0) + 1  // a whole number from 1 to 6

10. Maintainable programs

  • Meaningful identifiers for variables, constants, arrays, procedures and functions, e.g. TotalScore, not T.
  • Comments (// in pseudocode) that explain what sections of code do.
  • Procedures and functions that break the program into reusable parts.

11. Arrays

An array stores many values of the same data type under one name. Each value is accessed by its index, which can be a variable. A 1D array is a list; a 2D array is a table of rows and columns. Use loops (and nested loops for 2D) to read and write values.

DECLARE Marks : ARRAY[1:5] OF INTEGER
FOR Index ← 1 TO 5
  INPUT Marks[Index]
NEXT Index

DECLARE Board : ARRAY[1:3, 1:3] OF CHAR
FOR Row ← 1 TO 3
  FOR Column ← 1 TO 3
    Board[Row, Column] ← '-'
  NEXT Column
NEXT Row

12. File handling

Data stored in a file is kept after the program ends, so it can be used again later or by another program.

DECLARE LineOfText : STRING
OPENFILE "Scores.txt" FOR WRITE
WRITEFILE "Scores.txt", "Ela 85"
CLOSEFILE "Scores.txt"

OPENFILE "Scores.txt" FOR READ
READFILE "Scores.txt", LineOfText
OUTPUT LineOfText
CLOSEFILE "Scores.txt"

13. Run your own pseudocode

Try it: run your own pseudocode

Pick an example or write your own Cambridge-style pseudocode, add any inputs, and press Run. Supports DECLARE, CONSTANT, ←, INPUT, OUTPUT, IF, CASE, FOR, WHILE, REPEAT, arrays, procedures, functions and the library routines.

#rh-run select{font:inherit;font-size:15px;border:1px solid #D6DCE7;border-radius:10px;padding:8px 12px}#rh-run .rn-code{width:100%;box-sizing:border-box;background:#12203F;color:#E6F7F8;border:0;border-radius:12px;padding:14px 16px;font:14px/1.6 monospace;tab-size:2}#rh-run .rn-in{width:100%;box-sizing:border-box;font-family:monospace}#rh-run .rn-go{background:#0B7C86;color:#fff;border-color:#0B7C86}#rh-run .rn-out{background:#F4F7FB;border-radius:10px;padding:12px 16px;font:14px/1.6 monospace;white-space:pre-wrap;min-height:80px;margin:0} (function(){ var w=document.getElementById(‘rh-run’);if(!w)return; var box=w.querySelector(‘.rn-box’); box.innerHTML=’
‘;
var EX={
‘Grade (IF and CASE)’:’// Give a grade for a mark\nDECLARE Mark : INTEGER\nINPUT Mark\nIF Mark >= 50\n  THEN\n    OUTPUT “Pass”\n  ELSE\n    OUTPUT “Fail”\nENDIF\nCASE OF DIV(Mark, 10)\n  10 : OUTPUT “Grade A*”\n  9 : OUTPUT “Grade A*”\n  8 : OUTPUT “Grade A”\n  7 : OUTPUT “Grade B”\n  6 : OUTPUT “Grade C”\n  OTHERWISE OUTPUT “Keep practising”\nENDCASE’,
‘Times table (FOR loop)’:’// Output a times table\nINPUT Number\nFOR Count ← 1 TO 10\n  OUTPUT Number, ” x “, Count, ” = “, Number * Count\nNEXT Count’,
‘Total and average (WHILE)’:’// Input marks until -1 is entered\nTotal ← 0\nCount ← 0\nINPUT Mark\nWHILE Mark  -1 DO\n  Total ← Total + Mark\n  Count ← Count + 1\n  INPUT Mark\nENDWHILE\nIF Count > 0\n  THEN\n    OUTPUT “Average: “, ROUND(Total / Count, 1)\nENDIF’,
‘String handling’:’// Work with a name\nINPUT Name\nOUTPUT “Length: “, LENGTH(Name)\nOUTPUT “Upper: “, UCASE(Name)\nOUTPUT “Lower: “, LCASE(Name)\nOUTPUT “First 3 letters: “, SUBSTRING(Name, 1, 3)’,
‘Array and linear search’:’DECLARE Names : ARRAY[1:5] OF STRING\nFOR Index ← 1 TO 5\n  INPUT Names[Index]\nNEXT Index\nINPUT SearchName\nFound ← FALSE\nIndex ← 1\nREPEAT\n  IF Names[Index] = SearchName\n    THEN\n      Found ← TRUE\n    ELSE\n      Index ← Index + 1\n  ENDIF\nUNTIL Found = TRUE OR Index > 5\nIF Found\n  THEN\n    OUTPUT SearchName, ” is at position “, Index\n  ELSE\n    OUTPUT SearchName, ” not found”\nENDIF’,
‘Procedure and function’:’FUNCTION Square(Number : INTEGER) RETURNS INTEGER\n  RETURN Number * Number\nENDFUNCTION\n\nPROCEDURE Stars(Size : INTEGER)\n  Line ← “”\n  FOR I ← 1 TO Size\n    Line ← Line + “*”\n  NEXT I\n  OUTPUT Line\nENDPROCEDURE\n\nINPUT N\nOUTPUT N, ” squared is “, Square(N)\nCALL Stars(N)’
};
var INS={‘Grade (IF and CASE)’:’73’,’Times table (FOR loop)’:’7′,’Total and average (WHILE)’:’60, 72, 85, -1′,’String handling’:’Amelia’,’Array and linear search’:’Ali, Bea, Can, Deniz, Ela, Can’,’Procedure and function’:’5′};
var sel=w.querySelector(‘.rn-ex’),code=w.querySelector(‘.rn-code’),inp=w.querySelector(‘.rn-in’),out=w.querySelector(‘.rn-out’);
Object.keys(EX).forEach(function(k){var o=document.createElement(‘option’);o.textContent=k;sel.appendChild(o);});
function load(){code.value=EX[sel.value];inp.value=INS[sel.value];out.textContent=’Press Run to execute the pseudocode.’;}
sel.onchange=load;
function Err(m,l){this.m=m;this.l=l;}
function Ret(v){this.v=v;}
var TOK=/\s*(?:(\d+\.\d+|\d+)|(“[^”]*”|'[^’]*’|‘[^’]*’)|(|=|<-|←|[-+*\/^=()\[\],:&])|([A-Za-z_][A-Za-z0-9_]*))/y;
function lex(s,ln){var t=[],m;TOK.lastIndex=0;s=s.replace(/\s+$/,”);while(TOK.lastIndex<s.length){var st=TOK.lastIndex;m=TOK.exec(s);if(!m){throw new Err('Cannot read: '+s.slice(st).trim(),ln);}if(m[1]!==undefined)t.push({k:'n',v:+m[1]});else if(m[2]!==undefined)t.push({k:'s',v:m[2].slice(1,-1)});else if(m[3]!==undefined)t.push({k:'o',v:m[3]==='<-'?'←':m[3]});else t.push({k:'i',v:m[4]});}return t;}
function P(toks,ln){this.t=toks;this.p=0;this.ln=ln;}
P.prototype.peek=function(){return this.t[this.p];};
P.prototype.is=function(v){var x=this.t[this.p];if(!x)return false;if(x.k==='o')return x.v===v;if(x.k==='i')return x.v.toUpperCase()===v;return false;};
P.prototype.eat=function(v){if(!this.is(v))throw new Err('Expected '+v,this.ln);this.p+=1;};
P.prototype.expr=function(){var l=this.and();while(this.is('OR')){this.p+=1;l={k:'or',a:l,b:this.and()};}return l;};
P.prototype.and=function(){var l=this.not();while(this.is('AND')){this.p+=1;l={k:'and',a:l,b:this.not()};}return l;};
P.prototype.not=function(){if(this.is('NOT')){this.p+=1;return {k:'not',a:this.not()};}return this.rel();};
P.prototype.rel=function(){var l=this.add();var ops=['=','’,'<','’,’>=’];for(var i=0;i<ops.length;i++){if(this.is(ops[i])){this.p+=1;return {k:'bin',o:ops[i],a:l,b:this.add()};}}return l;};
P.prototype.add=function(){var l=this.mul();while(this.is('+')||this.is('-')||this.is('&')){var o=this.peek().v;this.p+=1;l={k:'bin',o:o,a:l,b:this.mul()};}return l;};
P.prototype.mul=function(){var l=this.pow();while(this.is('*')||this.is('/')||this.is('MOD')||this.is('DIV')){var x=this.peek();var o=x.k==='o'?x.v:x.v.toUpperCase();this.p+=1;l={k:'bin',o:o,a:l,b:this.pow()};}return l;};
P.prototype.pow=function(){var l=this.un();if(this.is('^')){this.p+=1;return {k:'bin',o:'^',a:l,b:this.pow()};}return l;};
P.prototype.un=function(){if(this.is('-')){this.p+=1;return {k:'neg',a:this.un()};}return this.prim();};
P.prototype.prim=function(){var x=this.peek();if(!x)throw new Err('Expression is incomplete',this.ln);
 if(x.k==='n'){this.p+=1;return {k:'lit',v:x.v};}
 if(x.k==='s'){this.p+=1;return {k:'lit',v:x.v};}
 if(this.is('(')){this.p+=1;var e=this.expr();this.eat(')');return e;}
 if(x.k==='i'){var u=x.v.toUpperCase();this.p+=1;if(u==='TRUE')return {k:'lit',v:true};if(u==='FALSE')return {k:'lit',v:false};
  if(this.is('(')){this.p+=1;var args=[];if(!this.is(')')){args.push(this.expr());while(this.is(',')){this.p+=1;args.push(this.expr());}}this.eat(')');return {k:'call',n:x.v,a:args};}
  if(this.is('[')){this.p+=1;var ix=[this.expr()];while(this.is(',')){this.p+=1;ix.push(this.expr());}this.eat(']');return {k:'idx',n:x.v,i:ix};}
  return {k:'var',n:x.v};}
 throw new Err('Unexpected '+x.v,this.ln);};
function pexpr(s,ln){var p=new P(lex(s,ln),ln);var e=p.expr();if(p.p<p.t.length)throw new Err('Unexpected '+p.t[p.p].v,ln);return e;}
function plist(s,ln){var p=new P(lex(s,ln),ln);var a=[p.expr()];while(p.is(',')){p.p+=1;a.push(p.expr());}if(p.p<p.t.length)throw new Err('Unexpected '+p.t[p.p].v,ln);return a;}
function ptarget(s,ln){var p=new P(lex(s,ln),ln);var e=p.prim();if(e.k!=='var'){if(e.k!=='idx')throw new Err('Cannot assign to this',ln);}if(p.p<p.t.length)throw new Err('Unexpected '+p.t[p.p].v,ln);return e;}
function strip(l){var q=null,r='';for(var i=0;i0;});var pos=0,funcs={};
 function up(s){return s.toUpperCase();}
 function startsW(s,w){var u=up(s);if(u===w)return true;return u.indexOf(w+’ ‘)===0;}
 function block(ends){var out=[];while(pos<L.length){var ln=L[pos],u=up(ln.s);for(var e=0;e<ends.length;e++){if(u===ends[e]||u.indexOf(ends[e]+' ')===0)return out;}out.push(stmt());}if(ends.length)throw new Err('Missing '+ends.join(' or '),L.length?L[L.length-1].n:1);return out;}
 function stmt(){var ln=L[pos],s=ln.s,u=up(s),n=ln.n,m;pos+=1;
  if(startsW(s,'DECLARE')){m=s.match(/^DECLARE\s+(\w+)\s*:\s*ARRAY\s*\[\s*(.+?)\s*\]\s*OF\s+\w+$/i);if(m){var dims=m[2].split(',').map(function(d){var r=d.split(':');if(r.length!==2)throw new Err('Array bounds should look like [1:10]',n);return [pexpr(r[0],n),pexpr(r[1],n)];});return {t:'arr',n:m[1],d:dims,ln:n};}if(/^DECLARE\s+\w+\s*:\s*\w+$/i.test(s))return {t:'nop'};throw new Err('DECLARE should look like: DECLARE Name : INTEGER',n);}
  if(startsW(s,'CONSTANT')){m=s.match(/^CONSTANT\s+(\w+)\s*(?:←|<-|=)\s*(.+)$/i);if(!m)throw new Err('CONSTANT should look like: CONSTANT Rate ← 6.5',n);return {t:'set',g:{k:'var',n:m[1]},e:pexpr(m[2],n),ln:n};}
  if(startsW(s,'INPUT')){return {t:'in',g:ptarget(s.slice(5),n),ln:n};}
  if(startsW(s,'OUTPUT')||startsW(s,'PRINT')){return {t:'out',e:plist(s.replace(/^\w+/,''),n),ln:n};}
  if(startsW(s,'IF')){var c=s.slice(2).replace(/\s+THEN\s*$/i,'');var st={t:'if',c:pexpr(c,n),y:[],no:[],ln:n};if(pos<L.length){if(up(L[pos].s)==='THEN')pos+=1;}st.y=block(['ELSE','ENDIF']);if(up(L[pos].s)==='ELSE'){pos+=1;st.no=block(['ENDIF']);}pos+=1;return st;}
  if(startsW(s,'CASE')){m=s.match(/^CASE\s+OF\s+(.+)$/i);if(!m)throw new Err('CASE should look like: CASE OF Choice',n);var cs={t:'case',e:pexpr(m[1],n),c:[],o:null,ln:n};while(pos<L.length){var l2=L[pos];if(up(l2.s)==='ENDCASE'){pos+=1;return cs;}if(startsW(l2.s,'OTHERWISE')){var rest=l2.s.replace(/^OTHERWISE\s*:?\s*/i,'');pos+=1;var sv=pos;L.splice(pos,0,{s:rest,n:l2.n});cs.o=[stmt()];continue;}var ci=l2.s.indexOf(' : ');if(ci<0)ci=l2.s.indexOf(':');if(ci<0)throw new Err('Each case should look like: value : statement',l2.n);var vals=plist(l2.s.slice(0,ci),l2.n);var body=l2.s.slice(ci+1).replace(/^\s*:?\s*/,'');pos+=1;L.splice(pos,0,{s:body,n:l2.n});cs.c.push({v:vals,b:[stmt()]});}throw new Err('Missing ENDCASE',n);}
  if(startsW(s,'FOR')){m=s.match(/^FOR\s+(\w+)\s*(?:←|0;});var fb=block([isF?’ENDFUNCTION’:’ENDPROCEDURE’]);pos+=1;funcs[up(m[1])]={p:ps,b:fb,f:isF,n:m[1]};return {t:’nop’};}
  if(startsW(s,’CALL’)){var ce=pexpr(s.slice(4),n);if(ce.k===’var’)ce={k:’call’,n:ce.n,a:[]};return {t:’call’,e:ce,ln:n};}
  if(startsW(s,’RETURN’)){return {t:’ret’,e:pexpr(s.slice(6),n),ln:n};}
  var ai=s.search(/←|0){var op=s[ai]===’0;}),qi=0,prog;
 try{prog=parse(src);}catch(e){out.textContent=e instanceof Err?’Syntax error on line ‘+e.l+’: ‘+e.m:’Error: ‘+e.message;return;}
 var G={},arrs={},F=prog.f;
 function look(sc,n){var u=n.toUpperCase();for(var i=sc.length-1;i>=0;i-=1){if(u in sc[i])return sc[i];}return null;}
 function get(sc,n,ln){var s=look(sc,n);if(!s)throw new Err(n+’ has no value yet’,ln);return s[n.toUpperCase()];}
 function put(sc,n,v){var s=look(sc,n);if(!s)s=sc[sc.length-1];s[n.toUpperCase()]=v;}
 function key(sc,node,ln){var a=look(sc,node.n);var A=a?a[node.n.toUpperCase()]:null;if(!A){throw new Err(node.n+’ is not a declared array’,ln);}if(!A.arr)throw new Err(node.n+’ is not a declared array’,ln);var ks=node.i.map(function(e,d){var v=ev(sc,e,ln);var lo=A.d[d][0],hi=A.d[d][1];if(vhi)throw new Err(‘Index ‘+v+’ is outside ‘+node.n+'[‘+lo+’:’+hi+’]’,ln);return v;});return {A:A,k:ks.join(‘,’)};}
 function tru(v){return v===true;}
 function ev(sc,e,ln){steps+=1;if(steps>200000)throw new Err(‘Too many steps: is there an infinite loop?’,ln);
  switch(e.k){case ‘lit’:return e.v;case ‘var’:return get(sc,e.n,ln);
  case ‘idx’:var r=key(sc,e,ln);if(!(r.k in r.A.v))throw new Err(e.n+'[‘+r.k+’] has no value yet’,ln);return r.A.v[r.k];
  case ‘neg’:return -ev(sc,e.a,ln);
  case ‘not’:return !tru(ev(sc,e.a,ln));
  case ‘and’:if(!tru(ev(sc,e.a,ln)))return false;return tru(ev(sc,e.b,ln));
  case ‘or’:if(tru(ev(sc,e.a,ln)))return true;return tru(ev(sc,e.b,ln));
  case ‘bin’:var a=ev(sc,e.a,ln),b=ev(sc,e.b,ln);switch(e.o){case ‘+’:return a+b;case ‘&’:return String(a)+String(b);case ‘-‘:return a-b;case ‘*’:return a*b;case ‘/’:if(b===0)throw new Err(‘Division by zero’,ln);return a/b;case ‘^’:return Math.pow(a,b);case ‘MOD’:return a%b;case ‘DIV’:return Math.trunc(a/b);case ‘=’:return a===b;case ”:return a!==b;case ‘<':return a<b;case '<=':return a’:return a>b;case ‘>=’:return a>=b;}break;
  case ‘call’:var u=e.n.toUpperCase(),A=e.a.map(function(x){return ev(sc,x,ln);});
   switch(u){case ‘LENGTH’:return String(A[0]).length;case ‘UCASE’:return String(A[0]).toUpperCase();case ‘LCASE’:return String(A[0]).toLowerCase();case ‘SUBSTRING’:return String(A[0]).substr(A[1]-1,A[2]);case ‘ROUND’:var f=Math.pow(10,A[1]||0);return Math.round(A[0]*f)/f;case ‘RANDOM’:return Math.random();case ‘DIV’:return Math.trunc(A[0]/A[1]);case ‘MOD’:return A[0]%A[1];case ‘INT’:return Math.trunc(A[0]);}
   var fn=F[u];if(!fn)throw new Err(‘Unknown function ‘+e.n,ln);if(!fn.f)throw new Err(e.n+’ is a procedure: use CALL’,ln);return callF(sc,fn,A,ln);}
  throw new Err(‘Cannot evaluate’,ln);}
 function callF(sc,fn,A,ln){if(A.length!==fn.p.length)throw new Err(fn.n+’ needs ‘+fn.p.length+’ parameter(s)’,ln);var loc={};fn.p.forEach(function(p,i){loc[p.toUpperCase()]=A[i];});var ns=[sc[0],loc];try{exec(ns,fn.b);}catch(x){if(x instanceof Ret)return x.v;throw x;}if(fn.f)throw new Err(fn.n+’ finished without RETURN’,ln);return null;}
 function show(v){if(v===true)return ‘TRUE’;if(v===false)return ‘FALSE’;if(typeof v===’number’){return String(Math.round(v*1e10)/1e10);}return String(v);}
 function exec(sc,body){for(var i=0;i200000)throw new Err(‘Too many steps: is there an infinite loop?’,s.ln);
  switch(s.t){case ‘nop’:break;
  case ‘arr’:var d=s.d.map(function(b){return [ev(sc,b[0],s.ln),ev(sc,b[1],s.ln)];});put(sc,s.n,{arr:true,d:d,v:{}});break;
  case ‘set’:var v=ev(sc,s.e,s.ln);if(s.g.k===’idx’){var r=key(sc,s.g,s.ln);r.A.v[r.k]=v;}else put(sc,s.g.n,v);break;
  case ‘in’:if(qi>=queue.length)throw new Err(‘INPUT needs another value: add it to the inputs box’,s.ln);var raw=queue[qi];qi+=1;var val=/^-?\d+(\.\d+)?$/.test(raw)?+raw:(/^true$/i.test(raw)?true:(/^false$/i.test(raw)?false:raw));lines.push(‘? ‘+raw);if(s.g.k===’idx’){var r2=key(sc,s.g,s.ln);r2.A.v[r2.k]=val;}else put(sc,s.g.n,val);break;
  case ‘out’:lines.push(s.e.map(function(x){return show(ev(sc,x,s.ln));}).join(”));break;
  case ‘if’:exec(sc,tru(ev(sc,s.c,s.ln))?s.y:s.no);break;
  case ‘case’:var cv=ev(sc,s.e,s.ln),hit=false;for(var c=0;c<s.c.length;c++){for(var k=0;k0?x=b;x+=st){put(sc,s.v,x);exec(sc,s.body);}break;
  case ‘while’:while(tru(ev(sc,s.c,s.ln)))exec(sc,s.body);break;
  case ‘rep’:do{exec(sc,s.body);}while(!tru(ev(sc,s.c,s.ln)));break;
  case ‘call’:var fn=F[s.e.n.toUpperCase()];if(!fn)throw new Err(‘Unknown procedure ‘+s.e.n,s.ln);callF(sc,fn,s.e.a.map(function(y){return ev(sc,y,s.ln);}),s.ln);break;
  case ‘ret’:throw new Ret(ev(sc,s.e,s.ln));}}}
 try{exec([G],prog.p);lines.push(‘— Program finished —’);}catch(e){if(e instanceof Err)lines.push(‘✗ Error on line ‘+e.l+’: ‘+e.m);else if(e instanceof Ret)lines.push(‘✗ RETURN used outside a function’);else lines.push(‘✗ Error: ‘+e.message);}
 out.textContent=lines.join(‘\n’);}
w.querySelector(‘.rn-go’).onclick=run;load();
})();



14. Examiner tips

  1. Write pseudocode, not program code, except in the 15-mark scenario question.
  2. Use meaningful names and comment your code in longer answers.
  3. Functions RETURN a value; procedures don’t. Call a procedure with CALL.
  4. Initialise totals and counters before the loop, and update them inside it.
  5. Close every structure (ENDIF, ENDCASE, NEXT, ENDWHILE, UNTIL, ENDPROCEDURE, ENDFUNCTION).
  6. MOD gives the remainder; DIV gives the whole-number part.
  7. Arrays: check the index range and use a loop to process every element.
  8. Files: OPENFILE before reading or writing, and CLOSEFILE afterwards.

15. Practice questions

Practice: answer and check instantly

Type a short answer, then press Check or Enter.

Show answer

BOOLEAN.

Show answer

CHAR.

Show answer

2: 17 = 3 × 5 + 2.

Show answer

3: whole-number division.

Show answer

8 characters.

Show answer

“put”: 3 characters starting at position 4.

Show answer

CALL.

Show answer

REPEAT … UNTIL.

Exam-style questions

Not sure what a question wants? Read Command words: what the question is really asking.

9. Write a function called Average that takes three integer parameters and returns their average. [4]

Show mark guide

FUNCTION Average(A : INTEGER, B : INTEGER, C : INTEGER) RETURNS REAL [1 header with parameters, 1 RETURNS type] · RETURN (A + B + C) / 3 [1] · ENDFUNCTION [1].

10. Explain the difference between a local and a global variable. [2]

Show mark guide

A local variable is declared inside a procedure or function and can only be used there [1]; a global variable is declared in the main program and can be used anywhere in the program [1].

(function(){var w=document.getElementById(‘rh-practice’);if(!w)return;function chk(id,btn){var i=document.getElementById(id),f=btn.parentNode.querySelector(‘.fb’);var got=(i.value||”).replace(/[^a-z0-9]/gi,”).toUpperCase();var ok=i.getAttribute(‘data-a’).split(‘|’).indexOf(got)>-1;f.className=’fb ‘+(ok?’ok’:’no’);f.textContent=got?(ok?’✓ Correct’:’✗ Not quite, try again or show the answer’):’Type an answer first’;}w.addEventListener(‘click’,function(e){var id=e.target.getAttribute(‘data-check’);if(id)chk(id,e.target);});w.addEventListener(‘keydown’,function(e){if(e.key===’Enter’&&e.target.matches(‘input[data-a]’)){e.preventDefault();chk(e.target.id,w.querySelector(‘[data-check=’+e.target.id+’]’));}});})();

16. Topic test: predict your grade

Topic test: predict your grade

15 questions, about 10 minutes. Answer them all, then press Mark my test.

1. Which is a constant?
2. Which data type should store 3.75?
3. Which statement chooses between many values of one variable?
4. Which loop checks its condition before the first repeat?
5. What does UCASE(“hi”) return?
6. What is 2 ^ 3?
<fieldset class="rh-tq" data-c="1" data-e=" in pseudocode”>7. Which operator means “not equal to”?
8. What is the difference between a function and a procedure?
9. A variable that can only be used inside one procedure is…
10. Which library routine gives a random number?
11. Which makes a program easier to maintain?
12. How is the 3rd element of the array Marks written?
13. How many elements does ARRAY[1:3, 1:4] hold?
14. Why store data in a file?
15. Which must come before READFILE?
(function(){var w=document.getElementById(‘rh-test’);if(!w)return;var G=[[85,’A*’],[75,’A’],[65,’B’],[55,’C’],[45,’D’],[35,’E’],[0,’U’]];var out=w.querySelector(‘.rh-grade’);document.getElementById(‘rh-mark’).onclick=function(){var f=w.querySelectorAll(‘.rh-tq’),s=0,un=0;f.forEach(function(x){if(!x.querySelector(‘input:checked’))un++;});if(un){out.style.display=’block’;out.innerHTML=’

You have ‘+un+’ unanswered question’+(un>1?’s’:”)+’. Answer them all first.

‘;return;}f.forEach(function(x){var c=x.querySelector(‘input:checked’),ok=+c.value===+x.dataset.c;if(ok)s++;x.className=’rh-tq ‘+(ok?’ok’:’no’);var e=x.querySelector(‘.ex’);e.hidden=false;e.textContent=(ok?’✓ ‘:’✗ Correct answer: ‘+x.querySelectorAll(‘label’)[+x.dataset.c].textContent.trim()+’. ‘)+x.dataset.e;});var pc=Math.round(s/f.length*100),g=’U’;for(var i=0;i=G[i][0]){g=G[i][1];break;}}out.style.display=’block’;out.innerHTML=’

Your score

‘+g+’   ‘+s+’ / ‘+f.length+’ (‘+pc+’%)

‘+(pc>=75?’Excellent. This topic is exam-ready; keep it fresh with past papers.’:pc>=55?’Good base. Re-read the sections for the questions marked in red, then try again.’:’Work through the notes and the practice questions above, then retake the test.’)+’

Estimated grade for this topic only, based on typical IGCSE grade boundaries. Your real grade depends on both papers.

‘;out.scrollIntoView({behavior:’smooth’,block:’center’});};document.getElementById(‘rh-reset’).onclick=function(){w.querySelectorAll(‘input’).forEach(function(i){i.checked=false;});w.querySelectorAll(‘.rh-tq’).forEach(function(x){x.className=’rh-tq’;x.querySelector(‘.ex’).hidden=true;});out.style.display=’none’;w.scrollIntoView({behavior:’smooth’});};})();

Frequently asked questions

What are the three basic programming constructs?

The three constructs are sequence, selection (IF and CASE) and iteration (FOR, WHILE and REPEAT loops).

What is the difference between a procedure and a function?

A procedure performs a task. A function performs a task and returns a single value that can be used in an expression.

What is the difference between a local and a global variable?

A local variable is declared inside a subroutine and can only be used there. A global variable is declared in the main program and can be used anywhere.

What are the data types in IGCSE Computer Science?

INTEGER, REAL, CHAR, STRING and BOOLEAN.

What is a 2D array?

A 2D array is a table of data items of the same data type, accessed using two indexes: one for the row and one for the column, for example Marks[2, 3].

What string handling operations do I need for IGCSE?

Finding the length of a string, extracting a substring, and converting to upper case or lower case.

Why do programmers use procedures and functions?

They let a block of code be written once and reused, make programs easier to read, test and maintain, and allow a large task to be split between programmers.

{“@context”:”https://schema.org”,”@type”:”FAQPage”,”mainEntity”:[{“@type”:”Question”,”name”:”What are the three basic programming constructs?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”The three constructs are sequence, selection (IF and CASE) and iteration (FOR, WHILE and REPEAT loops).”}},{“@type”:”Question”,”name”:”What is the difference between a procedure and a function?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”A procedure performs a task. A function performs a task and returns a single value that can be used in an expression.”}},{“@type”:”Question”,”name”:”What is the difference between a local and a global variable?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”A local variable is declared inside a subroutine and can only be used there. A global variable is declared in the main program and can be used anywhere.”}},{“@type”:”Question”,”name”:”What are the data types in IGCSE Computer Science?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”INTEGER, REAL, CHAR, STRING and BOOLEAN.”}},{“@type”:”Question”,”name”:”What is a 2D array?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”A 2D array is a table of data items of the same data type, accessed using two indexes: one for the row and one for the column, for example Marks[2, 3].”}},{“@type”:”Question”,”name”:”What string handling operations do I need for IGCSE?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”Finding the length of a string, extracting a substring, and converting to upper case or lower case.”}},{“@type”:”Question”,”name”:”Why do programmers use procedures and functions?”,”acceptedAnswer”:{“@type”:”Answer”,”text”:”They let a block of code be written once and reused, make programs easier to read, test and maintain, and allow a large task to be split between programmers.”}}]}
Was this page helpful?