Вы находитесь на странице: 1из 17

Assignment

For
Enterprise Application Development
Semester IT 7th

Assignment No. 02
Name Muhammad Hashim
Roll No. 052
Course Instructor Mam Fanila

Department OF Computer Science


Q.No:1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Number_Is_Large_or_Equal
{
class Program
{
static void Main(string[] args)
{
int n;
int n1;
Console.WriteLine("Enter First Number");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Second Number");
n1 = int.Parse(Console.ReadLine());
if (n > n1)
{
Console.WriteLine("First Number is Large");
}
else
if (n == n1)
{
Console.WriteLine("These Numbers are Equal");
} else
{
Console.WriteLine("Second Number is Larger");
}

Console.ReadKey();
}
}
}
Q.No:2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diamond
{
class Program
{
static void Main(string[] args)
{

int S;
Console.WriteLine("Enter size of Diamond: ");
S = int.Parse(Console.ReadLine());

int x = 1;

for (int a = 0; a <= S; a++)


{
for (int b = S; b > a; b--)
{
Console.Write(" ");
}

Console.Write("*");

if (a > 0)
{
for (int c = 1; c <= x; c++)
{
Console.Write(" ");
}
x += 2;
Console.Write("*");
}
Console.WriteLine("");
}

x -= 4;

for (int a = 0; a <= S - 1; a++)


{
for (int b = 0; b <= a; b++)
{
Console.Write(" ");
}

Console.Write("*");

for (int c = 1; c <= x; c++)


{
Console.Write(" ");
}
x -= 2;

if (a != S - 1)
{
Console.Write("*");
}
Console.WriteLine(""); ;
}

Console.ReadKey();

}
}
}

Q.No:3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Even_or_Odd
{
class Program
{
static void Main(string[] args)
{
int n;
Console.WriteLine("Enetr Any Number");
n = Convert.ToInt32(Console.ReadLine());

if (n% 2 == 0)
{
Console.WriteLine("The Number is Even");

}
else
{
Console.WriteLine("The Number is Odd");

}
Console.ReadKey();
}
}
}
Q.No:4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Five_Digit
{
class Program
{
static void Main(string[] args)
{
int n1,n2,n3,n4,n5;
int Sep;

Console.WriteLine("Please Enter a Five Digit Number: ");


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

n5 = Sep % 10;
n4 = (Sep / 10) % 10;
n3 = (Sep / 100) % 10;
n2 = (Sep / 1000) % 10;
n1 = (Sep / 10000) % 10;

Console.WriteLine("{0} {1} {2} {3} {4} ", n1, n2, n3, n4, n5);
Console.ReadLine();
}
}
}

Q.No:5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Escape_Sequence
{
class Program
{
static void Main(string[] args)
{
int counter = 0;

Console.WriteLine("N\t10*N\t100*N\t1000*N\n");
while (counter++ < 5)
{
Console.WriteLine("{0}\t{1}\t{2}\t{3}", (counter), (counter*10),
(counter*100), (counter*1000));
}
Console.ReadKey();
}
}
}
Q.No:6
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace plaindrome
{
class Program
{
static void Main(string[] args)
{
int n, temp, remainder, rev = 0;
Console.WriteLine("Enter an integer:");
n = int.Parse(Console.ReadLine());
temp = n;
while (n > 0)
{
remainder = n % 10;
rev = rev * 10 + remainder;
n /= 10;
}

if (temp == rev)
{
Console.WriteLine("Number is a palindrome \n");
}
else
{
Console.WriteLine("Number is not a palindrome \n");
}Console.ReadKey();

}
}
}

Q.N0:7
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Factorial
{
class Program
{
public void fact()
{
int fac = 1;
Console.WriteLine("Enter Any Number:");
int num = int.Parse(Console.ReadLine());
while(num>=1 )
{
fac = fac * num;
num--;
}
Console.WriteLine(fac);

}
static void Main(string[] args)
{
Program pr = new Program();
pr.fact();
Console.ReadKey();
}
}
}

Q.No:8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BMI_Calculator
{
class Program
{
static void Main(string[] args)
{

int weight;
double height;
double bMI;

Console.WriteLine("Enter Your Weight in Pounds: ");


weight = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Your Height in Inches: ");
height = double.Parse(Console.ReadLine());
bMI = (weight * 703) / (height * height);
Console.WriteLine("Your Body Mass Index (BMI) is %d\n\n", bMI);
Console.WriteLine("BMI VALUES");
Console.WriteLine("Underweight: less than 18.5");
Console.WriteLine("Normal: between 18.5 and 24.9");
Console.WriteLine("Overweight: between 25 and 29.9");
Console.WriteLine("Obese: 30 or greater");

Console.ReadKey();

}
}
}

Q.No:9
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Half_pyramid
{
class Program
{
static void Main(string[] args)
{

for (int a = 1; a <= 5; a++)


{
for (int b = 1; b <= a; b++)
{
Console.Write("* ");
}
Console.WriteLine("");

}
Console.ReadKey();
}
}
}

Q.No:10
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Half_Pyramid_Reverse
{
class Program
{
static void Main(string[] args)
{

for(int a= 5; a>=1; a--)


{
for (int b = 0; b < a; b++)
{
Console.Write("* ");
}
Console.WriteLine("");
}
Console.ReadKey();

}
}
}

Q.No:11
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Full_Pyramid
{
class Program
{
static void Main(string[] args)
{

for(int a = 1; a <=5; a++)


{
for(int b=1; b <= 5-a; b++)
{
Console.Write(" ");
}
for (int c = 1; c <= (a*2)-1; c++)
{
Console.Write("*");
}
Console.WriteLine("");
}

Console.ReadKey();
}
}
}

Q.No:12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Calculator2
{
class Program
{
static void Main(string[] args)
{
double result = 0;
int Operation = 0;

Console.WriteLine("Enter First Number:");


string stringFirstNumber = Console.ReadLine();
double firstNumber = Convert.ToDouble(stringFirstNumber);

Console.WriteLine("Enter Second Number:");


string stringSecondNumber = Console.ReadLine();
double secondNumber = Convert.ToDouble(stringSecondNumber);
Console.WriteLine("Press a key followed by ENTER: +(addition), -
(subtraction), *(Mulitiplication), /(Division)");
Operation = char.Parse(Console.ReadLine());

switch (Operation)
{
case '+':
result = firstNumber + secondNumber;
break;
case '-':
result = firstNumber - secondNumber;
break
;
case '*':
result = firstNumber * secondNumber;
break;
case '/':
result = firstNumber / secondNumber;
break;
default:
result = 0;
break;
}
Console.WriteLine("\nResult of " + firstNumber + " " + secondNumber + " = " +
result + " ");

Console.ReadKey();

}
}
}

Вам также может понравиться