## Constructs of Programming

• We write instructions in programs.
• Generally instructions are executed in a sequential order
``````a = 5
print(a)
a = a - 1
print(a)
``````
• Programming Languages have separtors
• C, C++, Java, C# => ;
• Python => new line
• Programming languages have conditionals, which allows us to execute certain set of instructions.
• if
• if else
``````number = 10
remainder = number%2
if remainder == 0 then print('even')
else print('odd')
``````
• Looping constructs which allow us to execute certain set of instruction repeatedly until some condition is met
``````index = 1
until index <= 5
start
print(index)
index = index + 1
end

``````
• Solution to Exercise:

• Write to Jarvis to calculate
• square of the number
``````Hello Jarvis
take input from user and assign to number
result = number * number
print(result)
``````
• Area of the rectangle (length * breadth)
``````Hello Jarvis
take input from user and assign to length and breadth
print(area)
``````
• find the reverse of the number (35 => 53 )
``````Hello jarvis,
Take input from user and assign it to number
result = 0
until number not equals zero (!=)
start
remainder = number%10
result = result * 10 + remainder
number = number/10
end
print result
`````` • Exercise:

• Write to Jarvis
• to find if the number is prime or not
• to find the factorial of a number (5! = 5 * 4* 3 * 2 * 1 )

This site uses Akismet to reduce spam. Learn how your comment data is processed. 