1 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d",

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

BNF <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
C Functions. What are they? In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive.
ARDUINO CLUB Session 1: C & An Introduction to Linux.
What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
Week 4 – Functions Introduction. Functions: Purpose Breaking a large problem into a series of smaller problems is a common problem- solving technique.
C Intro.
C Programming. printf int printf ( const char * format,... ); printf ("Characters: %c \n", 'a'); printf ("Decimals: %d %f\n", 1977, 3.14); specifierOutputExample.
Lecture 2 Introduction to C Programming
Introduction to C Programming
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
Chapter 11-12, Appendix D C Programs Higher Level languages Compilers C programming Converting C to Machine Code C Compiler for LC-3.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
Introduction to C Programming
Basic Input/Output and Variables Ethan Cerami New York
By: Mr. Baha Hanene Chapter 4. LEARNING OUTCOMES This chapter will cover learning outcome no. 2 i.e. Use basic data-types and input / output in C programs.
1 C/C++ UM/MCSR Last modified: September 3, 2008.
Functions in C. Function Terminology Identifier scope Function declaration, definition, and use Parameters and arguments Parameter order, number, and.
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.
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
Chapter 2 : Overview of C By Suraya Alias. /*The classic HelloWorld */ #include int main(void) { printf(“Hello World!!"); return 0; }
1 C/C++ UM/MCSR. 2 Logging into the system using ssh Logging into the system from Windows: –Start the secure shell client: Start->Programs->SSH.
CNG 140 C Programming (Lecture set 9) Spring Chapter 9 Character Strings.
 Input and Output Functions Input and Output Functions  OperatorsOperators Arithmetic Operators Assignment Operators Relational Operators Logical Operators.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
Introduction to Programming Using C Modularity. 2 Contents Modularity Functions Preprocessor Comments Global variables.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
C Hints and Tips The preprocessor and other fun toys.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
CC112 Structured Programming Lecture 2 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer.
CECS 130 EXAM 1. To declare a constant (read only) value: const int x = 20; const float PI = 3.14; Can we do this? const int x;
Khalid Rasheed Shaikh Computer Programming Theory 1.
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
E-1 University of Washington Computer Programming I Lecture 5: Input and Output (I/O) © 2000 UW CSE.
Chapter 15 Strings as Character Arrays
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 1 Scott Marino.
Functions, Part 1 of 3 Topics  Using Predefined Functions  Programmer-Defined Functions  Using Input Parameters  Function Header Comments Reading 
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
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.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
CSCE 206 Structured Programming in C
INC 161 , CPE 100 Computer Programming
Chapter 2 - Introduction to C Programming
What's a Computer? Monitor Disk Main mouse Memory Keyboard Network
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Data Types and Arithmetic in C
Introduction to C Programming
Presentation transcript:

1 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230

2 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 Comments are set between /* and */

3 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The C pre-processor replaces this directive with the contents of the stdio.h header file from the standard C library.

4 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 Every C program must have one main function.

5 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 Each variable must be explicitly defined as a specific type.

6 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The stdio library defines the printf() function for creating output.

7 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The stdio library defines the printf() function for creating output. \n is the newline character

8 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The stdio library defines the scanf() function for capturing input.

9 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 %d tells scanf() to interpret the input as a decimal value

10 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 The = operator is used for assignment. The * operator is used for multiplication.

11 A Simple C Program /* Take a number multiply it by 10 and display it */ #include main() { int number, result; printf("Type in a number \n"); scanf("%d", &number); result = number *10; printf("The number multiplied by 10 equals %d\n", result); } Sample Program Output Type in a number 23 The number multiplied by 10 equals 230 %d tells printf() to treat the value of the result variable as a decimal nbr.