0% found this document useful (0 votes)
33 views

Data Type and Constant in C Programming

This document explains about the primitives data type used in C. IT also discuss how to create and use constants with example programs.

Uploaded by

jatinder Kumar
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)
33 views

Data Type and Constant in C Programming

This document explains about the primitives data type used in C. IT also discuss how to create and use constants with example programs.

Uploaded by

jatinder Kumar
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/ 2

DATA TYPE MEMORY (BYTES) FORMAT SPECIFIER

short int 2 %hd

unsigned short int 2 %hu

unsigned int 4 %u

int 4 %d

long int 8 %ld

unsigned long int 8 %lu

long long int 8 %lld

unsigned long long int 8 %llu

signed char 1 %c

unsigned char 1 %c

float 4 %f

double 8 %lf

long double 16 %Lf


#include<stdio.h>
#include<conio.h>
#define PI 3.141412
int main()
{
short int num1 = 10000;
int number = 121113991;
long int prime = 9929991L;
long int notprime = 1233322L;
long long int sum = prime + notprime;
printf("Variable 1 value =%hd and Size = %u \n", num1 , sizeof(num1) );
printf("Variable 2 value =%d and Size = %u \n ", number , sizeof(number) );
printf("Variable 3 value =%ld and Size = %u \n", prime , sizeof(prime) );
printf("Sum value =%lld \n", sum );
// float variables
float average = 97.665;
float mark = 67;
printf("average is %f \n ", average);
printf(" marks is %f \n ", mark);
// double variables
double averageD = 679999999.454;
double score = 679999999.454;
printf("Average is %lf \n ", averageD);
printf("Score is %lf \n ", score);
// Character Data type or Variables
char group = 'B';
char name[30] = "Student1";
printf("group is %c, name is %s \n ", group, name);
const int MAX=90;
// MAX=92; not possible
printf(" Value of MAX = %d\n ",MAX);
printf(" Valie of PI = %lf and Size =%u", PI, sizeof(PI));
return 0;
}

You might also like