Assignments of visual programming, Quizzes of Software Engineering

C# Programming for beginners level. from these lecture you can easily understand the basic of c#

Typology: Quizzes

2020/2021

Uploaded on 05/08/2021

humaira-humaira
humaira-humaira 🇵🇰

5

(1)

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Integer Data Type
byte centuries = 20; // Usually a small number
ushort years = 2000;
uint days = 730480;
ulong hours = 17531520; // May be a very big number
Console.WriteLine("{0} centuries is {1} years, or {2} days, or {3} hours.", centuries, years, days, hours);
2. Precision Example
float floatPI = 3.141592653589793238f;
double doublePI = 3.141592653589793238;
Console.WriteLine("Float PI is: {0}", floatPI);
Console.WriteLine("Double PI is: {0}", doublePI);
3. Abnormalities in the Floating-Point Calculations
float a = 1.0f;
float b = 0.33f;
float sum = 1.33f;
bool equal = (a+b == sum); // False!!!
Console.WriteLine("a+b={0} sum={1} equal={2}", a+b, sum, equal);
4. Boolean Dataype
int a = 1;
int b = 2;
bool greaterAB = (a > b);
Console.WriteLine(greaterAB); // False
bool equalA1 = (a == 1);
Console.WriteLine(equalA1); // True
5. Char data type
char symbol = 'a';
Console.WriteLine("The code of '{0}' is: {1}",
symbol, (int) symbol);
symbol = 'b';
Console.WriteLine("The code of '{0}' is: {1}",
pf3

Partial preview of the text

Download Assignments of visual programming and more Quizzes Software Engineering in PDF only on Docsity!

1. Integer Data Type

byte centuries = 20; // Usually a small number ushort years = 2000; uint days = 730480; ulong hours = 17531520; // May be a very big number Console.WriteLine("{0} centuries is {1} years, or {2} days, or {3} hours.", centuries, years, days, hours);

2. Precision Example

float floatPI = 3.141592653589793238f; double doublePI = 3.141592653589793238; Console.WriteLine("Float PI is: {0}", floatPI); Console.WriteLine("Double PI is: {0}", doublePI);

  1. Abnormalities in the Floating-Point Calculations float a = 1.0f; float b = 0.33f; float sum = 1.33f; bool equal = (a+b == sum); // False!!! Console.WriteLine("a+b={0} sum={1} equal={2}", a+b, sum, equal);
  2. Boolean Dataype int a = 1; int b = 2; bool greaterAB = (a > b); Console.WriteLine(greaterAB); // False bool equalA1 = (a == 1); Console.WriteLine(equalA1); // True
  3. Char data type char symbol = 'a'; Console.WriteLine("The code of '{0}' is: {1}", symbol, (int) symbol); symbol = 'b'; Console.WriteLine("The code of '{0}' is: {1}",

symbol, (int) symbol); symbol = 'A'; Console.WriteLine("The code of '{0}' is: {1}", symbol, (int) symbol);

  1. String Data Type string firstName = "Ivan"; string lastName = "Ivanov"; Console.WriteLine("Hello, {0}!", firstName); string fullName = firstName + " " + lastName; Console.WriteLine("Your full name is {0}.", fullName);
  2. Object Data Type object dataContainer = 5; Console.Write("The value of dataContainer is: "); Console.WriteLine(dataContainer); dataContainer = "Five"; Console.Write ("The value of dataContainer is: "); Console.WriteLine(dataContainer);
  3. Operators int squarePerimeter = 17; double squareSide = squarePerimeter/4.0; double squareArea = squareSide*squareSide; Console.WriteLine(squareSide); // 4. Console.WriteLine(squareArea); // 18. int a = 5; int b = 4; Console.WriteLine( a + b ); // 9 Console.WriteLine( a + b++ ); // 9 Console.WriteLine( a + b ); // 10 Console.WriteLine( a + (++b) ); // 11 Console.WriteLine( a + b ); // 11 Console.WriteLine(11 / 3); // 3 Console.WriteLine(11 % 3); // 2 Console.WriteLine(12 / 3); // 4