Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

02 C Programming

C Programming lec -2 notes

Uploaded by

pnkulkarni05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

02 C Programming

C Programming lec -2 notes

Uploaded by

pnkulkarni05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

C PROGRAMMING

INDEX
1 DataTypes in C

2 Variable in C

3 Keyword in C
DATATYPE IN C

 Data types in c used for declaring variables or functions


of different types.

 The type of a variable determines how much space it


occupies in storage.

 A data type specifies the type of data that a variable


can store.
 There are 4 types of data types in C language.
Basic Data Types

 The basic data types are integer-based and


floating-point based.

 The memory size of basic data types may change


according to 32 or 64 bit operating system.
Type Storage size Value range

char 1 byte -128 to 127 or 0 to 255

int 2 bytes −32,768 to 32,767

float 4 byte 1.2E-38 to 3.4E+38

double 8 byte 2.3E-308 to 1.7E+308


 Example….

#include <stdio.h>
void main()
{
int a = 4000; // positive integer data type
float b = 5.2324; // float data type
char c = 'Z'; // char data type
int f = -185; // -ve integer data type
double i = 4.1234567890; // double float data type
float j = -3.55; // float data type
}
 Program :

#include <stdio.h>

int main()
{

printf("Storage size for int is: %d \n", sizeof(int));


printf("Storage size for char is: %d \n", sizeof(char));
printf("Storage size for int is: %d \n", sizeof(float));
printf("Storage size for char is: %d \n", sizeof(double));

return 0;
}
 OUTPUT
VARIABLES IN C
 A variable is a name of memory location.

 A variable is used to store data.

 Its value can be changed and it can be reused


many times.
Rules for defining variables

 A variable can have alphabets, digits and underscore.


(a-z, A-Z, 0-9, _)

 A variable name can start with alphabet and


underscore only.

 It can't start with digit.

 No white space is allowed within variable name.

 A variable name must not be any reserved word or


keyword e.g. int, float etc.
Syntax to declare a variable.

type variable_name;

Example of declaring variable.

➢ int a;
➢ float b;
➢ char c;
KEYWORDS IN C
 A keyword is a reserved word.

 You cannot use it as a variable name.

 There are 32 reserved words (keywords) in C


language.
*******************************************************

You might also like