Digital FXtbook
Easy Contacts
  • Home
    • Free Software
    • The Author
    • Former Students Hall of Fame
    • A tribute....
  • Animation
    • Intro to 3d >
      • AutoDesk
      • Introduction: The Temple
      • Troubleshooting Maya
      • Modeling >
        • The Nail
        • First Freestyle Lesson >
          • Cup and Straw
          • Garbage Can
        • Fence
        • Hammer
        • House
        • Environment Bubble
      • Animation >
        • Beginning Animation
        • Animation - Walk Cycle
        • Facial Animation
      • Rendering >
        • Arnold Rendering
      • StoryBoarding
      • Story Reels
      • Editing film >
        • Video Editing
        • Credits
      • Characters
      • Troubleshooting
    • Modeling and Rigging >
      • Modeling >
        • Image Planes
        • Polygon Modeling >
          • Coke Can
          • Low Polygon Character
          • Character Modeling Legion the Geth
          • Character Modeling Geth Armor
          • Face Modeling
        • NURBS Modeling >
          • Intro to NURBS
          • Lofting
          • CV Curves
          • Organic Modeling
          • Autombile
      • 3d Coat >
        • Integration with Maya >
          • Getting stuff out of Maya
        • UV Texture Mapping >
          • Texture mapping in 3d Coat
        • 3d Painting >
          • Painting in 3d Coat
        • Reintegration with Maya
      • Rigging >
        • Rigging
        • Smooth Skinning
        • Rigging with HumanIK
        • Smooth Skinning
      • Motion Capture
    • 3d Animation >
      • Arnold Rendering
      • Reference Videos
      • Beginning Animation
  • Gaming
    • Board Game Game Design Document
    • Modeling >
      • Introduction: The Temple
      • Halo 1 Blood Gulch Base
      • Hammer
      • Sword
      • Character Modeling Big Daddy
      • Shield
      • The OM6G
      • Weapon
      • Character Modeling Legion the Geth
      • Character Modeling Geth Armor
    • Animation >
      • Character Animation
    • Rigging >
      • Rigging with HumanIK
      • Characterizing and MoCap
      • Integration with Unity
    • Unity >
      • Number Wizard Game #1
      • Second Unity Game: Text Adventure
      • Number Wizard Game GUI
      • Block Breaker >
        • Block Breaker Game #1
        • Block Breaker Game #2
        • Block Breaker Game #3
        • Block Breaker Game #4
      • Terrain
      • Importing Models
  • Coding
    • Beginning C# >
      • First Unit >
        • First Program
        • Introduction Unity Lesson
        • Comments
        • PsuedoCode
        • Numbers and Operators
        • Use of Parenthesis
        • Casting
        • Try and Catch
        • Operators
      • Second Unit >
        • Conditional Statements >
          • Number validator
          • Number tester
          • Speed Camera
        • Random Class
        • Loops >
          • For Loops
          • For Each Loops
          • While Loops
          • Do While Loops
        • Arrays >
          • Simple Arrays
          • Complex Arrays
    • Web Design >
      • XHTML >
        • XHTML Introduction
        • XHTML Test #1
        • HTML Links and Images
        • XHTML Test #2
        • HTML Tables and Lists
        • XHTML Test #3
        • HTML intro to CSS
        • HTML CSS
        • HTML Styling
        • HTML Styles
        • HTML Positioning
      • HTML 5 >
        • HTML Chapter 1
        • HTML Chapter 2
        • HTML Chapter 3
        • HTML Chapter 4
        • HTML Chapter 5
        • HTML Chapter 6
        • HTML Chapter 7
        • HTML Chapter 8
        • HTML Chapter 9
  • Student Films
    • Advanced Student's movies
    • Beginning Student's movies
  • Adobe
    • Photoshop >
      • Introduction
      • Selection Tools >
        • Melonhead >
          • Melonhead Creative
        • Breakfast Lunch or Dinner
        • Blu 42
      • Painting Tools >
        • Invisi-World
        • Image Adjustment
        • FreeStyle project
      • Drawing Tools >
        • Abstract Expressionism
    • Premier >
      • Project 1
    • Illustrator >
      • Vector Ninjas
      • Live Art Painting
      • Starting the Pen Tool
      • Apple and Pear
      • Creating Your LOGO
      • Self Portrait
  • Links
    • Key Board Fix/Hack
    • Buiding Piers >
      • Buiding Piers
      • Buiding Piers
    • The Top Six Animation Schools
    • The Top Video Game Design Schools
  • International Team
  • BPA
    • BPA 2017-2018 >
      • Getting organized
      • Building the Train
      • Texturing the Train
      • Animating the Train
      • Making our Entry Film
    • BPA 2018-2019
    • BPA 2019-2020
  • Arnold Lighting
  • Example for 1st Hour

Algebra in code and assundry CHAOS

All righty then..... In this lesson we are going to getting down to some hard core numbers. You are given a number of float's and value in them. We are then going to take those Float's and make a program that derives a specific value from those float's making the computer run it through a computation that is provided below. 


​


Here is the situation

​Take a look at the code below: it reads a float value, puts it into a variable named x and prints the value of a variable named y.
Your task is to complete the code in order to evaluate the following expression:



​
Picture

Hints

​
We expect the result to be assigned to y.
Note: we've prepared a variable containing the value of π. Use it.
Be careful! Watch the operators and keep their priorities in mind. Remember that classical algebraic notation likes to omit the multiplication operator – you need to use it explicitly.
Don't hesitate to use as many parentheses as you need. Keep your code clean and readable – surround the operators with spaces. Use additional variables to shorten the expression.
Hint: multiply x by x to get x squared.
Test your code by using the data we've provided – don't be discouraged by any initial failures. Be persistent and inquisitive. Good luck!

The Code

#include <iostream>
using namespace std;
int main(void) {
float pi = 3.14159265359;
float x,y;
cout << "Enter value for x: ";
cin >> x;
// put your code here
cout << "y = " << y;
return 0;
}
​

The results that we are after

Example input 1 Example output y = 0.0949234 
Example input -1.5 Example output y = 0.0890702
Example input 12.345 Example output y = 0.101057
 

Videos

Proudly powered by Weebly