TASK 01:: Name: Syed Tanzeel Ur Rehman ROLL NO: 2020-BSCS-037 Sec: A
TASK 01:: Name: Syed Tanzeel Ur Rehman ROLL NO: 2020-BSCS-037 Sec: A
TASK 01:
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CA2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Name: Syed Tanzeel ur Rehman");
Console.WriteLine("Father's Name: Syed Muhammad Asif");
Console.WriteLine("Contact NO: 03367479229");
Console.WriteLine("Email Address: [email protected]");
Console.WriteLine("Address: Flat # B-10, Amin Court Block 'M'
North Nazimabad Karachi.");
Console.ReadKey();
}
}
}
OUTPUT:
TASK 02:
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CA2
{
class Program
{
static void Main(string[] args)
{
up:
string x;
double y;
Console.WriteLine(" *NATIONAL EARTHQUAKE INFORMATION CENTER* ");
Console.WriteLine(" ENTER SCALE VALUE : ");
x = Console.ReadLine();
y = Convert.ToDouble(x);
if (y < 5.0)
{
Console.WriteLine(" Little or No Damage ");
}
else if (y >= 5.0 && y < 5.5)
{
Console.WriteLine(" Some Damage ");
}
else if (y >= 5.5 && y < 6.5)
{
Console.WriteLine(" Serious Damage: (Walls May Crack Or Fall) ");
}
else if (y >= 6.5 && y < 7.5)
{
Console.WriteLine(" Disaster: (Houses May Collapse) ");
}
else
{
Console.WriteLine(" Catastrophe: (Most Buildings Destroyed) ");
}
goto up;
Console.ReadKey();
}
}
}
OUTPUT:
TASK 03:
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CA2
{
class Program
{
static void Main(string[] args)
{
string x;
double far, cel, kel;
Console.WriteLine("Enter Temperature in Farenheit: ");
x = Console.ReadLine();
far = Convert.ToDouble(x);
cel = 5 * (far - 32) / 9;
Console.WriteLine("Temperature in Celsius is: {0}", cel);
kel = cel + 273;
Console.WriteLine("Temperature in Kelvin is: {0}", kel);
Console.ReadKey();
}
}
}
OUTPUT:
TASK 04:
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CA2
{
class Program
{
void swap(int a, int b)
{
a = a + b;
b = a - b;
a = a - b;
Console.WriteLine("After Swapping a = {0} and b = {1}", a, b);
}
static void Main(string[] args)
{
string str;
int x, y;
Program n1 = new Program();
Console.WriteLine("Swapping Numbers");
Console.WriteLine("Enter first Number: ");
str = Console.ReadLine();
x = Convert.ToInt32(str);
Console.WriteLine("Enter second Number: ");
str = Console.ReadLine();
y = Convert.ToInt32(str);
Console.WriteLine("Before Swapping a = {0} and b = {1}", x, y);
n1.swap(x, y);
Console.ReadKey();
}
}
}
OUTPUT:
TASK 05:
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CA2
{
class Program
{
int smallest(int[] a)
{
int min = a[0];
for (int i = 0; i < 4; i++)
{
if (min > a[i])
{
min = a[i];
}
}
return min;
}
int largest(int[] a)
{
int max = a[0];
for (int i = 0; i < 4; i++)
{
if (max < a[i])
{
max = a[i];
}
}
return max;
}
int average(int[] a)
{
int sum = 0, avg = 0;
for (int i = 0; i < 4; i++)
{
sum += a[i];
}
avg = sum / 4;
return avg;
}
static void Main(string[] args)
{
string s;
int[] num = { 0, 0, 0, 0 };
Program n1 = new Program();
for (int i = 0; i < 4; i++)
{
Console.WriteLine("Enter {0} Number: ", i + 1);
s = Console.ReadLine();
num[i] = Convert.ToInt32(s);
}
Console.WriteLine("The smallest of the given numbers is: {0} ",
n1.smallest(num));
Console.WriteLine("The largest of the given numbers is: {0} ",
n1.largest(num));
Console.WriteLine("The average of the given numbers is: {0} ",
n1.average(num));
Console.ReadKey();
}
}
}
OUTPUT:
TASK 06:
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CA2
{
class Program
{
int Multiple(int x, int y)
{
if (x % y == 0)
{
return 1;
}
else
{
return 0;
}
}
static void Main(string[] args)
{
string str;
int x, y;
Program n1 = new Program();
Console.WriteLine("Enter First Number: ");
str = Console.ReadLine();
x = Convert.ToInt32(str);
Console.WriteLine("Enter First Number: ");
str = Console.ReadLine();
y = Convert.ToInt32(str);
Console.WriteLine(n1.Multiple(x, y));
Console.ReadKey();
}
}
}
OUTPUT: