Select an option to see the answer and solution.
Miscellaneous in C Sharp
practice.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
170
Questions
5/9
Page
Pick an option on a question to see the right answer and solution.
class Program
{
static void Main(string[] args)
{
double x = 2.0;
double y = 3.0;
double z = Math.Pow( x, y );
Console.WriteLine(z);
Console.ReadLine();
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
class Program
{
static void Main(string[] args)
{
double x = 3.14;
int y = (int) Math.Ceiling(x);
Console.WriteLine(y);
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
class MyClass
{
int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
public IEnumerator GetEnumerator()
{
for (int i = 0; i < 20; i++)
{
if (a[i] % 2 == 0)
yield return (int)(a[i]);
}
}
}
class Program
{
static void Main(string[] args)
{
MyClass mc = new MyClass();
foreach (int i in mc)
Console.Write(i + " ");
Console.WriteLine();
Console.ReadLine();
}
}Select an option to see the answer and solution.
#define DEBUG
#define MYTEST
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
#if (DEBUG && !MYTEST)
Console.WriteLine("DEBUG is defined");
#elif (!DEBUG && MYTEST)
Console.WriteLine("MYTEST is defined");
#elif (DEBUG && MYTEST)
Console.WriteLine("DEBUG and MYTEST are defined");
#else
Console.WriteLine("DEBUG and MYTEST are not defined");
#endif
Console.ReadLine();
}
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
static void main(String args[])
{
char chars[] = {'a', 'b', 'c'};
String s = new String(chars);
Console.WriteLine(s);
}Select an option to see the answer and solution.
class Program
{
static void Main(string[] args)
{
String c = " Hello World ";
String s = c.Trim();
Console.WriteLine("""+s+""");
Console.ReadLine();
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
class Program
{
static void Main(string[] args)
{
String s = "Hello World";
int i = s.IndexOf('o');
int j = s.LastIndexOf('l');
Console.WriteLine(i + " " + j);
Console.ReadLine();
}
}Select an option to see the answer and solution.
Select an option to see the answer and solution.
i. System.Nullable count;
ii. bool? done;Select an option to see the answer and solution.
public class A
{
public int x;
public int y;
public void display()
{
Console.WriteLine(x + " " + y);
}
}
class Program
{
static void Main(string[] args)
{
A obj1 = new A();
A obj2 = new A();
obj1.x = 1;
obj1.y = 2;
obj2 = obj1;
obj1.display();
obj2.display();
}
}Select an option to see the answer and solution.
Q100
Open questionSelect an option to see the answer and solution.