In this program we declare 4 type of variables which is integer , float , double , char. hten we find the size of variables using size of operator.
1. Program to find the size of variables in c language.
#include<stdio.h>
#include<conio.h>
void main()
{
int int_type;
float float_type;
double double_type;
char char_type;
clrscr();
//size of operator is used to find the value of variables
printf("Integer size is%d byte\n",sizeof(int_type));
printf("Float size is%f byte\n",sizeof(float_type));
printf("Double size is %ld byte\n",sizeof(double_type));
printf("Integer size is%c byte\n",sizeof(char_type));
getch();
}
2. Program to find size of variables in c++ language.
#include<iostream.h>
#include<conio.h>
void main()
{
int int_type;
float float_type;
double double_type;
char char_type;
clrscr();
cout<<"Integer size is\n"<<sizeof(int_type);
cout<<"Float size is\n"<<sizeof(float_type);
cout<<"Double size is\n"<<sizeof(double_type);
cout<<"Char size is\n"<<sizeof(char_type);
getch();
}
1. Program to find the size of variables in c language.
#include<stdio.h>
#include<conio.h>
void main()
{
int int_type;
float float_type;
double double_type;
char char_type;
clrscr();
//size of operator is used to find the value of variables
printf("Integer size is%d byte\n",sizeof(int_type));
printf("Float size is%f byte\n",sizeof(float_type));
printf("Double size is %ld byte\n",sizeof(double_type));
printf("Integer size is%c byte\n",sizeof(char_type));
getch();
}
2. Program to find size of variables in c++ language.
#include<iostream.h>
#include<conio.h>
void main()
{
int int_type;
float float_type;
double double_type;
char char_type;
clrscr();
cout<<"Integer size is\n"<<sizeof(int_type);
cout<<"Float size is\n"<<sizeof(float_type);
cout<<"Double size is\n"<<sizeof(double_type);
cout<<"Char size is\n"<<sizeof(char_type);
getch();
}
No comments:
Post a Comment