Declarations/Data Types/Statements. Assignments Due – Homework 1 Reading – Chapter 2 – 2.5-2.8 Lab 1 – due Monday.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Lab 8 User Defined Function.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
Display a 12-Month Calendar CS-2301 D-term Programming Assignment #2 12-Month Calendar CS-2301 System Programming C-term 2009 (Slides include materials.
Expressions and Arithmetic. Assignments Due – Lab 1 Reading – Chapter 3 –
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
C programming an Introduction. Types There are only a few basic data types in C. char a character int an integer, in the range -32,767 to 32,767 long.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
Programming Variables. Named area in the computer memory, intended to contain values of a certain kind (integers, real numbers, characters etc.) They.
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.
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
Chapter 2 : Overview of C By Suraya Alias. /*The classic HelloWorld */ #include int main(void) { printf(“Hello World!!"); return 0; }
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
CSCI 130 Chapter 3. Variables & Names Variable Declarations: –reserve a storage location in memory –identify the name of the variable –identify the type.
Khalid Rasheed Shaikh Computer Programming Theory 1.
Functions with Input/Ouput. Assignments Due – Lab 2 Reading – Chapter 4 –
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
E-1 University of Washington Computer Programming I Lecture 5: Input and Output (I/O) © 2000 UW CSE.
S CCS 200: I NTERACTIVE I NPUT Lect. Napat Amphaiphan.
Gator Engineering Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
CS 1704 Introduction to Data Structures and Software Engineering.
A.Abhari CPS1251 Topic 2: C Overview C Language Elements Variable Declaration and Data Types Statement Execution C Program Layout Formatting Output Interactive.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
NOTE: C programs consist of functions one of which must be main. C programs consist of functions one of which must be main. Every C program begins executing.
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
C Language Elements Preprocessor Directives # (sign for preprocessor directive commands) #include Standard header file (.h) Library.
+ Note On the Use of Different Data Types Use the data type that conserves memory and still accomplishes the desired purpose. For example, depending on.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
SCP1103 Basic C Programming SEM1 2010/2011 Arithmetic Expressions Week 5.
Lecture2.
Arithmetic Expressions
Formatted Input and Output
User Interaction and Variables
ECE Application Programming
BASIC ELEMENTS OF A COMPUTER PROGRAM
Formatted Input/Output
Input/output.
Functions, Part 2 of 2 Topics Functions That Return a Value
Revision Lecture
File Access (7.5) CSE 2031 Fall July 2018.
Chapter 2 Overview of C.
Chapter 3: I/O Management
ICS103 Programming in C Lecture 3: Introduction to C (2)
Introduction to C CSE 2031 Fall /3/ :33 AM.
Variables have a type have an address (in memory) have a value
Formatted Input/Output
2008/11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park
OUTPUT STATEMENTS GC 201.
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Formatted Input/Output
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.
CSCE 206 Lab Structured Programming in C
Functions, Part 2 of 3 Topics Functions That Return a Value
Lecture3.
Formatted Input/Output
Conversion Check your class notes and given examples at class.
EECE.2160 ECE Application Programming
Formatted Input/Output
EECE.2160 ECE Application Programming
Introduction to C EECS May 2019.
CSCE 206 Lab Structured Programming in C
EECE.2160 ECE Application Programming
Functions, Part 2 of 3 Topics Functions That Return a Value
Introduction to C CSE 2031 Fall /15/2019 8:26 AM.
Functions, Part 2 of 3 Topics Functions That Return a Value
EECE.2160 ECE Application Programming
Presentation transcript:

Declarations/Data Types/Statements

Assignments Due – Homework 1 Reading – Chapter 2 – Lab 1 – due Monday

Example Declarations double mynum; int count1, count2; char initial; Syntax type name;

Data Types int –integer value –10, 0, -23 float –floating point number –1.5, double –decimal number –store more digits than floats char –character –‘A’, ‘d’, ‘]’

Declarations #include void main (void) { int x; statements; } x: Allocate enough space for the given type and associate a name with the space

Assignment Statements tax = cost * TAX_RATE; Perform calculation on right and store in variable on left Also legal: total = total + cost;

Input and Output printf("Enter cost of item: "); scanf("%lf", &cost); printf("The tax on your item is $%5.2lf.\n", tax); printf("The total cost of your purchase is $%5.2lf.\n", total);

printf (“Format string”, printlist); Placeholder –starts with % –%c – char –%d – int –%f – double –%lf – double Precision printf("Enter cost of item: "); printf("The tax on your item is $%5.2lf.\n", tax);

printf \n – go to a new line printf (“Calculate %d plus %d.”, num1, num2); printf (“Hi %c%c!”, first_initial, last_initial);

scanf Read in data of the specified type and store it in the specified box & -- specifies the box, not the value cost -> &cost -> 1024 scanf("%lf", &cost); cost:

scanf scanf(“%d%d”, &num1, &num2); scanf(“%c%c”, &first_init, &last_init); careful with this, even return is a character!