1. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-1 MULTIPLICATION TABLE
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class mul
{
int no;
public void input()
{
Console.WriteLine("enter the number");
no = Convert.ToInt32(Console.ReadLine());
while (no <= 0)
{
Console.WriteLine("u entered an invaild no");
Console.WriteLine("enter a number great than 0:");
no = Convert.ToInt32(Console.ReadLine());
}
}
public void cal()
{
Console.WriteLine("multiplication table:");
for (int i = 1; i <= 10; i++)
{
Console.WriteLine(no + "*" + i + "=" + no * i);
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
2. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
mul mp = new mul();
mp.input();
mp.cal();
Console.ReadLine();
}
}
}
}
OUTPUT:
3. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-2 PERFECT NUMBER
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication7
{
class Perfectnumber
{
public void perfect()
{
int n, s = 0;
Console.WriteLine("PERFECT NUMBER CHECKING");
Console.WriteLine("give INPUT number");
n = Int32.Parse(Console.ReadLine());
for (int i = 1; i < n; i++)
if (n % i == 0)
s = s + i;
if (s == n)
{
Console.WriteLine("the given number is perfect number");
}
else
{
Console.WriteLine("the number is not a perfect number");
}
}
}
class subperfect
{
static void Main(string[] args)
{
int ch;
do
{
4. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
Perfectnumber pf = new Perfectnumber();
pf.perfect();
Console.WriteLine("Do U want to continue");
ch = Int32.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
OUTPUT:
5. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-3 ARMSTRONGNUMBER
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication10
{
class armstrong
{
public void armenthod()
{
int num, remainder, sum = 0;
Console.WriteLine("enter the number");
num = int.Parse(Console.ReadLine());
for (int i = num; i > 0; i = i / 10)
{
remainder = i % 10;
sum = sum + remainder * remainder * remainder;
}
if (sum == num)
{
Console.WriteLine("is args armstrong number");
}
else
{
Console.WriteLine("not a armstrong number");
}
}
}
class ppp
{
static void Main(string[] args)
{
int ch;
do
6. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
{
armstrong arm = new armstrong();
arm.armenthod();
Console.WriteLine("do u want to continue");
ch = Int32.Parse(Console.ReadLine());
Console.ReadLine();
} while (ch == 1);
}
}
}
OUTPUT:
7. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-4 PALINDROME NUMBER
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
class pali
{
int n, n1, r, s = 0;
public void input()
{
Console.WriteLine("enter the number to check number palindrome");
n = Int32.Parse(Console.ReadLine());
n1 = n;
}
public void cal()
{
while (n1 > 0)
{
r = n1 % 10;
n1 = n1 / 10;
s = r + (s * 10);
}
}
public void disp()
{
if (n == s)
{
Console.WriteLine("the number is a palindrome");
}
else
{
Console.WriteLine("the number is not palindrome");
}
}
8. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
class Program
{
static void Main(string[] args)
{
int ch;
do
{
pali p = new pali();
p.input();
p.cal();
p.disp();
Console.WriteLine("Do U want to continue");
ch = Int32.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
} }
OUTPUT:
9. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-5 SUM OF DIGIT
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication9
{
class sumdigits
{
public void sumdigit()
{
int n,r,sum=0;
Console.WriteLine("*************************");
Console.WriteLine("sum of digits of N nubers");
Console.WriteLine("*************************");
Console.WriteLine("enter the number");
n = Int32.Parse(Console.ReadLine());
while(n!=0)
{
r=n%10;
n=n/10;
sum=sum+r;
}
Console.WriteLine("sum of digits{0}",sum);
Console.ReadLine();
}
}
class sumd
{
static void Main(string[] args)
{
int ch;
do
{
sumdigits d=new sumdigits();
d.sumdigit();
Console.WriteLine("Do U want to continuen continue(1) exit(0)");
11. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-6 PRIME NUMBER WITH A RANGE
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication12
{
class prim
{
int i, j, n1, n2, p, q;
public void input()
{
Console.WriteLine("Enter the Starting Range Number");
n1 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the Ending Range Number");
n2 = int.Parse(Console.ReadLine());
p = n1;
q = n2;
Console.WriteLine("Prime number Range from {0} to {1} is", p, q);
}
public void calc()
{
for (i = p; i < q; i++)
{
for (j = 2; j <= (i / j); j++)
if (i % j == 0)
break;
if (j > (i / j))
{
Console.WriteLine("{0}", i);
}
}
}
}
class pr
12. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
{
static void Main(string[] args)
{
int ch;
do
{
Console.WriteLine("Prime Number Generation");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~");
prim p = new prim();
p.input();
p.calc();
Console.WriteLine("Do you want to perform again Press 1 or 0 to Exit");
ch = int.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
OUTPUT:
13. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-7 FLOYDS TRIANGLE
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication14
{
class floyds
{
int i, j, k = 1, n1;
public void input()
{
Console.WriteLine("Enter the Number");
n1 = int.Parse(Console.ReadLine());
}
public void calc()
{
for (i = 1; i <= n1; i++)
{
for (j = 1; j <= i + 1; j++)
{
Console.Write(k++ + " ");
}
Console.WriteLine("n");
}
Console.ReadLine();
}
}
class flower
{
static void Main(string[] args)
{
int ch;
14. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
do
{
Console.WriteLine("Floyd's Triangle");
Console.WriteLine("*********************");
floyds ff = new floyds();
ff.input();
ff.calc();
Console.WriteLine("Do you want to perform again Press 1 or 0 to
Exitn");
ch = int.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
OUTPUT:
15. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-8 ASCII VALUES
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class asc
{
string s;
public void input()
{
Console.WriteLine("Enter the sentence to find ascii code");
s = Console.ReadLine();
}
public void calc()
{
foreach (char c in s)
{
Console.WriteLine((int)c);
}
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Find Ascii Value string");
Console.WriteLine("*****************");
asc a = new asc();
a.input();
a.calc();
Console.ReadLine();
}
}
}
16. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
OUTPUT:
17. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-9 FACTORS OF A GIVEN NUMBER
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication12
{
class prim
{
int i, j, n1, n2, p, q;
public void input()
{
Console.WriteLine("Enter the Starting Range Number");
n1 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the Ending Range Number");
n2 = int.Parse(Console.ReadLine());
p = n1;
q = n2;
Console.WriteLine("Prime number Range from {0} to {1} is", p, q);
}
public void calc()
{
for (i = p; i < q; i++)
{
for (j = 2; j <= (i / j); j++)
if (i % j == 0)
break;
if (j > (i / j))
{
Console.WriteLine("{0}", i);
}
}
}
}
class pr
18. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
{
static void Main(string[] args)
{
int ch;
do
{
Console.WriteLine("Prime Number Generation");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~");
prim p = new prim();
p.input();
p.calc();
Console.WriteLine("Do you want to perform again Press 1 or 0 to Exit");
ch = int.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
OUTPUT:
19. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-10 (A)CONVERT DECIMAL TO BINARY
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication28
{
class conv
{
public void esdectobin()
{
Console.WriteLine("Converting Decimal value to binary value");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
int num, quot, n;
string rem = "";
string bin = "";
Console.WriteLine("Enter the number");
num = int.Parse(Console.ReadLine());
n = num;
while (num >= 1)
{
quot = num / 2;
rem += (num % 2).ToString();
num = quot;
}
//Reversing the Value
for (int i = rem.Length - 1; i >= 0; i--)
{
bin = bin + rem[i];
}
Console.WriteLine("nThe binary format for {0} is {1}", n, bin);
}
20. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
class Program
{
static void Main(string[] args)
{
int ch;
do
{
conv d = new conv();
d.esdectobin();
Console.WriteLine("Do U want to continue");
ch = Int32.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
}
OUTPUT:
21. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-10 (B)CONVERT BINARYTO DECIMAL
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication29
{
class conv
{
public void esbintodec()
{
Console.WriteLine("Converting binary value to decimal value");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
int rem, num, bvalue, dvalue = 0, basevalue = 1;
Console.WriteLine("Enter the number");
num = int.Parse(Console.ReadLine());
bvalue = num;
while (num > 0)
{
rem = num % 10;
dvalue = dvalue + rem * basevalue;
num = num / 10;
basevalue = basevalue * 2;
}
Console.Write("nBinary number {0} equivalent decimal number is {1}",
bvalue, dvalue);
}
class Program
{
static void Main(string[] args)
22. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
{
int ch;
do
{
conv d = new conv();
d.esbintodec();
Console.WriteLine("Do U want to continue");
ch = Int32.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
}
OUTPUT:
23. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-10 (C) CONVERT DECIMALTO OCTAL
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication32
{
class conv
{
public void esdectohexa()
{
Console.WriteLine("Converting Decimal value to hexa value");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
int n, decimelnum, quot, i = 1, j, temp = 0;
char[] hexnum = new char[100];
char temp1;
Console.WriteLine("Enter the number");
decimelnum = int.Parse(Console.ReadLine());
n = decimelnum;
quot = decimelnum;
while (quot != 0)
{
temp = quot % 16;
if (temp < 10)
temp = temp + 48;
else
temp = temp + 55;
temp1 = Convert.ToChar(temp);
hexnum[i++] = temp1;
quot = quot / 16;
24. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
}
Console.Write("nDecimal number {0} equivalent Hexadecimal number is
", n);
for (j = i - 1; j > 0; j--)
Console.Write("{0}", hexnum[j]);
}
class Program
{
static void Main(string[] args)
{
int ch;
do
{
conv d = new conv();
d.esdectohexa();
Console.WriteLine("Do U want to continue");
ch = Int32.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
}
OUTPUT:
25. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
LABLIST:1 EX.NO-10 (D)CONVERT DECIMALTO HEXADECIMAL
SOURCE CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication32
{
class conv
{
public void esdectohexa()
{
Console.WriteLine("Converting Decimal value to hexa value");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
int n, decimelnum, quot, i = 1, j, temp = 0;
char[] hexnum = new char[100];
char temp1;
Console.WriteLine("Enter the number");
decimelnum = int.Parse(Console.ReadLine());
n = decimelnum;
quot = decimelnum;
while (quot != 0)
{
temp = quot % 16;
if (temp < 10)
temp = temp + 48;
else
temp = temp + 55;
temp1 = Convert.ToChar(temp);
hexnum[i++] = temp1;
quot = quot / 16;
26. SUB NAME: .NET PROGRAMMING
Dr.M.KarthikaITDepartment
}
Console.Write("nDecimal number {0} equivalent Hexadecimal number is
", n);
for (j = i - 1; j > 0; j--)
Console.Write("{0}", hexnum[j]);
}
class Program
{
static void Main(string[] args)
{
int ch;
do
{
conv d = new conv();
d.esdectohexa();
Console.WriteLine("Do U want to continue");
ch = Int32.Parse(Console.ReadLine());
Console.ReadLine();
}
while (ch == 1);
}
}
}
}
OUTPUT: