G
G
gvadelypa2020-02-21 17:00:11
Pascal
gvadelypa, 2020-02-21 17:00:11

What will the code from Pascal to C# look like?

How would this piece of Pascal code look like in C#?

a := x div 100;
b := x (div 10) mod 10;
c := x mod 10

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Planet_93, 2020-02-21
@NovichekTyrnira

In C#

int x = 123;

//Целая часть при делении, то есть ответ будет 1
 int a = x / 100;
            
Console.WriteLine(a);//1

//В скобках берем целую часть, то есть 12 и от 12 получаем остаток, то есть 2
 int b = (x / 10) % 10;

Console.WriteLine(b);//2

//Остаток от деления, то есть 3
int c = x % 10;
            
Console.WriteLine(c);//3

Console.ReadKey();

Pascal example and description here .

L
LiptonOlolo, 2020-02-21
@LiptonOlolo

double a = x / 100;
double b = (x / 10) % 10;
double c = x % 10;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question