Sunteți pe pagina 1din 8

PROBLEME C#

1. Sa se scrie o aplicatie care afiseaza valoarea constantei PI.(pi)

using System;

namespace pi
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
Console.WriteLine(Math.PI);

}
}
}

2. Sa se afiseze valoarea expresiei 18+x-5, unde x este de tip int si este


initializat cu 10.(ecuatie)

using System;
namespace ecuatie
{
///<summary>
/// Summary descriptiom for Class1.
/// </summary>
class Class1
{
///<summary>
/// The main entry point for the aplication.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Add code start applicatin here
//
int x = 10;
Console.WriteLine(18+x-5);
}
}
}

3. Sa se scrie o aplicatie care declaravariabilele a si b tip int, initializandu-le,


pe a cu 3, iar pe b cu 987654321 si apoi afiseaza valoarea produsului
dintre a si b.(produs)

using System;
namespace produs
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
int a=3, b=987654321;
Console.WriteLine ((uint)a*b);
}
}
}

4. Sa se scrie o aplicatie care stabileste semnul expresiei 3*x*x-7*x+4 pentru


x=1.2. Aplicatia va afisa True daca expresia 3*x*x-7*x+4>0 pentru x=1.2
si False altfel.(semn)

using System;
namespace semn
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
float x=1.2F;
Console.WriteLine(3 * x * x - 7 * x + 4 > 0);
}
}
}
5. Sa se scrie o aplicatie care sa testeze daca valoarea 0.5, de tip double, este
solutie a ecuatiei x*x-3*m*x+1.25m=0.(test)

using System;
namespace test
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
double x = .5;
Console.WriteLine((decimal)x * (decimal)x - 3m * (decimal)x
+ 1.25m == 0);
}
}
}

6. Sa se scrie o aplicatie care afiseaza cu 15 cifre valoarea expresiei 1/(n+1),


unde n este o variabila de tip int initializata cu 6.(cifre)

using System;
namespace cifre
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
int n = 6;
Console.WriteLine("1/(6+1)={0}\t{1}",1 / (n + 1),(1 / (n +
1)).GetType());
Console.WriteLine("1/(6+1)={0}\t{1}",1.0 /(n + 1),(1.0 / (n
+ 1)).GetType());
}
}
}

7. Sa se scrie o aplicatie care determina daca un an calendaristic este bisesct


sau nu.(an_bisect)

using System;
namespace an_bisect
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
Console.WriteLine("Anul 2004 este bisect deoarece:");
Console.WriteLine("{0}%4==0&&{1}%100!=0||{2}%400==0 are
valoarea {3}", 2004, 2004, 2004, 2004 % 4 == 0 && 2004 % 100 != 0 ||
2004 % 400 == 0);
Console.WriteLine("Anul 2005 nu este bisect deoarece:");
Console.WriteLine("{0}%4==0&&{1}%100!=0||{2}%400==0 are
valoarea {3}", 2005, 2005, 2005, 2005 % 4 == 0 && 2005 % 100 != 0 ||
2005 % 400 == 0);
Console.WriteLine("Anul 2008 este bisect deoarece:");
Console.WriteLine("{0}%4==0&&{1}%100!=0||{2}%400==0 are
valoarea {3}", 2008, 2008, 2008, 2008 % 4 == 0 && 2008 % 100 != 0 ||
2008 % 400 == 0);
Console.WriteLine("Anul 2010 nu este bisect deoarece:");
Console.WriteLine("{0}%4==0&&{1}%100!=0||{2}%400==0 are
valoarea {3}", 2010, 2010, 2010, 2010 % 4 == 0 && 2010 % 100 != 0 ||
2010 % 400 == 0);
}
}
}

8. Sa se scrie o aplicatie care afiseaza maximul dintre valorile a doua


variabile, una de tip int si una de tip double.(max)

using System;
namespace max
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
int i = 10;
double d = -10;
Console.WriteLine("max({0},{1})={2}", i, d, i > d ? i : d);
}
}
}
9. Sa se scrie o aplicatie care testeza apartenenta valorilor variadilei x la
intervalul [-3,7]. Se vor testa valorile 4 si -4.(interval)

using System;
namespace interval
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
int x = 4;
Console.WriteLine("{0}>=-3 && {1}<=7 are valoarea:{2}", x,
x, x >= -3 && x <= 7);
int y = -4;
Console.WriteLine("{0}>=-3 && {1}<=7 are valoarea:{2}", y,
y, y >= -3 && y <= 7);
}
}
}

10. Sa se scrie o aplicatie care evalueaza expresii ce contin operatoul de


indexare pentru a accesa elementele unui tablou unidimensional.(index)

using System;
namespace interval
{

/// <summary>
/// Summary desciption for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
//TODO: Addcode to start aplication here
//
double [] tab={1,2,3,4,5,6,7,8,9};
long[] tab1 ={ 0, 1 };
long lg=1;
int i=2;
int j=-3;
Console.WriteLine("double [] tab={1,2,3,4,5,6,7,8,9};");
Console.WriteLine("long [] tab1={0,1};");
Console.WriteLine("tab [0]={0}",tab[0]);
Console.WriteLine("tab [7]={0}",tab[7]);
Console.WriteLine("tab [{0}]={1}",lg, tab[lg]);
Console.WriteLine("tab [tab1[1]+4]={0}",tab[tab1[1]+4]);
Console.WriteLine("tab [3*{0}={1}]={2}",i,j,tab[3*i+j]);
}
}
}

S-ar putea să vă placă și