Subscribe

RSS Feed (xml)

Friday, October 30, 2009

Write a C program to get the maximum and minimum values of a Data type

#include(stdio.h)  // note place '<' & '>' in place of '(' & ')'
#include(conio.h)
void main( )
{
int x, y;
clrscr( );
x=1; 
while( x > 0)
{
y = x;
x + + ;
}
printf("\nMaximum value : %d ", y );
printf("\nMinimum value : %d", x);
getch( );
}

Output:- Maximum value : 32767
Minimum value : -32768

Similarly we can find the below datatypes,
long int ( %ld )
char ( %d )
unsigned ( %u )
.....

No comments:

Post a Comment