Assignment 3

Programming

Introduction

Both C and python are similar in that they do the same task but through different syntaxes. In programming languages the order in which the code is written is important as the code is processed line by line. C is a more structured language with more rules on how to write a program. Besides the examples worked on in the classroom I have not spent a lot of time experimenting with C.
Python is a lot simpler in that it has fewer constraints with regard to how a program is to be written. Indentation is important in python. It enables nesting. There are also a set of reserved words in python that have predefined meanings. Given below is an example of a code in python to determine whether the variable is greater than or smaller than 10.

example

Program 1

Write a program to take two integers "a" and "b" as inputs from the user and print their sum.

sketch sketch

Program 2

Write a program to take an integer "n" as input and print if it is "odd" or "even".

sketch sketch

Program 3

Write a program to take an integer "n" as input from the user and print its factorial.

sketch sketch