Wednesday 26 February 2014

size of data types

//Write a c program to find the size of int without using sizeof operator
#include<stdio.h>
int main(){
  int *ptr = 0;
  ptr++;
  printf("Size of int data type:  %d",ptr);
  return 0;
}
//Write a c program to find the size of double without using sizeof operator
#include<stdio.h>
int main(){
  double *ptr = 0;
  ptr++;
  printf("Size of double data type:  %d",ptr);
  return 0;
}
//Write a c program to find the size of structure without using sizeof operator
#include<stdio.h>
struct student{
    int roll;
    char name[100];
    float marks;
};
int main(){
  struct student *ptr = 0;
  ptr++;
  printf("Size of the structure student:  %d",ptr);
  return 0;
}
//Write a c program to find the size of union without using sizeof operator
#include<stdio.h>
union student{
    int roll;
    char name[100];
    float marks;
};
int main(){
  union student *ptr = 0;
  ptr++;
  printf("Size of the union student:  %d",ptr);
  return 0;

No comments:

Post a Comment