C SHARPE

PART-A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6

PART-B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

 
  
 
 
using System;

class Program
{
    static void Main()
    {
        // Calling a subroutine (method without a return value)
        GreetUser("John");

        // Calling a function (method with a return value)
        int sum = AddNumbers(5, 3);
        Console.WriteLine("Sum: " + sum);
    }

    // Subroutine: GreetUser
    // This method takes a name as a parameter and prints a greeting message.
    static void GreetUser(string name)
    {
        Console.WriteLine("Hello, " + name + "!");
    }

    // Function: AddNumbers
    // This method takes two parameters, adds them, and returns the result.
    static int AddNumbers(int a, int b)
    {
        int result = a + b;
        return result;
    }
}