0
Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Programs discussed so far!

1,456

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
1,456
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
37
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. Programming Language CS-103 Snapshot of Programs discussed in Class &amp; Labs
• 2. /*Palindrome Program1*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); int a,b[10],c[10],i=0,L,j,k; char ch='F'; printf("nEnter a number:"); scanf("%d",&amp;a); while(a&gt;0) { b[i]=a%10; a=a/10; i++; } for(j=i-1,k=0;j&gt;=0;j--,k++) { c[j]=b[k]; } for(L=0;L&lt;i;L++) { if(c[L]=b[L]) { ch='T'; else ch='F'; } if(ch=='T') printf("Palindrome"); else printf("Number is not a Palindrome"); getch(); } /* Removing Vowels from String */ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; int check_vowel(char); void main(void) { char s[100],t[100]; int i,j=0; printf("Enter a string to delete Vowels:"); gets(s); for(i=0;s[i]!='0';i++) { if(check_vowel(s[i])==0) // not a vowel { t[j]=s[i]; j++; } } t[j]='0'; printf("String after deleting vowels:%sn",t); getch(); } int check_vowel(char) { switch(c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': return 1; default: return 0; } } /*Palindrome Program2*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;string.h&gt; void main(void) { clrscr(); char a[25],b[25]; printf("Enter a string:"); gets(a); strrev(strcpy(b,a)); if(strcmp(a,b)==0) printf("String is a palindrome"); else printf("String is not a palindrome"); getch(); } /*Palindrome program3*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); int a,s=0; printf("nEnter a number:"); scanf("%d",&amp;a); temp=a; // store 'a' for comparison while(a&gt;0) { s=(s*10)+(a%10); a=a/10; } if(c==s) printf("Palindrome"); else printf("Number is not a Palindrome"); getch(); }
• 3. /*Decimal to Binary Conversion*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int binary[10],n,r,c=0,i; clrscr(); printf("Enter a decimal number:"); scanf(%d",&amp;n); while(n&gt;0) { r=n%2; b[c]=r; n=n/2; c++; } printf("nThe Binary Equivalent is:"); for(i=c-1;i&gt;=0;i--) printf("%d",b[i]); getch(); } /*Reverse of string*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { char a[30], b[30]; int j,length; clrscr(); printf("Enter string:"); gets(a); length=strlen(a); printf("Length of string is:%d",length); for(j=0;j&lt;=length;j++) { b[j]=a[length-1-j]; } printf("nFinal String is: %s",b); getch(); } /*sum of digits of integers*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int n,r,s=0; clrscr(); printf("Enter a number:"); scanf("%d",&amp;n); while(n&gt;0) { r=n%10; s=s+r; n=n/10; } printf("nThe sum of the digits is:%d",s); getch(); } //Type Casting #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); int i=9,j=2; float value; //value=(float)i/(float)j; //value=float(i)/float(j); printf("value = %f",value); getch(); } //String #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { char name[6]={'h','e','l','l','o','o','p','0'}; printf("%s",name); getch(); } //increment operator #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int num=0; clrscr(); printf("nNumber =%dn",num++); printf("Number =%dn",++num); printf("Number =%dn",num); getch(); }
• 4. /*Swapping of strings*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { char fstr[30], sstr[30], temp[30]; clrscr(); printf("n Enter string1:"); gets(fstr); printf("n Enter string2:"); gets(sstr); printf("nString before swapping n String1:: %s n string2::%s",fstr,sstr); strcpy(temp,fstr); strcpy(fstr,sstr); strcpy(sstr,temp); printf("nString before swapping n String1:: %s n string2::%s",fstr,sstr); getch(); } /*Total Number of vowels*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); int i,j; char a[21]; printf("n Please enter String:"); gets(a); for(i=0,j=0;a[i]!='0';i++) { if(a[i]=='a' || a[i]=='A' || a[i]=='e' || a[i]=='E' || a[i]=='i' || a[i]=='I' || a[i]=='o' || a[i]=='O' || a[i]=='u' || a[i]=='U') j++; } printf("Total no. of Vowels are:%d",j); getch(); } //Unions Example #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { union intflo { int intnum; float fltnum; } unex; printf("size of(union intflo)=%dn",sizeof(union intflo); unex.intnum=734; printf("unex.intnum=%dn",unex.intnum); unex.fltnum=867.43; printf("unex.fltnum=%.2fn",unex.fltnum); getch(); } //Structure Example #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { struct easy { int num; char ch; } struct easy ez1; ez1.num=2; ez1.ch='Z'; printf("ez1.num=%d,ez1.ch=%c",ez1.num,ez1.ch); getch(); } //Stored address Example #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int varx; char vary; printf("Address of varx:%xn",&amp;varx); printf("Address of vary:%xn",&amp;vary); getch(); } //Pointers Example1 #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int var=20; int *ip; ip=&amp;var; printf("Address of var:%xn",&amp;var); printf("Address stored in pointer variable:%xn",ip); printf("Value of *ip variable:%dn",*ip); getch(); }
• 5. /* BUBBLE SORT implementation using array ascending order*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); int s, t, j, a[10]; printf("nEnter total no of elements:"); scanf("%d",&amp;s); printf("nEnter %d elements",s); for(i=0;i&lt;s;i++) scanf("%d",&amp;a[i]); //Bubble Sorting for(i=s-2;i&gt;=0;i--) { for(j=0;j&lt;=1;j++) { if(a[j]&gt;a[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } } printf("After sortingn"); for(i=0;i&lt;s;i++) printf("%d",d[i]); getch(); } /*Alphabet and Vowel check #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main (void) { clrscr(); char J; printf("Enter a character:"); scanf("%c",&amp;J); if((J&gt;='a' &amp;&amp; J&lt;='z') || (J&gt;='A' &amp;&amp; J&lt;='Z')) { printf("%c is an alphabet",J); if(J=='a' || J=='A' || J=='e' || J=='E' || J=='i' || J=='I' || J=='o' || J=='O' || J=='u' || J=='U') printf(" and a vowel"); else printf(" but not a vowel"); } else printf("%c is not an alphabet",J); getch(); } //using 'getche' function #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); char name[20],ch='y'; float T1,T2,avg; while(ch=='y') { printf("Enter name:"); gets(name); printf("Enter marks for Test1:"); scanf("%f",&amp;T1); printf("Enter marks for Test2:"); scanf("%f",&amp;T2); avg=(T1+T2)/2; printf("Average=%f",avg); printf("More data (y/n)?"); ch=getche(); } } //Factorial #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); int count,a; scanf(%d",&amp;a); for(count=a;count&gt;=1;count--) { a=a*(count-1); } printf("%d",a); getch(); }
• 6. /*Greater among 3 number*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main (void) { clrscr(); int i,a,b,c; printf("Enter three number with space[a!=b!=c]:"); scanf("%d %d %d",&amp;a,&amp;b,&amp;c); if(a&gt;b &amp;&amp; a&gt;c) printf("%d is the largest number",a); else if(b&gt;a &amp;&amp; b&gt;c) printf("%d is the largest number",b); else printf("%d is the largest number",c); getch(); } /*Print all the divisors of a given number*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); int i, n; printf("Enter a number:"); scanf("%d",&amp;n); printf("n The divisors arenn"); for(i=1;i&lt;=n;i++) { if(n%i==0) { printf("%dt",i); } } getch(); } /* Adding two numbers using Function*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; //int add(int a,int b); int add(int a,int b) { int add; add=a+b; return add; } int main() { int num1,num2,sum; printf("nEnter two numbers to add:"); scanf("%d %d",&amp;num1,&amp;num2); sum=add(num1,num2); printf("sum=%d",sum); getch(); } //Character count without white spaces #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int i=0,count=0; char str[20]; clrscr(); printf("Enter a string:"); gets(str); while(str[i]!='0') { if(str[i]!=' ') { count++; } i++; } printf("Character count:%d",count); getch(); } //Character count with white spaces #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); int i=0; char str[20]; printf("Enter a string:"); gets(str); while(str[i]!='0') { i++; } printf("Total characters are:%d",i); getch(); }
• 7. //right angle triangle &amp; its reflection type2 #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int i,j,rows; clrscr(); printf("Enter number of rows:"); scanf("%d",&amp;rows); for(i=1;i&lt;=rows;++i) { for(j=1;j&lt;=i;++j) { printf("%d",i); } printf("n"); } for(k=i;k&gt;=0;k--) { for(L=1;L&lt;=k;L++) { printf("%d",k); } printf("n"); } getch(); } * ** *** ** * //right angle triangle &amp; its reflection type1 #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int i,j,rows; clrscr(); printf("Enter number of rows:"); scanf("%d",&amp;rows); for(i=1;i&lt;=rows;++i) { for(j=1;j&lt;=i;++j) { printf("*"); } printf("n"); } for(k=i;k&gt;=0;k--) { for(L=1;L&lt;=k;L++) { printf("*"); } printf("n"); } getch(); } * ** *** ** * /*Prime Number*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; int prime(int a); void main(void) { clrscr(); int n; printf("enter a number:"); scanf("%d",&amp;n); prime(n); getch(); } int prime(int a) { int i; char Ch='T'; for(i=2;i&lt;a;i++) { if(a%i==0) { printf("n%d is not a prime number",a); Ch='F'; break; } // above if ends here } //for loop ends here if(Ch=='T') printf("n%d is a prime number",a); } //function definition ends here
• 8. //PyramidType1 #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int i,space,rows,k=0,L,m,space1; clrscr(); printf("Enter the number of rows:"); scanf("%d",&amp;rows); for(i=1;i&lt;=rows;i++) { for(space=1;space&lt;=rows-i;space++) { printf(" "); } for(k=0;k&lt;2*i-1;k++) { printf("*"); } printf("n"); } for(L=i-1;L&gt;=1;L--) { for(space1=1;space1&lt;=rows-L;space1++) printf(" "); for(m=L;m&lt;=2*L-1;m++) printf("*"); for(m=1;m&lt;=L-1;m++) printf("*"); printf("n"); } getch(); } //PyramidType2 #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int i,space,rows,k=0,L,m,space1; clrscr(); printf("Enter the number of rows:"); scanf("%d",&amp;rows); for(i=1;i&lt;=rows;i++) { for(space=1;space&lt;=rows-i;space++) { printf(" "); } for(k=0;k&lt;2*i-1;k++) { printf("*"); } printf("n"); } for(L=i-1;L&gt;=1;L--) { for(space1=1;space1&lt;=rows-L+1;space1++) printf(" "); for(m=L;m&lt;2*L-1;m++) printf("*"); for(m=1;m&lt;L-1;m++) printf("*"); printf("n"); } getch(); } //Pyramid3 #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main (void) { int i,j,m,k,n,space; clrscr(); printf("Enter no.of rows:n"); scanf("%d",&amp;n); textcolor(RED); for(i=1;i&lt;=n;i++) { for(space=1;space&lt;=n-i;space++) { printf(" "); } for(k=1;k&lt;=2*i-1;k++) { cprintf("8"); } printf("n"); } textcolor(YELLOW); for(m=i-2;m&gt;=1;m--) { for(j=1;j&lt;i-m;j++) { printf(" "); } for(k=1;k&lt;=2*m-1;k++) { cprintf("8"); } printf("n"); } getch(); }
• 9. //Graphics Example #include &lt;graphics.h&gt; #include &lt;conio.h&gt; main() { int gd = DETECT, gm; initgraph(&amp;gd, &amp;gm, "C:TCBGI"); setcolor(YELLOW); rectangle(0,30,639,450); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2); setcolor(WHITE); outtextxy(275,0,"Bar Chart"); setlinestyle(SOLID_LINE,0,2); line(100,420,100,60); line(100,420,600,420); line(90,70,100,60); line(110,70,100,60); line(590,410,600,420); line(590,430,600,420); outtextxy(95,35,"Y"); outtextxy(610,405,"X"); outtextxy(85,415,"O"); setfillstyle(LINE_FILL,BLUE); bar(150,100,200,419); setfillstyle(XHATCH_FILL,RED); bar(225,150,275,419); setfillstyle(WIDE_DOT_FILL,GREEN); bar(300,200,350,419); setfillstyle(INTERLEAVE_FILL,MAGENTA); bar(375,125,425,419); setfillstyle(HATCH_FILL,BROWN); bar(450,175,500,419); getch(); } //string functions #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { clrscr(); char str1[12]="Hello"; char str2[12]="World"; char str3[12]; int len; /*copy str1 into str3*/ strcpy(str3,str1); printf("%sn",str3); /*concatenate str1 &amp; str2 */ strcat(str1,str2); printf("%sn",str1); /*total length of str1 after concatenation*/ len=strlen(str1); printf("String length(str1):%dn",len); getch(); } /*Recursive Function to sum first n natural nos.*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; int sum(int n); int main() { int add,num; printf("Enter a +ve integer:"); scanf("%d",&amp;num); add=sum(num); printf("sum=%d",add); getch(); } int sum(int n) { if(n==0) return 0; else return (n+sum(n-1)); } //Word count #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int i=0,count=1; char str[20]; clrscr(); printf("Enter a string:"); gets(str); while(str[i]!='0') { if(str[i]==' ') { count++; } i++; } printf("Total words are:%d",count); getch(); }
• 10. /* The following example shows the usage of isprint() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int var1 = 'k'; int var2 = '8'; int var3 = 't'; int var4 = ' '; if( isprint(var1) ) { printf("var1 = |%c| can be printedn", var1 ); } else { printf("var1 = |%c| can't be printedn", var1 ); } if( isprint(var2) ) { printf("var2 = |%c| can be printedn", var2 ); } else { printf("var2 = |%c| can't be printedn", var2 ); } if( isprint(var3) ) { printf("var3 = |%c| can be printedn", var3 ); } else { printf("var3 = |%c| can't be printedn", var3 ); } if( isprint(var4) ) { printf("var4 = |%c| can be printedn", var4 ); } else { printf("var4 = |%c| can't be printedn", var4 ); } getch(); } /* The following example shows the usage of isalnum() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int var1 = 'd'; int var2 = '2'; int var3 = 't'; int var4 = ' '; if( isalnum(var1) ) {printf("var1 = |%c| is alphanumericn", var1 ); } else {printf("var1 = |%c| is not alphanumericn", var1 );} if( isalnum(var2) ) {printf("var2 = |%c| is alphanumericn", var2 ); } else {printf("var2 = |%c| is not alphanumericn", var2 );} if( isalnum(var3) ) {printf("var3 = |%c| is alphanumericn", var3 );} else {printf("var3 = |%c| is not alphanumericn", var3 );} if( isalnum(var4) ) {printf("var4 = |%c| is alphanumericn", var4 ); } else {printf("var4 = |%c| is not alphanumericn", var4 );} getch(); } /* The following example shows the usage of isalpha() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int var1 = 'd'; int var2 = '2'; int var3 = 't'; int var4 = ' '; If( isalpha(var1) ) {printf("var1 = |%c| is an alphabetn", var1 ); } else {printf("var1 = |%c| is not an alphabetn",var1 );} if( isalpha(var2) ) {printf("var2 = |%c| is an alphabetn", var2 ); } else {printf("var2 = |%c| is not an alphabetn",var2 );} if( isalpha(var3) ) {printf("var3 = |%c| is an alphabetn", var3 );} else {printf("var3 = |%c| is not an alphabetn", var3 );} if( isalpha(var4) ) {printf("var4 = |%c| is an alphabetn", var4 ); } else { printf("var4 = |%c| is not an alphabetn", var4 ); } getch(); }
• 11. /* The following example shows the usage of islower() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int var1 = 'Q'; int var2 = 'q'; int var3 = '3'; if( islower(var1) ) {printf("var1 = |%c| is lowercase charactern", var1);} else {printf("var1 = |%c| is not lowercase charactern", var1 ); } if( islower(var2) ) { printf("var2 = |%c| is lowercase charactern", var2 ); } else { printf("var2 = |%c| is not lowercase charactern", var2 ); } if( islower(var3) ) { printf("var3 = |%c| is lowercase charactern", var3 ); } else { printf("var3 = |%c| is not lowercase charactern", var3 ); } getch(); } /* The following example shows the usage of isspace() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int var1 = 't'; int var2 = '1'; int var3 = ' '; if( isspace(var1) ) { printf("var1 = |%c| is a white-space charactern", var1 ); } else { printf("var1 = |%c| is not a white-space charactern", var1 ); } if( isspace(var2) ) { printf("var2 = |%c| is a white-space charactern", var2 ); } else { printf("var2 = |%c| is not a white-space charactern", var2 ); } if( isspace(var3) ) { printf("var3 = |%c| is a white-space charactern", var3 ); } else { printf("var3 = |%c| is not a white-space charactern", var3 ); } getch(); } /* The following example shows the usage of isupper() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int var1 = 'M'; int var2 = 'm'; int var3 = '3'; if( isupper(var1) ) { printf("var1 = |%c| is uppercase charactern", var1 ); } else { printf("var1 = |%c| is not uppercase charactern", var1 ); } if( isupper(var2) ) { printf("var2 = |%c| is uppercase charactern", var2 ); } else { printf("var2 = |%c| is not uppercase charactern", var2 ); } if( isupper(var3) ) { printf("var3 = |%c| is uppercase charactern", var3 ); } else { printf("var3 = |%c| is not uppercase charactern", var3 ); } getch(); }
• 12. /*program that accept values in 2-Dimensional 3 by 3 array and displays the sum of all the elements */ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int arr[3][3], i, j, sum=0; /*Accepts input from the user and stores it in 2-D array*/ for(i=0;i&lt;3;i++) { for(j=0;j&lt;3;j++) { printf(&#x201C;nEnter the value for A[%d][%d]: &#x201C;,i,j); scanf(&#x201C;%d&#x201D;,&amp;arr[i][j]); } } /*Calculate sum of elements in 2-D array*/ for(i=0;i&lt;3;i++) { for(j=0;j&lt;3;j++) { sum=sum+arr[i][j]; } } /*Display the value of sum*/ printf(&#x201C;nThe sum of the elements of 2-D array is %d&#x201D;, sum); getch(); } /*Transpose means changing rows into columns and vice versa. */ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main(void) { int a[10][10], b[10][10], m,n,I,j; printf(&#x201C;nEnter number of rows &amp; column of array:&#x201D;); scanf(&#x201C;%d %d&#x201D;,&amp;m,&amp;n); printf(&#x201C;nEnter elements of 2-D array:n&#x201D;); for(i=0;i&lt;m;i++) { for(j=0;j&lt;n;j++) { scanf(&#x201C;%d&#x201D;,&amp;a[i][j]); } } printf(&#x201C;nn2-D array before transposing :nn&#x201D;); for(i=0;i&lt;m;i++) { for(j=0;j&lt;n;j++) { printf(&#x201C;t%d&#x201D;,a[i][j]); } printf(&#x201C;nn&#x201D;); } /*Transposing array*/ for(i=0;i&lt;m;i++) { for(j=0;j&lt;n;j++) { b[j][i]=a[i][j]; } } printf(&#x201C;nn2-D array after transposing:nn&#x201D;); for(i=0;i&lt;n;i++) { for(j=0;j&lt;m;j++) { printf(&#x201C;t%d&#x201D;,b[i][j]); } printf(&#x201C;nn&#x201D;); } getch(); } /*Graphics*/ #include&lt;conio.h&gt; #define left 1 #define top 1 #define right 15 #define bot 1 void main(void) { clrscr(); window(left, top, right, bot); textcolor(12 or LIGHTRED); textbackground(6 or BROWN); cputs(&#x201C;Chocolate&#x201D;); gotoxy(1,1); getch(); } /*Circle*/ #include&lt;graphics.h&gt; #include&lt;conio.h&gt; main() { int gd=DETECT,gm; initgraph(&amp;gd,&amp;gm,""); /* initialization of graphic mode */ circle(150,150,100); getch(); closegraph(); /* Restore orignal screen mode */ } /*Rectangle*/ #include&lt;graphics.h&gt; #include&lt;conio.h&gt; main() { int gd = DETECT, gm; initgraph(&amp;gd, &amp;gm, "C:TCBGI"); rectangle(100,100,200,200); getch(); closegraph(); }
• 13. /* The following example shows the usage of isdigit() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int var1 = 'h'; if( isdigit(var1) ) { printf("var1 = |%c| is a digitn", var1 ); } else { printf("var1 = |%c| is not a digitn", var1 ); } getch(); } /* The following example shows the usage of toupper() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int i = 0; char str[] = "Tutorials Point"; while(str[i]) { putchar(toupper(str[i])); i++; } getch(); } /* The following example shows the usage of tolower() function. */ #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;ctype.h&gt; void main(void) { int i = 0; char str[] = "TUTORIALS POINT"; while( str[i] ) { putchar(tolower(str[i])); i++; } getch(); } Pointer is nothing but a variable which stores the address of another variable. While using the pointer we can store any data type suppose using an array we can be able to store particular defined data type only, but in pointers we can store any data type. It&#x2019;s like a reference variable.