0% found this document useful (0 votes)
11 views6 pages

01

The document contains three C# code examples demonstrating basic programming concepts. The first example calculates the total and average of two marks, the second swaps two numbers without a temporary variable, and the third splits a two-digit number into its individual digits. Each code snippet includes user input and output statements.

Uploaded by

Sarathi M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

01

The document contains three C# code examples demonstrating basic programming concepts. The first example calculates the total and average of two marks, the second swaps two numbers without a temporary variable, and the third splits a two-digit number into its individual digits. Each code snippet includes user input and output statements.

Uploaded by

Sarathi M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1)

Code:

using System;

Class Mark

Static void Main()

Console.Write(“Enter English mark: “);

int m1 = int.Parse(Console.ReadLine());

Console.Write(“Enter Mathematics mark: “);

int m2 = int.Parse(Console.ReadLine());

int total = m1 + m2;

int average = total / 2;

Console.WriteLine(“Total Marks: “ + total);

Console.WriteLine(“Average Marks: “ + average);

Output:
2)
Code:

using System;

Class Swapping

Static void Main()

Console.Write(“Enter first number: “);

int a = int.Parse(Console.ReadLine());

Console.Write(“Enter second number: “);

Int b= int.Parse(Console.ReadLine());

a = a + b;

b = a – b;

a = a – b;

Console.WriteLine(“a =”+a);

Console.WriteLine(“b =”+b);

}
Output:
3)

Code:

Using System;

Class Split

Static void Main()

Console.Write(“Enter a 2-digit number: “);

int n = int.Parse(Console.ReadLine());

int firstDigit = n / 10;

int secondDigit = n % 10;

Console.WriteLine(“First digit: “ + firstDigit);

Console.WriteLine(“Second digit: “ + secondDigit);

}
Output:

You might also like