UNIT#1

 

 

 

Program #1:

The program prints the phrase, “Hello World!” to the screen.

 

·        Program Code

 

Output for Program#1:

Hello World!

 

 

Program #2:

The program prints the phrase, “Hello World!” by using two print statements.

 

·        Program Code

 

Output for Program#2:

Hello World!

 

Program #3:

The program prints one line of text followed by another on the next line.

 

·        Program Code

 

Output for Program#3:

Hello there!

How are you?

 

 

Program #4:

The program asks the user to enter two integers (number1 and number2) and prints the sum, difference, product and quotient of the two integers.

 

·         Program Code

 

Output for Program#4:

Enter first integer: 7

Enter second integer: 2

Sum is 9

Difference is 5

Product is 14

Quotient is 3

 

Program #5:

The program asks the user to enter two integers and prints if the two integers are greater, equal, less or smaller after comparing them.

 

·         Program Code

 

Output for Program#5:

Enter first integer: 23

Enter second integer: 45

23 not equal to 45

23 is less than 45

 

Program #6:

The program prints if the input integer is even or odd.

 

·        Program Code

 

Output for Program#6:

 

Run#1:

Enter number: 23

23 is odd

 

Run#2:

Enter number: 44

44 is even