October 2019 15k SPAM Thread

Professional Engineer & PE Exam Forum

Help Support Professional Engineer & PE Exam Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Status
Not open for further replies.
Simple programming question of the day, what is c?

int d = 5, c = 10, h = 16, f = 9;
double a = 48, e = 12, g = 3, b = 7;

int main()
{
c += (b + (a / c)) / 6.0;

return 0;
}

a / c = 4.8

4.8 + b = 11.8

11.8 / 6.0 = 1.96666667

c = 10, + 1.96666667 = 11.966666667

BUT

c is an int, so the result is truncated.

Therefore, c=11

And i’m Pretty sure the result would be the same in this case even if the truncation took place earlier in the process.

 
Last edited by a moderator:
If we can, lets get the following:

  • Personality Results (already have this for everyone)
  • Engineering degree field
  • PE Discipline
  • Current work field
ISFJ

Degree is B.S. Electrical and Electronics Engineering

Discipline is Electrical

Work Field is Control Systems, Software, and Electrical Engineering (in that order)

 
a / c = 4.8

4.8 + b = 11.8

11.8 / 6.0 = 1.96666667

c = 10, + 1.96666667 = 11.966666667

BUT

c is an int, so the result is truncated.

Therefore, c=11

And i’m Pretty sure the result would be the same in this case even if the truncation took place earlier in the process.
How would you feel if the equation was:

Code:
[COLOR=rgb(0,0,0)]c [/COLOR][COLOR=rgb(102,102,0)]+=[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]([/COLOR][COLOR=rgb(0,0,0)]b [/COLOR][COLOR=rgb(102,102,0)]+[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]([/COLOR][COLOR=rgb(0,0,0)]a [/COLOR][COLOR=rgb(102,102,0)]/[/COLOR][COLOR=rgb(0,0,0)] c[/COLOR][COLOR=rgb(102,102,0)]))[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,102,0)]/[/COLOR][COLOR=rgb(0,0,0)] 5.9[/COLOR][COLOR=rgb(102,102,0)];[/COLOR]
 
Last edited by a moderator:
If we can, lets get the following:

  • Personality Results (already have this for everyone)
  • Engineering degree field
  • PE Discipline
  • Current work field
Consul ESFJ-a

Civil Engineering

Civil Construction (pending)

I am a senior executive managing people who oversee people that do the fun stuff (planning, real estate, architecture, engineering and construction).

 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top