?

Questions From Previous Class

Variables:

Do you Really get it?

Variables are simply names used to refer to some location in memory – a location that holds a value with which we are working.

Location can hold any thing.

Its upto us to decide what it holds.

Notion

What are Data Types?

&

Why do we need them?

Data Type:

Type of data that memory location or variable will hold

Trend that you should have noticed while writing code:

Syntax

data_type   v1=a1 ,v2=a2 ,.... ;

 

v1   =  name of variable

a1   =  value of variable v1

.

.

so on

Problem

How to name a variable?

Function

printf

Output

scanf

Input

Let's Formally Define it:

printf( "You can get anything                        printed" )

 

Part inside the braces is stream at least this is how we know it.

Type Specifiers:

They are more like names how computer sees them.

 

  1. '%d'  for  integers
  2. '%s'   for strings
  3. '%f'    for floats
  4. '%lf'   for double
  5. '%c'   for characters

Its more like Fill in the Blanks

Question

Why do we need them?

Answer : to tell computer what comes next

Syntax

printf( " some string %d some string",   v1  );

 

in the string or characters in between double quotes %d tells the compile that this data is missing and its most likely at the end before the braces.

 

So now you can guess what v1 should be?

See the bigger picture

Made with Slides.com