Size of Numeric value

Thursday, 8 September 2011

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("\nSize= %d byte",sizeof(5));
printf("\nSize= %d byte",sizeof(4.5));
printf("\nSize= %d byte",sizeof(4.5f));
getch();
}


OUTPUT:


Size=2 byte
Size=8 byte
Size=4 byte











Size of Data Types

#include<stdio.h>
#include<conio.h>
void main()
{
int a;
float b;
char c;
clrscr();
printf("\nSize of a=%d byte",sizeof(a));
printf("\nSize of b=%d byte",sizeof(b));
printf("\nSize of c=%d byte",sizeof(c));
getch();
}


OUTPUT:


Size of a=2 byte
Size of b=4 byte
Size of c=1 byte









Maximum of two Number using Relational Operator

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the two integer number\n");
scanf("%d%d",&a,&b);
c=a>b?a:b;
printf("Max of %d and %d is %d\n",a,b,c);
getch();
}


OUTPUT:


Enter the two integer number
4
5
max of 4 and 5 is 5













Use of Relational Operator

#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=6,c,d,e,f,g;
clrscr();
c=a>b;
d=a<b;
e=(4!=3);
f=(8>=17);
g=(123<=123);
printf("Value of c=%d\n",c);
printf("Value of d=%d\n",d);
printf("Value of e=%d\n",e);
printf("Value of f=%d\n",f);
printf("Value of g=%d\n",g);
getch();
}


OUTPUT:


Value of c=0
Value of d=1
Value of e=1
Value of f=0
Value of g=1












Logical Operator

#include<stdio.h>
#include<conio.h>
void main()
{
int a=40,b=30,c=50,d,e;
clrscr();
d=a==40&&b==c;
e=b==a&&b<c;
printf("d=%d\ne=%d",d,e);
getch();
}


OUTPUT:


d=0
e=0










Pre Increement

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
clrscr();
x=10;
y=++x;
printf("x=%d\ny=%d",x,y);
getch();
}


OUTPUT:


x=11
y=11









Post Increement

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
clrscr();
x=10;
y=x++;
printf("x=%d\ny=%d",x,y);
getch();
}


OUTPUT:


x=11
y=10











 

Blogger news

Blogroll

Enter your email address:

Delivered by FeedBurner

Total Pageviews

Followers

Most Reading