Robotics scanf and strings March 18 th, 2011. Today’s learning objective Use character strings Use the “scanf” function to input data into C programs.

Slides:



Advertisements
Similar presentations
ARDUINO CLUB Session 1: C & An Introduction to Linux.
Advertisements

Computer Programming Lab(7).
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
1 Loops. 2 Often we want to execute a block of code multiple times. Something is always different each time through the block. Typically a variable is.
14-Jun-15 State Machines. 2 What is a state machine? A state machine is a different way of thinking about computation A state machine has some number.
CMPUT 101 Lab #6 October 29, :00 – 17:00. Array in C/C++ Array is a structure type variable. One dimension of array int: int num[3]; There are.
Classes, methods, and conditional statements We’re past the basics. These are the roots.
The little language that could Remember C is a “small language”
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
Ping Zhang 10/08/2010.  You can get data from the user (input) and display information to the user (output).  However, you must include the library.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
1 - buttons Click “Step Forward” to execute one line of the program. Click “Reset” to start over. “Play,” “Stop,” and “Step Back” are disabled in this.
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
E0001 Computers in Engineering
CS107 Introduction to Computer Science Java Basics.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
February 11, 2005 More Pointers Dynamic Memory Allocation.
How to start Visual Studio 2008 or 2010 (command-line program)
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
NA2204.1jcmt CSE 1320 Intermediate Programming C Program Basics Structure of a program and a function type name (parameters) { /* declarations */ statement;
CMP-MX21: Lecture 5 Repetitions Steve Hordley. Overview 1. Repetition using the do-while construct 2. Repetition using the while construct 3. Repetition.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
(9-1) Strings I H&K Chapter 8 Instructor - Andrew S. O’Fallon CptS 121 (October 19, 2015) Washington State University.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Using variable Variables are used to store values.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Loops Brent M. Dingle Texas A&M University Chapter 6 – Section 6.3 Multiway Branches (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.
Discussion 4 eecs 183 Hannah Westra.
Basic concepts of C++ Presented by Prof. Satyajit De
GCSE COMPUTER SCIENCE Practical Programming using Python
Whatcha doin'? Aims: To start using Python. To understand loops.
Strings (Continued) Chapter 13
What skills have I used today? Have I learnt a new skill?
INC 161 , CPE 100 Computer Programming
Review C Programming Language
Computer Programming I
Pointers.
Using Encoders to go Straight
Reindeer don't go to public school, they’re elf taught.
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
I/O in C Lecture 6 Winter Quarter Engineering H192 Winter 2005
Introduction to CS Your First C Programs
Use proper case (ie Caps for the beginnings of words)
Console input.
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
The switch statement: an alternative to writing a lot of conditionals
Auto Straightening using VEX Shaft Encoders
Module 4 Loops.
Buffer Overflows.
Functions continued.
Python Basics with Jupyter Notebook
Variables and Computer Memory
Using string type variables
Unit 3: Variables in Java
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
CSCE 206 Lab Structured Programming in C
Variables and Constants
Getting Started With Coding
Presentation transcript:

Robotics scanf and strings March 18 th, 2011

Today’s learning objective Use character strings Use the “scanf” function to input data into C programs. Make our own madlib programs!

Here’s the story… It was a _________ day at PATH. Mr. Oakland was ___________ because someone had _________ the _________.

character strings We’ve met “int” before. This is a variable of type integer. “char” means a character. What do you suppose the last line means? int mynumber; char mycharacter; char mystring[80];

When the program sees a scanf statement, it will stop and wait for the user to type something, and then try to put the user's input into the variable scanf ("%s", &string1);.

Classwork 1 Go to Download, compile, and run “madlib.c”

Classwork 2 Modify the “madlib.c” program to make a different story. You might want to change the types of strings the computer asks for. For example, ask for someone’s name, or a location. When you are done, show your program to someone else and have them run it without knowing what story it will make!