0% found this document useful (0 votes)
32 views6 pages

Fa19 Bse 066

The document contains code snippets and explanations for 5 questions on C# programming concepts like loops, arrays, methods, user input, and prime number checking. The code examples demonstrate basic syntax and usage of common data types and operations in C#.

Uploaded by

Hassan Sajid
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)
32 views6 pages

Fa19 Bse 066

The document contains code snippets and explanations for 5 questions on C# programming concepts like loops, arrays, methods, user input, and prime number checking. The code examples demonstrate basic syntax and usage of common data types and operations in C#.

Uploaded by

Hassan Sajid
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/ 6

QNo1:

Ans:-

```*using System;

public class Input

static public void Main ()

Console.WriteLine(" *\n ***\n *****\n *******\n *******\n *****\n ***\n *");

*```

QNo2(A)

Ans:-

Console.WriteLine("Enter a :");

int a = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter b :");

int b = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter c :");

int c = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter d :");

int d = Convert.ToInt32(Console.ReadLine());

double part1=((Math.Pow(a,2)-Math.Pow(b,2))*(3*a*d))

/ (Math.Pow(c,2)-Math.Pow(b,2));
double part2=(a*b)/(a+b/d);

Console.WriteLine(part1+part2);

QNo2(B)

Console.WriteLine("Enter a :");

int a = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter b :");

int b = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter c :");

int c = Convert.ToInt32(Console.ReadLine());

int part1=((a+b)/(a-b))+ Convert.ToInt32( Math.Pow(b,2));

int part2=(c-(4*b*c))/(a-b*c);

Console.WriteLine(part1+part2);

QNo3:

Ans:- for(int x=10;x<=200;x++)

if(x%2!=0){

string parsedNum=Convert.ToString(x);

Console.WriteLine(new string( parsedNum.Reverse().ToArray())+"


reversed odd number");

}
public class MyWork

public static void Main()

for(int x=10;x<=200;x++)

if(isPrime(x)){

Console.WriteLine(x+" is prime");

public static bool isPrime(int num){

for(int m=2;m<num;m++){

if(num%m==0)

return false;

}
return true;

QNo4:

Ans:-

class Program

static void Main(string[] args)

int x = 1;

while (x <= 5)

Console.WriteLine("Enter your {0} number greater than 10",x);

int no = Convert.ToInt32(Console.ReadLine());

if (no < 10)

Console.WriteLine("Your entered number is invalid");

else

Console.WriteLine(" Your number is "+no);

x++;
}

QNo5:

Ans:-

int n1,n2,n3,n4,n5,n6;

Console.WriteLine("Input 1st lumber :");

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

Console.WriteLine("Input 2nd lumber :");

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

Console.WriteLine("Input 3rd lumber :");

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

Console.WriteLine("Input 4th lumber :");

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

Console.WriteLine("Input 5th lumber :");

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

Console.WriteLine("Input 6th lumber :");

n6=Convert.ToInt32(Console.ReadLine());
int[] list=new int[]{n1,n2,n3,n4,n5,n6};

int[] filter=list.Distinct().ToArray();

foreach(int tn in filter){

int count=0;

foreach(int temp in list){

if(tn==temp){count++;}

Console.WriteLine( tn+" occurred "+ count+ " time(s)");

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy