0% found this document useful (0 votes)
5 views5 pages

Experiment No 2shraddha

The document presents a series of programming exercises completed by Shraddha Amar Salokhe, including adding two numbers, swapping numbers with and without a third variable, creating a multiplication table, and calculating the factorial of a number. Each exercise is accompanied by C# code and output examples. The document emphasizes basic programming concepts and user input handling.

Uploaded by

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

Experiment No 2shraddha

The document presents a series of programming exercises completed by Shraddha Amar Salokhe, including adding two numbers, swapping numbers with and without a third variable, creating a multiplication table, and calculating the factorial of a number. Each exercise is accompanied by C# code and output examples. The document emphasizes basic programming concepts and user input handling.

Uploaded by

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

EXPERIMENT NO:01

Name: Shraddha Amar Salokhe


Roll no: 248
Div: B

1:Write a program to Add two Numbers.


using System;

class Addition
{
static void Main()
{
Console.WriteLine("Name: Shraddha Amar Salokhe, Roll no:248 ,Div:B");
int num1, num2, sum;
Console.WriteLine("Calculate the sum of two numbers:");
Console.Write("Input number1:");
num1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Input number2:");
num2 = Convert.ToInt32(Console.ReadLine());
sum = num1 + num2;
Console.Write("Result:" + sum);

Console.ReadKey();
}
}
OUTPUT:

2: Swap two numbers by using third variable.\using System;

namespace Swap
{
class Program
{
static void Main(string[] args)
{
int num1, num2, temp;
Console.WriteLine("Name: Shraddha Amar Salokhe, Roll no:248, Div:B");

Console.Write("Enter the first number: ");


num1 = Convert.ToInt32(Console.ReadLine());

Console.Write("Enter the second number: ");


num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Before swapping: number1 = " + num1 + " and number2 = " +
num2);
temp = num1;
num1 = num2;
num2 = temp;
Console.WriteLine("After swapping: number1 = " + num1 + " and number2 = " +
num2);
Console.ReadKey();
} }}

OUTPUT:

3.Swap two numbers without using third variable.

using System;

namespace Swapw
{
class Program
{
static void Main(string[] args)
{
int num1, num2;
Console.WriteLine("Name: Shraddha Amar Salokhe, Roll no:248, Div: B");
Console.Write("Enter the number one: ");
num1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the number two: ");
num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Before swapping: number 1 = " + num1 + " and number 2 = " +
num2);
num1 = num1 + num2;
num2 = num1 - num2;
num1 = num1 - num2;

Console.WriteLine("After swapping: number1 = " + num1 + " and number2 = " +


num2);

Console.ReadKey();
}
}
}

OUTPUT:

4.write a program to create a table .

using System;

namespace table
{
class tab
{
static void Main(string[] args)
{
int num, i;
Console.WriteLine("Name: Shraddha Amar Salokhe, Roll no:248, Div: B");
Console.Write("Enter the number: ");
num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Table of " + num + ":");
for (i = 1; i <= 10; i++)
{
Console.WriteLine( num * i);
}

Console.ReadKey();
} }}

OUTPUT:

5.Write a program to find factorial of a number.

using System;
public class Factorial
{
public static void Main(string[] args)
{
Console.WriteLine("Name: Shraddha Amar Salokhe, Roll no:248, Div: B");
int i, fact = 1, number;
Console.Write("Enter any Number: ");
number = int.Parse(Console.ReadLine());
for (i = 1; i <= number; i++)
{
fact = fact * i;
}
Console.Write("Factorial of " + number + " is: " + fact);
}
}

OUTPUT:

You might also like