• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
C & DS Record Manual 1-44 Programs for ECE-A & ECE-B
EXPERIMENT 1: PROGRAM TO PRINT THE SIZES ANDRANGES OF DIFFERENT DATA TYPES#include<stdio.h>#include<conio.h>#include<limits.h>#include<float.h>void main(){clrscr();printf(" DATA TYPE SIZE IN BYTES MINIMUMVALUE MAXIMUM VALUE");printf("\n INTEGER(SIGNED) %d %i %d ",sizeof(int),INT_MIN,INT_MAX);printf("\nSHORT INTEGER %d %hi %hd",sizeof(short),SHRT_MIN,SHRT_MAX);printf("\nLONG INTEGER %d %ld %ld",sizeof(long),LONG_MIN,LONG_MAX);printf("\nUNSIGNED INTEGER %d %u%u",sizeof(unsigned int),0,UINT_MAX);printf("\nUNSIGNED SHORT INTEGER %d %u%u",sizeof(unsigned short),0,USHRT_MAX);printf("\nUNSIGNED LONG INTEGER %d %d%lu",sizeof(unsigned long),0,ULONG_MAX);printf("\nFLOAT %d 3.4E%d 3.4E+%d",sizeof(float),FLT_MIN_10_EXP,FLT_MAX_10 _EXP);printf("\nDOUBLE %d 1.7E%d 1.7E+%d",sizeof(double),DBL_MIN_10_EXP,DBL_MAX_10_EXP);printf("\nLONG DOUBLE %d 3.4E%d1.1E+%d",sizeof(longdouble),LDBL_MIN_10_EXP,LDBL_MAX_10_EXP);printf("\nCHARACTER(SIGNED) %d %d%d",sizeof(char),SCHAR_MIN,SCHAR_MAX);printf("\nUNSIGNED CHAR %d %d%d",sizeof(unsigned char),0,UCHAR_MAX);getch();}EXPERIMENT 2: DEMONSTRATING INTEGER CONSTANTS#include<stdio.h>#include<conio.h>void main(){clrscr();printf("\n integer constants are three types");printf("\n[1] decimal integer consist of a set of digits,0 through9,\npreceded by anoptional - or + sign");printf("\n valid examples of decimal integer constants are:");printf("\nint %d \n int %d \n long int %ld \n unsigned long int%lu \n long int%ld",+123,-378,-32271L,76542LU,12789845L);printf("\n[2] an octal integer constant consists of anycombination of 0 through 7, with a1
 
C & DS Record Manual 1-44 Programs for ECE-A & ECE-B
leading 0(means starting with 0)");printf("\n valid examples of octal integers:");printf("\n octal integers %o \t %o \t %o \t%o",037,0,0435,0551);printf("\n[3] A sequence of digits preceded by 0x and 0X isconsidered as hexadecimalinteger constants\nthey may also include alphabets Athrough F or a through f\nthe letters A or a through F or f represents thenumbers 10 to 15");printf("\n following are the examples of valid hex integers");printf("\n %X \t %x \t %X \t %x",0X2,0x9F,0Xbcd,0);getch();}EXPERIMENT 3: DEMONSTRATING FLOATING POINTCONSTANTS#include<conio.h>#include<stdio.h>void main(){clrscr();printf("\nReal constants are often known as floating pointconstants");printf("\ninteger constants are unfit for many quantities for examplelength,breadth,radius,price etc");printf("\n real numbers are in decimal notation, having awhole number followed by adecimal point and a fractional part");printf("\n for example %f \t %f \t %f \t %f are valid realnumbers", 21.5,.95,-.71,+.5);printf("\n a real number may also be expressed in exponentialnotation (or scientificnotation)");printf("\n for example the value 215.65 may also be written as2.1565e+2 wheree2=100");printf("\nexamples of legal floating point constants:");printf("\n %f \t %f \t %f \t %f \t %f ",0.65e4,12e-2,1.5e+5,3.18E+3,-1.2E-1);getch();}EXPERIMENT 4: DEMONSTRATING CHARACTER ANDSTRING CONSTANTS#include<stdio.h>#include<conio.h>void main(){int i,l;char string1[10]="MRITS";clrscr();printf("\n a single character constant contains a singlecharacter enclosed between a pair of single quote marks");printf("\ncharacter constants have integer values known asASCII values");printf(" the ASCII (american standard code for informationinterchange) values of somecharacter constants are :");for(i=35;i<=122;i++)printf(" %c=%d\t ",i,i);2
 
C & DS Record Manual 1-44 Programs for ECE-A & ECE-B
printf("\n a string constant is a sequence of character enclosedin double quotes");printf("\n the character may be letters,numbers,specialcharacters and blank space");l=printf("\n%s",string1);/* now l contains length of thestring*/puts(string1);for(i=0;i<l;i++)/* the is the another way of printing string*/printf("%c",string1[i]);printf("\n backslash characters constants are:");printf("\n audible alert(bell) \a");printf("\n back space mri\bts");printf("\n new line \n");printf("\n carriage return \r");printf("\n horizontal tab \t mrits");printf("\n vertical tab \v mrits");printf("\n single quote '\'' ");printf("\n double quote '\"' ");printf("\n quetion mark '\?' ");printf("\n backslash '\\' ");printf("\n null character '\0' ");getch();}EXPERIMENT 5: DEMONSTRATING C OPERATORS#include<stdio.h>#include<conio.h>void main(){int choice;clrscr();printf("\n[1] Airthmetic operators");printf("\n[2] increment and decrement operators");printf("\n[3] relational operators");printf("\n[4] Logical operators");printf("\n[5] Bitwise operators");printf("\nEnter ur choice");scanf("%d",&choice);switch(choice){case 1: {int a=5,b=3;float x=5,y=3;clrscr();printf("\n integer addition a+b=%d \n float additionx+y=%f ",a+b,x+y);printf("\n integer subtraction a-b=%d \n floatsubtraction x-y=%f",a-b,x-y);printf("\n integer multiplication a*b=%d \n floatmultiplicationx*y=%f",a*b,x*y);printf("\n integer quetiont division a/b=%d \ninteger remainder divisionamodb=%d",a/b,a%b);printf("\n there is no exact division in integer division \n and there is noremainder or quetiont division in floatdivision");printf("\n exact division or float divisionx/y=%f",a/b);}break;3
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...