Google what is meant by precedence of operators in programming?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

Question 03: Google what is meant by precedence of operators in programming?

 

Question 04:

   Arithmetic Instruction

 

Evaluate following examples by your own then run these on C# and compare with your result.

 

Example 1

int ad ;

float kot, deta, alpha, beta, gamma ;

ad = 3200 ;

kot = 0.0056 ;

alpha=1.25;

beta=35.789;

gamma=19.25;

deta = alpha * beta / gamma + 3.2 * 2 / 5 ;

Console.WriteLine(deta);

 

Example 2

float si, prin, anoy, roi, avg ;

int a, b, c, num ;

si = prin * anoy * roi / 100.0 ;

avg = ( a + b + c + num ) / 4 ;

 

Example 3

char x, y ;

int z ;

x = 'a' ;

y = 'b' ;

z = x + y ;

Console.WriteLine(z);

 

Example 4

int a ;

a = Math.Pow(3,5);        //Error Cannot implicitly convert type 'double' to 'int'

Console.WriteLine(a);

 

double a ;

a = Math.Pow(3,5);   

Console.WriteLine(a);

 

 

Example 5

double a=2.45f, b=3.786f, c=2.934f ;

int s ;

s = a * b * c / 100 + 32 / 4 - 3 * 1.1 ;               //Error Cannot implicitly convert type 'double' to 'int'

Console.WriteLine(s);

 

double a=2.45f, b=3.786f, c=2.934f ;

double s ;

s = a * b * c / 100 + 32 / 4 - 3 * 1.1 ;

Console.WriteLine(s);

 

g = big / 2 + big * 4 / big - big + abc / 3 ;

             (abc = 2.5, big = 2, assume g to be a float)

on = ink * act / 2 + 3 / 2 * act + 2 + tig ;

             (ink = 4, act = 1, tig = 3.2, assume on to be an int)

 s = qui * add / 4 - 6 / 2 + 2 / 3 * 6 / god ;

            (qui = 4, add = 2, god = 2, assume s to be an int)

 s = 1 / 3 * a / 4 - 6 / 2 + 2 / 3 * 6 / g ;

             (a = 4, g = 3, assume s to be an int)

 

Example 6

int x, y ;

x=Convert.ToInt32(Console.ReadLine();

y = ( x > 5 ? 3 : 4 ) ;

Console.WriteLine(y);

 

Example 7

char a ;

int y ;

a=Convert.ToInt32(Console.ReadLine();

y = ( a >= 65 && a <= 90 ? 1 : 0 ) ;

Console.WriteLine(y);

 

Example 8

int big, a, b, c ;

a=7;

b=5;

c=3;

 

big = ( a > b ? ( a > c ? 3: 4 ) : ( b > c ? 6: 8 ) ) ;

Console.WriteLine(big);

 

Example 9

int k = 35 ;

Console.WriteLine( "\n {0} {1} {2}", k == 35, k = 50, k > 40 ) ;

 

Question 05

Write C# programs to convert the following equations into corresponding C# statements (values of variables should be inputted by the user).

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage