FOC Exercise Unit 1 and 2:

 
Assignment No1: 

Use goto Statement to Print Numbers from 1 to 5

Task: Write a program to print numbers from 1 to 5 using the goto statement.


Assignment No2:

Use break and continue in a Loop

Task: Write a program to print numbers from 1 to 10 but skip 5 and stop the loop when number reaches 8. 


Assignment No3:

Find the Sum of First N Natural Numbers Using a Do-While Loop

Task: Write a program to calculate the sum of first N natural numbers using a do-while loop.


Assignment No4:

Print Numbers from 1 to N Using a While Loop

Task: Write a program that takes an integer N from the user and prints numbers from 1 to N using a while loop.


Assignment No5:

Implicit and Explicit Type Conversion

Task: Write a program to demonstrate implicit and explicit type conversion.

  • Read an integer and a float.

  • Add them and store the result in a float variable.

  • Print the result.


Assignment No 6:

Use the Ternary Operator to Find the Maximum of Two Numbers

Task: Write a program that reads two numbers and uses the ternary operator to print the maximum.


Post a Comment

0 Comments