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

c#1 1

The document contains five C# programs authored by Snehal Patil, a student in Division B with Roll No 239. The programs demonstrate basic programming concepts such as addition of two numbers, swapping two numbers, printing a multiplication table, calculating the area of a circle, and computing the factorial of a given number. Each program includes user input and outputs the results accordingly.

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

c#1 1

The document contains five C# programs authored by Snehal Patil, a student in Division B with Roll No 239. The programs demonstrate basic programming concepts such as addition of two numbers, swapping two numbers, printing a multiplication table, calculating the area of a circle, and computing the factorial of a given number. Each program includes user input and outputs the results accordingly.

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

Name : Snehal Patil

Div : B
Roll No : 239

Program 1 : Program for addition of 2 numbers.


using System;

class Program
{
static void Main()
{
Console.WriteLine("Name:Snehal Satappa Patil ");

Console.WriteLine("Roll No:239 ");


Console.WriteLine("Div:B ");

int num1, num2, sum;

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


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

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


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

sum = num1 + num2;

Console.WriteLine("The sum of " + num1 + " and " + num2 + " is: " + sum);
}
}
Output:
Program 2 : Program for swaping of 2 numbers.
using System;

public class swapping


{

public static void Main(string[] args)


{
Console.WriteLine("Name:Snehal Satappa Patil");
Console.WriteLine("Div:B ");
Console.WriteLine("Roll No:239 ");
int num1, num2, temp;

Console.WriteLine("Input the First Number : ");


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

Console.WriteLine("Input the Second Number : ");


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

temp = num1;
num1 = num2;
num2 = temp;

Console.Write("\nAfter Swapping : ");


Console.Write("\nFirst Number : " + num1);
Console.Write("\nSecond Number : " + num2);

Console.Read();
}

Output:
Program 3 : Program to print table of any number.
using System;
public class table
{
public static void Main(string[] args)
{
Console.WriteLine("Name:Snehal Satappa Patil");
Console.WriteLine("Div:B ");
Console.WriteLine("Roll No:239 ");

int n, i, t = 0;
Console.Write("Enter a number:");
n = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Table is:");
for (i = 1; i <= 10; i++)
{
t = n * i;
Console.WriteLine(t);
}

}
}
Output:
Program 4 : Program to print area of circle.
using System;
using System.Formats;
public class Circlearea
{
public static void Main(string[] args)
{
Console.WriteLine("Name:Snehal Satappa Patil");
Console.WriteLine("Div:B ");
Console.WriteLine("Roll No:239 ");

int r;
double pi = 3.14;
Console.Write("Enter a radius:");
r = Convert.ToInt32(Console.ReadLine());

double area = pi * r * r;

Console.WriteLine("Area of circle is:" +area);

}
}

Output:
Program 5 : Program to print factorial of given number.
using System;
public class FactorialExample
{
public static void Main(string[] args)
{
Console.WriteLine("Name:Snehal Satappa Patil");
Console.WriteLine("Div:B ");
Console.WriteLine("Roll No:239 ");
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