Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a compiler for is a language that I created. I chose a functional language

ID: 3595049 • Letter: W

Question

write a compiler for is a language that I created. I chose a functional language because such languages can be easily interpreted without generating any intermediate code. It is important that you understand the language first, so examine the syntax rules

Write a short program in this language that contains one function, and has at least one input, one variable and one conditional expression. Show the output of that program on two different inputs. Here is an example of the kind of program that I am looking for:

Explanation / Answer

#include<iostream>
using namespace std;

// function that returns absolute difference between 2 numbers

// input is a
int absoluteDiff(int a)
{
// variable declaration
int b = 4;
  
// condition
if(a>b)
return a-b;
else
return b-a;
}

main(){
// 2 sample runs
cout << absoluteDiff(2) << endl;
cout << absoluteDiff(8) << endl;
}

/*SAMPLE OUTPUT
2
4
*/