0% found this document useful (0 votes)
6 views3 pages

C# Basic Math and Input Programs

Uploaded by

carlopaglomutan
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)
6 views3 pages

C# Basic Math and Input Programs

Uploaded by

carlopaglomutan
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

using System; Console.

WriteLine("a = " + a);


[Link]("b = " + b);
class Program [Link]("c = " + c);
{ [Link]("d = " + d);
static void Main()
{ [Link]("Addition = " +
addition);
// Declare 4 integer variables (sample
values from the board) [Link]("Subtraction = " +
subtraction);
int a = 5;
[Link]("Multiplication = " +
int b = 3;
multiplication);
int c = 7;
[Link]("Division = " +
int d = 2; division);
[Link]("Average = " +
// Perform operations average);

int addition = a + b + c + d;
int subtraction = a - b - c - d; [Link](); // keep console
window open
int multiplication = a * b * c * d;
}
double division = (double)a / b / c /
d; // cast to double for decimal result }

double average = (double)(a + b + c + d)


/ 4;

// Display results
using System; using System;

class Program1 class Program2

{ {

static void Main() static void Main()

{ {

[Link]("Enter a value for length: "); [Link]("Enter a number of seconds: ");

int length = [Link]([Link]()); int totalSeconds =


[Link]([Link]());

[Link]("Enter a value for width: ");


int hours = totalSeconds / 3600;
int width = [Link]([Link]());
int minutes = (totalSeconds % 3600) / 60;
int seconds = totalSeconds % 60;
int perimeter = 2 * (length + width);
int area = length * width;
[Link](totalSeconds + " seconds = "
+
[Link]("The perimeter of a $"{hours}:{minutes:D2}:
rectangle is: " + perimeter); {seconds:D2}");
[Link]("The area of a rectangle is: " }
+ area);
}
}
}
using System;

class Program3
{
static void Main()
{
[Link]("Enter any three-digit number:
");
int number = [Link]([Link]());

int hundreds = number / 100;


int tens = (number / 10) % 10;
int ones = number % 10;

[Link]("The place value of the


number " + number + " is:");
[Link](hundreds + " hundreds, " +
tens + " tens, and " + ones + " ones");
}
}

You might also like