Roller Coaster Design Project

Slides:



Advertisements
Similar presentations
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Advertisements

DATA TYPES, VARIABLES, ARITHMETIC. Variables A variable is a “named container” that holds a value. A name for a spot in the computer’s memory This value.
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
Lecture 1 The Basics (Review of Familiar Topics).
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
PHYS 2020 Making Choices; Arrays. Arrays  An array is very much like a matrix.  In the C language, an array is a collection of variables, all of the.
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
1 Please switch off your mobile phones. 2 Data Representation Instructor: Mainak Chaudhuri
CSC 107 – Programming For Science. Announcements  Textbook available from library’s closed reserve.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
C Programming n General Information on C n Data Types n Arithmetic Operators n Relational Operators n if, if-else, for, while by Kulapan Waranyuwat.
M.T.Stanhope Oct Title : C++ Basics Bolton Institute - Faculty of Technology (Engineering) 1 C++ Basics u Data types. u Variables and Constants.
PHY 107 – Programming For Science. Announcements  Slides, activities, & solutions always posted to D2L  Note-taking versions before class, for those.
Fundamental Programming: Fundamental Programming Introduction to C++
COMPUTER PROGRAMMING II SUMMER 2011 Visual Basic to C#
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Computer And Programming Array and Pointer. Array provides a means to allocating and accessing memory. Pointers, on the other hand, provides a way to.
Written by: Dr. JJ Shepherd
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Fundamentals of Programming Most.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
Presentation By :- Nikhil R. Anande ( ) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
C LANGUAGE UNIT 3. UNIT 3 Arrays Arrays – The concept of array – Defining arrays – Initializing arrays.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Welcome to Computer Programming II! Computer Programming II Summer 2015.
ARRAYS.
EGR 2261 Unit 11 Pointers and Dynamic Variables
The Machine Model Memory
How Computers Store Variables
Data Types, Variables & Arithmetic
C Programming Tutorial – Part I
ITEC113 Algorithms and Programming Techniques
Pointers in C.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
C Short Overview Lembit Jürimägi.
Student Book An Introduction
C Basics.
L7 – Assembler Directives
Lecture2.
Engineering Innovation Center
DATA HANDLING.
11/10/2018.
Arrays, For loop While loop Do while loop
Unit 2 Programming.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Introduction to Programming
Java - Data Types, Variables, and Arrays
An Introduction to Java – Part I, language basics
Program Breakdown, Variables, Types, Control Flow, and Input/Output
C Programming Getting started Variables Basic C operators Conditionals
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Arrays in Java.
CS 240 – Lecture 7 Boolean Operations, Increment and Decrement Operators, Constant Types, enum Types, Precedence.
Suggested self-checks: Section 7.11 #1-11
Setting up a basic program with Arduino
Variables and Constants
SPL – PS2 C++ Memory Handling.
Presentation transcript:

Roller Coaster Design Project Lab 4 Supplement: C Crash Course

The C Language Many similarities to Matlab, but some very important differences, each covered in turn in the following slides: Strongly Typed Vectors very different Syntax differences 2

C Variables Strongly Typed When you create a variable, you must also specify what sort of data is stored within the variable. Uninitialized – start with random data in them. Types: Integers (int/short/long) Store integer type data (-4, 2, 111) Are (16/8/32) bits long Can be signed (default, 1-bit used for sign) or unsigned (all bits used for magnitude, but always positive) Will 'overflow' when value stored in them exceeds available bits 3

Types (cont') Types: Floating Point (float/double) Store floating point data (3.14, -0.00000134) Are (32/64) bits long Are always signed, and can represent a HUGE range of values Can be tricky to work with, as it can be very hard to predict the details of how they work. Using direct comparisons (== or !=) can be VERY dangerous, logically 4

Types (cont') Types: Character types (char, string) Used to store character data Usually, chars are used in arrays (see below) Can be tricky to work with without more in depth discussion of how C/C++ works Arrays: Collections of other data types To make an array, add [#] to the end of the variable name, with # being equal to the number you want. Use [n] to access the nth element of the array 5

Variable declarations Examples of variable declarations in C: int myInteger; float pi = 3.14; char myName[10] = “Dr. Smith”; 6

Constants #define can be used to create a constant #define pi 3.14 Now, everywhere 'pi' shows up in your code, it will be replaced with '3.14' before the code is compiled 7

Operators Work pretty much exactly as they do in Matlab Order of operations still holds Vector math is NOT implemented, so '.' operators do not exist In C, 'not equal' is '!=' C supports 'in-line' or 'compound' operators: n++ → n = n + 1 n - - → n = n – 1 n += a → n = n + 1 n *= b → n = n * b etc... n++ (etc) can be used in equations 8

Flow Control C supports if statements, while loops, for loops and case statements, like Matlab did, but with different syntax: if (pinFiveInput < 500) { // action A } else { // action B } 9

Flow Control for (initialization; condition; increment) { //statement(s); } while(expression) // statement(s) 10

More Resources http://www.cprogramming.com/tutorial/c-tutorial.html www.Arduino.cc CSE 1222, CSE 2221 11