Let's review - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Let's review

Description:

It can be of any length but only the first eight characters will be recognized. ... Reserved Words have predefined meaning in C. They don't have ... – PowerPoint PPT presentation

Number of Views:212
Avg rating:3.0/5.0
Slides: 11
Provided by: DLSZ2
Category:
Tags: meaning | review

less

Transcript and Presenter's Notes

Title: Let's review


1
Let's review
2
In C, the standard library (stdio.h) provides
routines for input and output. The standard
library function printf is used for formatted
output. It makes the user input a string and an
optional list of variables or strings to output.
The variables and strings are output according to
the specifications in the printf() function. The
standard library function scanf is used for
formatted input. It asks the user to input a
string or any other data type.
3
Conversion Specifiers The conversion characters
tell the compiler what data type the variable or
string will be. d      int        (the d is
short for decimal)f       float or double e
     float or double, output in scientific
notation.   (also known as standard form)c
     character s      character string (char )
4
Cs data types
Variable Type Keyword Range
Character char -128 to 127
Integer int -32768 to 32767
Long Integer long -2,147,483,648 to 2,147,483,647
Single-precision floating pt float 1.2E-38 to 3.4E381
Double-precision floating pt double 2.2E-308 to 1.8E3082
5
  • Float
  • 00000000000000000000000000000000000012 to
  • 340000000000000000000000000000000000000

6
Arithmetic Operators
Operator Action
Addition
- Subtraction
Multiplication
/ Division
Modulus Operation
Exponentiation
Increment
-- Decrement
7
Identifiers Identifiers are names that are used
to referenced variables, functions, labels and
user- defined objects. They consist of a letter
or an underscore followed by any combinations of
letters, digits or underscores. They can be as
long as 127 characters. C has standard
identifiers and user-defined identifiers. User-De
fined Identifiers start with a letter and may
contain any combination of letters and digits. It
can be of any length but only the first eight
characters will be recognized. Ex sum, num1,
ave Examples of Standard Identifiers are
printf(), scanf(), getch(). Reserved Words have
predefined meaning in C. They dont have ().
Ex void, int, float
8
  • Syntax Rules and Valid Identifiers
  • An identifier must consist of letters, digits
    and underscores only.
  • An identifier must not begin with a digit.
  • A C reserved word cannot be used as an
    identifier.
  • An identifier defined in a C library must not be
    redefined.
  • Directions Type V on the blank if the identifier
    is valid otherwise, type I.
  • ___ 1. quiz
  • ___ 2. quiz2
  • ___ 3. quiz 3
  • ___ 4. sum_1
  • ___ 5. quiz1
  • ___ 6. main
  • ___ 7. 2answer
  • ___ 8. username

9
The Welcome Program
includeltstdio.hgt includeltconio.hgt
Preprocessor directives
void main()
char fname
printf("Please enter your first name")
scanf("s",fname)
printf(\n Welcome to C s", fname)
getch()

10
The Area of the Rectangle Program
/Programmed by Ms ShiePel /
includeltstdio.hgt includeltconio.hgt
void main()
float width, height, area
printf(Enter the width of the rectangle in
inches )
scanf("f", width)
printf(\nEnter the height of the rectangle in
inches )
scanf("f", height)
areawidthheight
printf(\n The area of the rectangle is .2f sq.
in. , area)
getch()
Write a Comment
User Comments (0)
About PowerShow.com