Question
I need to add to the program this cases C++ w = HOLA y = MUNDO if 3 .gt. 2 then a = 2
I need to add to the program this cases C++
w = "HOLA"
y = " MUNDO"
if 3 .gt. 2 then a = 2 .add. 1 .add. 3 .mul. 4
z = w .add. y
print z
if z .eq. "HOLA MUNDO" then print z
cc = 0
c2 = 9
c = 4
if c .eq. 4 then a = c .add. 3 .div. 3
n = 3.0 .add. 2 .mul. c
print "n = "
print n
a = 3 .mul. c .add. 2
print "a = "
print a
print "ENTER AN INTEGER NUMBER: "
read b
print "YOU ENTERED: "
print b
if b .gt. 7 .and. b .le. 9 .or. b .eq. 8 then print "a = "
if b .gt. 7 .and. b .le. 9 .or. b .eq. 8 then print a
end.
#include
#include
#include
#include
using namespace std;
void keyword(int, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*, char*);
void checkPrint(char*, char*,int);
void checkVariable(char*);
void checkNumber(char*);
void checkOperator();
void checkAdd();
void checkOperator2();
void checkOperator3();
int main()
{
char end[] = "END.", print[] = "PRINT", if_[] = "IF", read[] = "READ", eq[] = ".EQ.", add[] = ".ADD.", or_[] = ".OR.", and_[]=".AND.", xor_[]=".XOR.", then[] = "THEN";
char rem[]="REM";
char var[] = "abcdefghijklmnopqrstuvwxyz";
char num[] = "0123456789";
char input[100];
do
{
cout
cin.getline(input, 100);
int size = strlen(input);
//Para entrar Variable
if (*input == var[0] || *input == var[1] || *input == var[2] || *input == var[3] || *input == var[4] || *input == var[5] || *input == var[6] || *input == var[7] || *input == var[8] || *input == var[9] || *input == var[10] || *input
== var[11] || *input == var[12] || *input == var[13] || *input == var[14] || *input == var[15] || *input == var[16] || *input == var[17] || *input == var[18] || *input == var[19] || *input == var[20] || *input == var[21] || *input == var[22] || *input == var[23] || *input == var[24] || *input == var[25] || *input == var[26])
{
checkVariable(input);
}
//Para entrar Number
if (*input == num[0] || *input == num[1] || *input == num[2] || *input == num[3] || *input == num[4] || *input == num[5] || *input == num[6] || *input == num[7] || *input == num[8] || *input == num[9])
{
checkNumber(input);
}
//Para entrar REM
if (input[0] == rem[0] && input[1] == rem[1] && input[2] == rem[2])
{
cout
}
//Keywords
keyword(size, then, num, input, end, print, if_, read, add, eq, or_, var);
//.XOR.
if (xor_[0] == input[0] && xor_[1] == input[1] && xor_[2] == input[2] && xor_[3] == input[3] && xor_[4] == input[4])
{
cout
}
//Invalid Syntax
if (input[0] == '?' || input[0]=='=')
{
cout
}
cout
} while (1);
return 0;
}
//functions:
void keyword(int size, char* then, char* and_, char* input, char* end, char* print, char* if_, char* read, char* add, char* eq, char* or_, char* var)
{
for (int i = 0; i
{
input[i] = toupper(input[i]);
}
//Para entrar THEN
if (input[0] == then[0] && input[1] == then[1] && input[2] == then[2] && input[3] == then[3])
{
cout
}
//Para entrar .EQ.
if (eq[0] == input[0] && eq[1] == input[1] && eq[2] == input[2] && eq[3] == input[3])
{
checkOperator();
}
//Para entrar .OR.
if (or_[0] == input[0] && or_[1] == input[1] && or_[2] == input[2] && or_[3] == input[3])
{
checkOperator2();
}
//Para entrar .AND.
if (and_[0] == input[0] && and_[1] == input[1] && and_[2] == input[2] && and_[3] == input[3] && and_[4] == input[4])
{
checkOperator3();
}
//Para entral .ADD.
if (add[0] == input[0] && add[1] == input[1] && add[2] == input[2] && add[3] == input[3] && add[4] == input[4])
{
checkAdd();
}
//Para entrar END.
if (input[0] == end[0] && input[1] == end[1] && input[2] == end[2] && input[3] == end[3])
{
cout
}
//Para entrar IF
if (input[0] == if_[0] && input[1] == if_[1])
{
cout
}
//Para entrar PRINT
if (input[0] == print[0] && input[1] == print[1] && input[2] == print[2] && input[3] == print[3] && input[4] == print[4])
{
if (!(input[6] == *("\"") && input[size - 1] == *("\"")))
{
cout
}
else
{
checkPrint(input, print, size);
}
}
//Para entrar READ
if (input[0] == read[0] && input[1] == read[1] && input[2] == read[2] && input[3] == read[3])
{
cout
}
}
void checkOperator()
{
cout
}
void checkAdd()
{
cout
}
void checkOperator2()
{
cout
}
void checkOperator3()
{
cout
}
void checkPrint(char* input,char* print,int size)
{
if (input[6] == *("\"") && input[size - 1] == *("\""))
{
cout
}
else
{
cout
}
}
void checkVariable(char* input)
{
cout
}
void checkNumber(char* input)
{
int size = strlen(input);
int found=0;
for (int f = 0; f
{
if (input[f]=='.')
{
found = f;
}
}
if (input[found] == '.')
{
cout
}
else
{
cout
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started