0% found this document useful (0 votes)
4 views

Code Simple

CodeSimple

Uploaded by

Gerard Garcia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Code Simple

CodeSimple

Uploaded by

Gerard Garcia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Welcome to CodeSimple, the language designed to teach coding in a simple and fun way!

Here are some basic commands to get you started:

1. PRINT: This command is used to display output on the screen. For example, "PRINT Hello,
World!" would display the message "Hello, World!" on the screen.

2. SET: This command is used to assign a value to a variable. For example, "SET x = 5" would
assign the value 5 to the variable x.

3. ADD: This command is used to add two numbers together. For example, "ADD 5 + 3" would
return the value 8.

4. SUBTRACT: This command is used to subtract one number from another. For example,
"SUBTRACT 7 - 3" would return the value 4.

5. MULTIPLY: This command is used to multiply two numbers together. For example, "MULTIPLY
[email protected]
OZI2PGYXVN
2 * 4" would return the value 8.

6. DIVIDE: This command divides one number from another. For example, "DIVIDE 10 / 2" would
return the value 5.

7. IF: This command is used to create conditional statements. For example, "IF x > 5 THEN PRINT
x" would display the value of x only if it is greater than 5.

8. LOOP: This command is used to repeat a block of code. For example, "LOOP 10 TIMES PRINT
x" would display the value of x ten times.

9. LENSTR: This command is used to calculate the length of a String (Number of characters in
the string data). For example, LENSTR(“CodeSimple”) will provide the answer as 10 as the result.

With these basic commands, you can start creating your own programs in CodeSimple.

Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution is prohibited.
This file is meant for personal use by [email protected] only.
Sharing or publishing the contents in part or full is liable for legal action.
Let's see the below questions and how you can use CodeSimple to solve these problems.

1. Q: Write a program that displays the message "Hello, world!" on the screen.
A:
```
PRINT "Hello, world!"
```
2. Q: Write a program that assigns the value 10 to a variable named "count",
then displays the value of "count" on the screen.
A:
```
SET count = 10
PRINT count
```
3. Q: Write a program that calculates the sum of two numbers (e.g. 5 and 3)
and displays the result on the screen.
A:
```
[email protected]
OZI2PGYXVN SET num1 = 5
SET num2 = 3
SET sum = ADD num1 + num2
PRINT sum
```
4. Q: Write a program that calculates the product of two numbers (e.g. 4 and 6)
and displays the result on the screen.
A:
```
SET num1 = 4
SET num2 = 6
SET product = MULTIPLY num1 * num2
PRINT product
```
5. Q: Write a program that prompts the user to enter a number, and then
displays whether that number is even or odd.
A:
```
INPUT "Enter a number: " num

Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution is prohibited.
This file is meant for personal use by [email protected] only.
Sharing or publishing the contents in part or full is liable for legal action.
IF num % 2 = 0 THEN
PRINT "The number is even."
ELSE
PRINT "The number is odd."
END IF
```
6. Q: Write a program that prompts the user to enter a string, then displays the string's length
on the screen.
A:
```
INPUT "Enter a string: " str
SET length = LENGTH str
PRINT length
```
7. Q: Write a program that uses a loop to display the numbers from 1 to 10 on
the screen.
A:
```
[email protected]
OZI2PGYXVN SET count = 1
LOOP 10 TIMES
PRINT count
SET count = ADD count + 1
END LOOP
```
8. Q: Write a program that uses an if statement to display the message "x is
greater than y" if x is greater than y, or "y is greater than x" if y is greater than
x.
A:
```
SET x = 10
SET y = 5
IF x > y THEN
PRINT "x is greater than y"
ELSE
PRINT "y is greater than x"
END IF
```

Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution is prohibited.
This file is meant for personal use by [email protected] only.
Sharing or publishing the contents in part or full is liable for legal action.
Now that you have understood the application of the commands of Codesimple, it's time to test
your understanding by solving the below questions.

1. Write a program that displays the message "Welcome to CodeSimple!" on the screen.

2. Write a program that assigns the value 10 to a variable named "count", then displays the
value of "count" on the screen.

3. Write a program that calculates the sum of two numbers (e.g. 5 and 3) and displays the result
on the screen.

4. Write a program that calculates the product of two numbers (e.g. 4 and 6) and displays the
result on the screen.

5. Write a program that prompts the user to enter a number, and then displays whether that
number is even or odd.

6. Write a program that prompts the user to enter a string, then displays the string's length on
[email protected]
OZI2PGYXVNthe screen.

7. Write a program that uses a loop to display the numbers from 1 to 10 on the screen.

8. Write a program that uses an if statement to display the message "x is greater than y" if x is
greater than y, or "y is greater than x" if y is greater than x.

Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution is prohibited.
This file is meant for personal use by [email protected] only.
Sharing or publishing the contents in part or full is liable for legal action.

You might also like