CONSTANTS - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

CONSTANTS

Description:

CONSTANTS – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 10
Provided by: QuaziAbid5
Category:
Tags: constants | var

less

Transcript and Presenter's Notes

Title: CONSTANTS


1
CONSTANTS
  • Integer Constants
  • 1, 4, -98
  • Real Constants
  • 12.8, -98.9
  • Logical Constants
  • Character Constants
  • 1234, abcd, a, a1s2

2
Variables
  • Rules
  • Start with a.z, A.Z
  • Lengthlt6
  • Should not contain special characters
  • May have 0..9
  • No blanks

3
Variables (Contd)
  • Integer Variables
  • Explicit
  • Integer x, y, z
  • Implicit
  • Starts with I,J,K,L,M,N
  • Real Variables
  • Explicit
  • Real a, b, c
  • Implicit
  • Anything other than integer

4
Variables (Contd..)
  • Logical Variables
  • Character Variables (Explicit only)
  • Character varlength
  • Character x20, y10
  • Character length var
  • Character 20 a, b, c

5
Arithmetic Operations
  • ? Exponentiation? PREC 1
  • ? Multiplication? PREC 2
  • / ? Division? PREC 2
  • ? Addition? PREC 3
  • - ? Subtraction? PREC 3
  • Parentheses have the highest priority

6
Arithmetic Operations (Contd..)
  • Integer Operation
  • Result is Integer
  • Fraction is truncated
  • Real Operation
  • Result is real
  • Mixed Mode Operation
  • Result is real

7
INPUT STATEMENTS
  • Read, var1,var2,..
  • Data values are separated by commas or blank
  • Must match the type in sequence
  • Integer x, y
  • Real a, b
  • Read, x, a, y, b
  • Input 10 5.2 3 -9.8
  • Wrong Input 5.2 10 1.2 5.6

8
OUTPUT STATEMENTS
  • Print, var1, test messsage, var2, 10
  • INPUT Keyboard?Memory
  • OUTPUT Memory?Monitor

9
EXERCISES
  • Type and Execute the program on page 25
  • Write a program to calculate the area of a circle
  • Write a program to input an integer as days which
    will be converted to years, months and days.
Write a Comment
User Comments (0)
About PowerShow.com