Computer Science, asked by isaacwesonga90, 5 months ago

(c) Assuming Pascal programming language, evaluate the expression;
Y = sqr (a) + b * c mod 4/ d
given that a = 4, b = 6, c = 10 and d = 3. (4 marks)

Answers

Answered by hrishikesh241
2

Following table shows all the arithmetic operators supported by Pascal. Assume variable A holds 10 and variable B holds 20, then −

Operator Description Example

+ Adds two operands A + B will give 30

- Subtracts second operand from the first A - B will give -10

* Multiplies both operands A * B will give 200

div Divides numerator by denominator B div A will give 2

mod Modulus Operator AND remainder of after an integer division B mod A will give 0

The following example illustrates the arithmetic operators −

Live Demo

program calculator;

var

a,b,c : integer;

d: real;

begin

a:=21;

b:=10;

c := a + b;

writeln(' Line 1 - Value of c is ', c );

c := a - b;

writeln('Line 2 - Value of c is ', c );

c := a * b;

writeln('Line 3 - Value of c is ', c );

d := a / b;

writeln('Line 4 - Value of d is ', d:3:2 );

c := a mod b;

writeln('Line 5 - Value of c is ' , c );

c := a div b;

writeln('Line 6 - Value of c is ', c );

end.

Please note that Pascal is very strongly typed programming language, so it would give an error if you try to store the results of a division in an integer type variable. When the above code is compiled and executed, it produces the following result:

Line 1 - Value of c is 31

Line 2 - Value of c is 11

Line 3 - Value of c is 210

Line 4 - Value of d is 2.10

Line 5 - Value of c is 1

Line 6 - Value of c is 2

Previous PageNext Page

Advertisements

Tutorials Point

About us Refund Policy Terms of use Privacy Policy FAQ's Contact

© Copyright 2020. All Rights Reserved.

Answered by sonamchaudhary453
0

Answer:

he djxnhxtkvoonfcgmxcbbc

Similar questions