Visual Programming Practical Sheet for Class 12
Visual Programming Practical Sheet for Class 12
Definition of C#:
Development of C#.NET
Features of C#.NET
• Rich Library: Extensive library for handling files, databases, networking, etc.
This program demonstrates the use of multiple conditions using if, else if, and else.
using System;
class Program
int x = 20;
if (x > 50)
{
else if (x == 20)
Console.WriteLine("Equal to 20");
else
Explanation:
• The program checks whether the value of x is greater than 50, equal to 20, or less
than 20 and prints the corresponding message.
using System;
class Program
Console.WriteLine(i);
Explanation:
• The for loop starts from i = 0 and runs until i reaches 4, printing the value of i at each
iteration.
using System;
class Program
int[,] matrix = { { 1, 2 }, { 3, 4 } };
Console.WriteLine("Matrix Elements:");
{
for (int j = 0; j < 2; j++)
Console.WriteLine();
Explanation:
• This program creates a 2x2 matrix and prints the elements of the matrix row by row.
This program demonstrates the use of string methods to manipulate and display a string.
using System;
class Program
// Create a string
// Convert to uppercase
Explanation:
This program demonstrates the use of a switch statement to perform basic arithmetic
operations based on user input.
using System;
class Program
string operation;
// User input for numbers and operation
num1 = Convert.ToDouble(Console.ReadLine());
num2 = Convert.ToDouble(Console.ReadLine());
operation = Console.ReadLine();
switch (operation)
case "+":
break;
case "-":
break;
case "*":
case "/":
if (num2 != 0)
else
break;
default:
break;
Explanation:
• The program prompts the user for two numbers and a mathematical operator.
• It uses a switch statement to perform the correct operation based on the user's
input (+, -, *, or /).
• If the user enters an invalid operation or attempts to divide by zero, it handles the
error accordingly