You are on page 1of 89

1

1.Write a program to insert an element into one-dimensional array.


#include<stdio.h>
#include<conio.h>
void main()
{
int a[10];
int i,k,n,pos,val;
clrscr();
printf(enter n:\n);
scanf(%d,&n);
for(i=0;i<n;i++)
{
printf(enter number:\n);
scanf(%d,&a*i+);
}
printf(enter position:\n);
scanf(%d,&pos);
printf(enter value:\n);
scanf(%d,&val);
for(k=n-1;k>=pos;k--)
{
a[k+1]=a[k];
a[pos]=val;
n=n+1;
}
printf(array elements after insertion:\n);
for(i=0;i<n;i++)
{
printf(%d,a*i+);
printf(\n);
}
getch();
}


2

Output:
enter n:
3
enter number:
1
enter number:
2
enter number:
3
enter position:
2
enter value:
12
array elements after insertion:
1
2
12
3













3

2.Write a program to delete an element from one-dimensional array.
#include<stdio.h>
#include<conio.h>
Void main()
{
int a[10];
int I,k,n,pos;
clrscr();
printf(enter n:\n);
scanf(%d,&n);
for(i=0;i<n;i++)
{
printf(enter number:\n);
scanf(%d,&a*i+);
}
printf(enter position:\n);
scanf(%d,&pos);
for(k=pos+1;k<n-1;k++)
a[k-1]=a[k];
n=n-1;
printf(array elements after deletion:\n);
for(i=0;i<n;i++)
{
printf(%d,a*i+);
printf(\n);
}
getch();
}

Output:

enter n:
3
enter number:
1
enter number:
2
enter number:
4

3
enter position:
1
array elements after deletion:
1
3





















5

3.Write a program to sort array elements in ascending into one-dimensional array.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10];
int i,j,n,temp;
clrscr();
printf(enter n:\n);
scanf(%d,&n);
for(i=0;i<n;i++)
{
printf(enter number:\n);
scanf(%d,&a*i+);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf(array elements after sorting:\n);
printf(ascending data:\n);
for(i=0;i<n;i++)
printf(%d\n,&a*i+);
getch();
}





6

Output:
enter n:
3
enter number:
1
enter number:
3
enter number:
2
array elements after sorting:
ascending data:
1
2
3
























7

4.write a program to merge two one-dimensional arrays.

#include<stdio.h>
#include<conio.h>
void main()
{
int a1[3],a2[2],a[5];
int i,j;
clrscr();
printf(enter elements of first array:\n);
for(i=0;i<3;i++);
{
Scanf(%d,&a1[i]);
}
printf(enter elements of second array:\n);
for(i=0;i<2;i++)
{
scanf(%d,&a2*i+);
}
for(i=0,j=0;i<3;i++,j++)
a[j]=a1[i];
for(i=0;i<2;i++,j++)
a[j]=a2[i];
printf(\narray elements after merging:\n);
for(j=0;j<5;j++)
{
printf(%d,a*j+;
printf(\n);
}
getch();
}





8

Output:
enter elements of first array:
1
2
3
enter elements of second array:
4
5
array elements after merging:
1
2
3
4
5
















9

5.write a program to search given value in an one-dimensional array.
#include<stdio.h>
#include<conio.h>
Void main()
{
int a[10];
int i,n,val,flag=0;
clrscr();
printf(enter n:\n);
scanf(%d,&n);
printf(enter array elements :\n);
for(i=0;i<n;i++)
{
scanf(%d,&a*i+);
}
printf(enter value:\n);
scanf(%d,&val);
for(i=0;i<n;i++)
{
if(val==a[i]){
printf(data found at %d\n,i);
flag=1;
}
}
if(!flag){
printf(data not found);
}
getch();
}

Output:
enter n:
3
enter array elements:
1
2
3
enter value:
2
data found at 1
10

6.write a program to display matrix using array(2*2).

#include<stdio.h>
#include<conio.h>
Void main()
{
int a[2][2];
int i,j;
clrscr();
printf(enter array elements:\n);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(a*%d+*%d+=,i,j);
scanf(%d,&a*i+*j+);
}
}
printf(matrix is:\n);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
printf(%2d,a*i+*j+)
printf(\n);
}
getch();
}

Output:
enter array elements:
a[0][0]=1
a[0][1]=2
a[1][0]=3
a[1][1]=4
matrix is:
1 2
3 4



11

7.Write a program to display sum of matrix(3*3).
#include<stdio.h>
#include<conio.h>
Void main()
{
int a[3][3],b[3][3],c[3][3];
int i,j;
clrscr();
printf(enter matrix a:\n);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(%d,&a*i+*j+);
}
}
printf(enter matrix b:\n);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(%d,b*i+*j+);
}
}
printf(sum of matrix is:\n);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(%4d,c*i+*j+);
}
printf(\n);
}
getch();
12

}

Output:
enter matrix a:
1 2 3
4 5 6
7 8 9
enter matrix b:
1 2 3
4 5 6
7 8 9
sum of matrix is:
2 4 6
8 10 12
14 16 18
















13

8.Write a program to display multiplication of two matrix.
#include<stdio.h>
#include<conio.h>
Void main()
{
int a[10][10],b[10][10],c[10][10];
int i,j,k,m,n,sum=0;
clrscr();
printf(enter rows and columns:\n);
scanf(%d %d,&m,&n);
printf(enter matrix a:\n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf(%d,&a*i+*j+)
}
}
printf(enter matrix b:\n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf(%d,&b*i+*j+);
}
}
printf(multiplication of two matrix is:\n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
sum=0;
for(k=0;k<m;k++)
sum=sum+a[i][k]*b[k][j];
c[i][j]=sum;
printf(%d\t,c*i+*j+);
}
printf(\n);
}
getch();
}
14


Output:
Enter rows and columns:
3
3
enter matrix a:
1 2 3
4 5 6
7 8 9
Enter matrix b:
1 2 3
4 5 6
7 8 9
multiplication of two matrix is:
30 36 42
66 81 96
102 126 150















15

9.Write a program to check upper triangle in the matrix using array.
#include<stdio.h>
#include<conio.h>
Void main()
{
int a[10[10];
int i,j,m,n,flag=0;
clrscr();
printf(enter rows and columns:\n);
scanf(%d %d,&m,&n);
printf(enter matrix :\n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
Scanf(%d,&a*i+*j+);
}
}
for(i=0;i<m;i++)
{
for(j=i;j<n;j++)
{
if(a[i][j]==0)
{
flag=1;
go to outer:
}
}
}
outer:
if(!flag)
printf(matrix has upper triangle\n);
else
printf(matrix doesnt have upper triangle\n);
getch();
}

Output:

enter rows and columns:
4 4
16

enter matrix a:
1 1 1 1
0 1 1 1
0 0 1 1
0 0 0 1
matrix has upper triangle






















17

10.Write a program to print length of string using scanf().
#include<stdio.h>
#include<conio.h>
Void main()
{
int i,count=0;
char str[50];
clrscr();
puts(enter string:);
scanf(%s,&str);
for(i=0;str*i+!=\0;i++)
count++;
printf(length of string=%d,count);
getch();
}

Output:
enter string:
computer
length of string=8
or
enter string:
computer engineering
length of string=8










18

11.Write a program to print length of string using gets().
#include<stdio.h>
#include<conio.h>
Void main()
{
int i,count=0;
char str[50];
clrscr();
puts(enter string:);
gets(str);
for(i=0;str*i+!=\0;i++)
count++;
printf(length of string=%d,count);
getch();
}

Output:
enter string:
computer
length of string=8
or
enter string:
computer engineering
length of string=15










19

12.Write a program to print reverse string without using strrev().
#include<stdio.h>
#include<conio.h>
Void main()
{
int i,j,len;
char str[50],rev[50];
clrscr();
puts(enter string:);
gets(str);
for(len=0;str[len]!=NULL;len++)
printf( );
for(i=len-1,j=0;i>=0;i--,j++)
{
rev[j]=str[i];
}
rev[j]=NULL;
printf(reverse string=%s\nrev);
getch();
}

Output:
enter string:
computer
reverse string=repupmoc















20

13.Write a program to check whether the given word is Palindrome or not.

#include<stdio.h>
#include<conio.h>
Void main()
{
char str[50],temp[50];
clrscr();
puts(enter word:);
gets(str)
strcpy(temp,str);
strrev(temp);
if(strcmp(str,temp)==0)
printf(given number is palindrome\n);
else
printf(given number is not palindrome\n);
getch();
}
Output:
enter word:
madam
given number is palindrome
or
enter word:
computer
given number is not palindrome
















21

14. Write a program to convert lowercase characters of a string in uppercase.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[50];
clrscr();
puts(enter lowercase characters string);
gets(str);
strupr(str);
puts(str);
getch();
}

Output:
enter lowercase characters string:
aij
AIJ













22

14. Write a program which accept string from user and print its equivalent ASCII code.
#include<stdio.h>
#include<conio.h>
#include<string.h>
Void main()
{
char[50];
int i;
clrscr();
puts(enter string:);
gets(str);
printf(ASCII code of %s is\n,str);
for(i=0;i<strlen(str);i++)
printf(%d\t,str*i+);
getch();
}

Output:
enter string:
COMPUTER
ASCII code of COMPUTER is
67 79 77 80 85 84 69 82












23

15. Write a program to arrange five words in order.
#include<stdio.h>
#include<conio.h>
#include<string.h>
Void main()
{
char s[5][50],temp[50];
int i,j;
clrscr();
puts(enter five words:);
for(i=0;i<5;i++)
gets(s[i]);
for(i=0;i<4;i++)
{
For(j=i+1;j<5;j++)
{
if(strcmp(s[i],s[j])>0)
{
strcpy(temp,s[i]);
strcpy(s[i],s[j]);
strcpy(s[j],temp);
}
}
}
puts(words in order data:->);
for(i=0;i<5;i++)
printf(%s\n);
getch();
}
Output:
enter five words:
maths
chemistry
physics
biology
programming in c

words in order data:->
biology
chemistry
24

maths
physics
programming in c

























25

16. Write a program to print
C
C P
C P R
C P R O
C P R O G
C P R O G R
C P R O G R A
C P R O G R A M
C P R O G R A M M
C P R O G R A M M I
C P R O G R A M M I N
C P R O G R A M M I N G
C P R O G R A M M I N G
C P R O G R A M M I N
C P R O G R A M M I
C P R O G R A M M
C P R O G R A M
C P R O G R A
C P R O G R
C P R O G
C P R O
C P R
C P
C

#include<stdio.h>
#include<conio.h>
#include<string.h>
Void main()
{
Char s*+=cprogramming;
int i,j;
clrscr();
printf(\n\n);
for(i=0;i<=11;i++)
{
J=i+1;
Printf(%-12.*s\n,j,s);
}
for(i=11;i>=0;i--)
26

{
j=i+1;
printf(%-12.*s\n,j,s);
}
getch();
}

Output:
C
C P
C P R
C P R O
C P R O G
C P R O G R
C P R O G R A
C P R O G R A M
C P R O G R A M M
C P R O G R A M M I
C P R O G R A M M I N
C P R O G R A M M I N G
C P R O G R A M M I N G
C P R O G R A M M I N
C P R O G R A M M I
C P R O G R A M M
C P R O G R A M
C P R O G R A
C P R O G R
C P R O G
C P R O
C P R
C P
C






27

17. Write a program to print multiplication table of 1 to 5.
#include<stdio.h>
#include<conio.h>
#define rows 5
#define cols 5
Void main()
{
int multi[rows][cols];
int i,j,r,c;
clrscr();
printf( multiplication table:\n);
for(j=1;j<=cols;j++)
printf(%7d,j);
printf(\n------------------------------------------\n);
for(i=0;i<rows;i++){
r=i+1;
printf(%2d|\n,r);
for(j=1;j<cols;j++){
c=j;
multi[i][j]=r*c;
printf(%7d,multi*i+*j+);
}
Printf(\n);
}
getch();
}

Output:
multiplication table:
1 2 3 4 5
------------------------------------------------------------
1 | 1 2 3 4 5
2 | 2 4 6 8 10
3 | 3 6 9 12 15
4 | 4 8 12 16 20
5 | 5 10 15 20 25
28

18. Write a program to print ascii code of uppercase characters A to Z to lowercase characters a to z.
#include<stdio.h>
#include<conio.h>
Void main()
{
char c;
clrscr();
printf(\n\n);
for(c=65;c<=122;c++)
{
if(c>90 && c<97)
continue:
printf(|%5d-%c,c,c);
}
Printf(\n);
getch();
}

Output:

|65-A|66-B|67-C|68-D|69-E|70-F|71-G|72-H|73-I|74-J|75-K|76-L|77-M|78-N|79-O|80-P|81-Q|82-R|83-S
|84-T|85-U|86-V|87-W|88-X|89-Y|90-Z|97-a|98-b|99-c|100-d|101-e|102-f|103-g|104-h|105-i|106-j|107-k
|108-l|109-m|110-n|111-o|112-p|113-q|114-r|115-s|116-t|117-u|118-v|119-w|120-x|121-y|122-z











29

19. Write a program to print
G U J A R A T T A R A J U G
G U J A R A A R A J U G
G U J A R R A J U G
G U J A A J U G
G U J J U G
G U U G
G G

#include<stdio.h>
#include<conio.h>
#include<string.h>
Void main()
{
char s*+=GUJARAT;
int i,j,len;space;
clrscr();
len=strlen(s);
for(i=0;i<len;i++)
printf(%c,s*i+);
for(i=len-1;i>=0;i--)
printf(%c,s*i+);
printf(\n);
space=1;
for(j=len-1;j>=0;j--)

{
for(i=0;i<j;i++)
printf(%c,s*i+);
for(i=0;i<=space;i++)
printf( );
space=space+1;
for(i=j-1;i>=0;i--)
printf(%c,s*i+);
printf(\n);
}
getch();
}



30

Output:

G U J A R A T T A R A J U G
G U J A R A A R A J U G
G U J A R R A J U G
G U J A A J U G
G U J J U G
G U U G
G G





















31

20. Write a program to demostrate various string functions.
#include<stdio.h>
#include<conio.h>
#include<string.h>
Void main()
{
Char s1[50],s2[50],temp[50];
int len,n;
clrscr();
printf(enter string:\n);
gets(s1);
len=strlen(s1);
printf(length of %s is %d\n.s1,len);
puts(------------------------------------------------------);
strcpy(temp,s1);
printf(copy of %s is %s \ns1,temp);
puts(-------------------------------------------------------);
strrev(temp);
printf(reverse of %s is %s\n,s1,temp);
puts(------------------------------------------------------);
printf(enter any uppercase string:\n);
gets(s1);
strlwr(s1);
printf(converted lowercase string is %s\n,s1);
puts(----------------------------------------------------);
printf(enter any lowercase string:\n);
gets(s1);
strupr(s1);
printf(converted uppercase is %s\n,s1);
puts(----------------------------------------------);
printf(enter first string:\n);
gets(s1);
printf(enter second string:\n);
gets(s2);
strcat(s1,s2);
printf(joined string is %s \n,s1);
puts(-------------------------------------------);
printf(enter first string:\n);
scanf(%s,&s1);
printf(enter second string:\n);
scanf(%s,&s2);
32

printf(enter n:\n);
scanf(%d,&n);
strncat(s1,s2,n);
printf(joined n character string is %s,s1,s2);
puts(---------------------------------------------);
printf(enter first string:\n);
scanf(%s,&s1);
printf(enter second string:\n);
scanf(%s,&s2);
if(strcmp(s1,s2)==0)
printf(strings are same\n);
else
printf(strings are not same\n);
puts(------------------------------------------------);
printf(enter n:\n);
scanf(%d,&n);
if(strncmp(s1,s2,n)==0)
printf(n characters of string are same\n);
else
printf(n characters of string are not same\n);
getch();
}

Output:

Enter string:
aij
length of aij is 3
--------------------------------------------
Copy of aij is aij
---------------------------------------------
Reverse of aij is jia
---------------------------------------------
Enter any uppercase string:
AIJ
Converted lowercase string is aij
----------------------------------------------
Enter any lowercase string:
aij
converted uppercase string is AIJ
------------------------------------------------
Enter first string:
33

amrut
enter second string:
institute
joined string is amrutinstitute
--------------------------------------------------
Enter first string:
amrut
enter second string:
institute
enter n:
3
Joined n characters string is amrutins
----------------------------------------------------
Enter first string:
amrut
enter second string:
amrut
strings are same
---------------------------------------------------
Enter n:
3
n characters of string are same

21. Write a program to demostrate use of function.
#include<stdio.h>
#include<conio.h>
Void a()
{
int a;
printf(enter a:);
scanf(%d,&a);
printf(a=%d,a);
}
Void main()
{
Clrscr();
a();
getch();
}
Output:
Enter a: 2
a=2
34

22. Write a program to demostrate function using no arguments and no return type.

#include<stdio.h>
#include<conio.h>
Void a();
Void main()
{
Clrscr();
a();
getch();
}
Void a()
{
int num;
printf(enter number:\n);
scanf(%d,&num);
if(num%2==0)
printf(%d is even,num);
else
printf(%d is odd,num);
}
Output:
Enter number:
4
4 is even











35

23. Write a program to demostrate function using no argument but return type.
#include<stdio.h>
#include<conio.h>
int sum ();
void main()
{
Clrscr();
Sum();
getch();
}
int sum()
{
int a,b,sum;
printf(enter two numbers:\n);
scanf(%d %d,&a,&b);
sum=a+b;
printf(sum=%d,sum);
return(sum);
}
Output:
Enter two numbers:
3
2
Sum=5











36

24. Write a program to demostrate function with argument but no return type.
#include<stdio.h>
#include<conio.h>
Void max(int,int);
Void main()
{
int a,b;
clrscr();
max(a,b);
getch();
}
Void max(int c,int d)
{
Printf(enter two integer numbers:\n);
Scanf(%d %d,&c,&d);
if(c>d)
Printf(maximum number is %d,c);
else
printf(maximum number is %d,d);
}
Output:
Enter two integer numbers:
2
3
Maximum number is 3
















37

25. Write a program to demostrate function with argument and with return type.
#include<stdio.h>
#include<conio.h>
#include<math.h>
int fun(int,int);
void main()
{
int a,s;
clrscr();
fun(a,s);
getch();
}
int fun(int a,int s)
{
Printf(enter a:\n);
Scanf(%d,&a);
S=sqrt(a);
Printf(squareroot of %d is %d,a,s);
return (s);
}
Output:
Enter a:
4
Squareroot of 4 is 2


















38

26. Write a program to find factorial using recursive function.
#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
int fc,n;
clrscr();
puts(enter number:);
scanf(%d,&n);
fc=fact(n);
printf(factorial=%d,fc);
getch();
}
int fact(int n){
int f=1;
if(n==1)
return(f);
f=n*fact(n-1)
return(f);
}
Output:
Enter number:
5
factorial=120
















39

27. Write a program to swap of two numbers using function.

#include<stdio.h>
#include<conio.h>
int swap(int,int,int);
void main()
{
int n1,n2,n3;
clrscr();
swap(n1,n2,n3);
getch();
}
int swap(int a,int b,int temp)
{
Printf(enter numbers:\n);
Scanf(%d %d,&a,&b);
Printf(numbers before swapping->\n);
Printf(a=%d\nb=%d\n,a,b);
temp=a;
a=b;
b=temp;
printf(numbers after swapping->\n);
printf(a=%d\nb=%d\n,a,b);
return (a,b);
}

Output:
enter numbers:
2
3
numbers before swapping->
a=2
b=3
numbers after swapping->
a=3
b=2




40

28. Write a program to print array elements in ascending order data using function.
#include<stdio.h>
#include<conio.h>
Void data(int [],int n);
Void main()
{
int i,n,a[10];
clrscr()
printf(enter n:\n);
scanf(%d,&n);
printf(enter array elements:\n);
for(i=0;i<n;i++)
{
Scanf(%d,&a*i+);
}
data(a,n);
printf(array elements in ascending order data->\n);
for(i=0;i<n;i++)
printf(%d\n,a*i+);
getch();
}
Void data(int a[],int n)
{
int i,j,temp;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
}




41

Output:

Enter n:
4
Enter array elements:
1
4
3
2
array elements in order data->
1
2
3
4

29. Write a program to print factorial using function.

#include<stdio.h>
#include<conio.h>
int fact();
void main()
{
clrscr();
fact();
getch();
}
int fact(){
int n,f=1,i=1;
` printf(enter number:\n);
Scanf(%d,&n);
for(i=1;i<=n;i++)
{
f=f*i;
}
Printf(factorial=%d,f);
return(f);
}
Output:
Enter n:
5
factorial=120

42

30. Write a program to generate Fibonacci series using recursive function.
#include<stdio.h>
#incude<conio.h>
int Fibonacci(int);
void main()
{
int c,i=0,n;
clrscr();
printf(enter n:\n);
scanf(%d,&n);
printf(Fibonacci series is:\n);
for(c=1;c<=n;c++)
{
Printf(%d\n,Fibonacci(i));
}
getch();
}
int Fibonacci(int n)
{
if(n==0)
return 0;
else if(n==1)
return 1;
else
return(Fibonacci(n-1)+Fibonacci(n-2));
}
Output:
Enter n;
4
Fibonacci series is:
0
1
1
2





43

31. Write a program to print table of squares and cubes of 1 to 10 numbers.
#include<stdio.h>
#include<conio.h>
Void table();
Void main()
{
int a,s,c,n;
clrscr();
table();
getch();
}
Void table()
{
int a=1,s,c,n;
printf(enter n:\n);
scanf(%d,&n);
printf(-------------------------------------------\n);
printf(|number\t|square\t|cube\t|\n);
printf(--------------------------------------------\n);
while(a<=n)
{
Printf(|%d\t|,a);
s=a*a;
printf(%d\t|,s);
c=s*a;
printf(%d\t|\n,c);
a++;
}
Printf(------------------------------------------\n);
}











44

Output:

10
--------------------------------------------------------------
|number |square |cube |
|1 |1 |1 |
|2 |4 |8 |
|3 |9 |27 |
|4 |16 |64 |
|5 |25 |125 |
|6 |36 |216 |
|7 |49 |343 |
|8 |64 |512 |
|9 |81 |729 |
|10 |100 |1000 |
--------------------------------------------------------------
















45

32. Write a program to pass one-dimensional array in function.
#include<stdio.h>
#include<conio.h>
Void array(int [],int n);
Void main()
{
int a[10],n,i;
clrscr();
array(a,n);
getch();
}
Void array(int a[10],int n)
{
int i;
printf(enter n:\n);
scanf(%d,&n);
printf(enter array elements :\n);
for(i=0;i<n;i++)
{
Scanf(%d,&a*i+);
}
Printf(array elements location is:\n);
for(i=0;i<n;i++){
Printf(a*%d+=%d\n,i,a*i+);
}
}
Output:
Enter n:
5
Enter array elements:
1
2
3
4
5
array elements location is:
a[0]=1
a[1]=2
a[2]=3
a[3]=4
a[4]=5
46

33. Write a program to demostrate concept of local variable.
#include<stdio.h>
#include<conio.h>
Void f();
Void main()
{
int a; // local variable in main()
clrscr();
printf(enter a:\n);
scanf(%d,&a);
printf(a=%d\n,a);
f();
getch();
}
Void f()
{
int a; // local variable in UDF
printf(enter a:\n);
scanf(%d,&a);
printf(a=%d,a);
}

Output:

Enter a:
2
a=2
enter a:
5
a=5








47

34. Write a program to demostrate concept of global variable.
#include<stdio.h>
#include<conio.h>
int x,y; // global variables
void f(int);
void main(){
int max;
clrscr();
printf(enter x & y:\n);
scanf(%d %d,&x,&y);
f(max);
getch();
}
Void f(int max){
if(x>y)
max=x;
else
max=y;
printf(max=%d,max);
}
Output:
Enter x & y:
3
2
Max=3
















48

35. Write a program to demostrate concept of static variables.

#include<stdio.h>
#include<conio.h>
Static int x,y; // static global
Void f();
Void main(){
int min;
clrscr();
printf(enter x & y:\n);
scanf(%d %d,&x,&y);
f();
getch();
}
Void f(){
Static int min; // static local
If(x<y)
min=x;
else
min=y;
printf(min=%d,min);
}

Output:

Enter x & y:
3 2
min=2














49

35.Write a program to demo call by value.

#include<stdio.h>
#include<conio.h>
int f(int);
void main()
{
int a;
clrscr();
a=f(2);
printf(a=%d,a);
getch();
}
int f(int a)
{
a=2;
return a;
}

Output:
a=2












50

36. Write a program to check whether a word is palindrome or not using function.
#include<stdio.h>
#include<conio.h>
#include<string.h>
Void pal(char [])
{
char str[50],temp[50];
clrscr();
puts(enter a string:);
gets(str);
pal(str);
getch();
}
Void pal(char str[50])
{
Char temp[50];
Strcpy(temp,str);
Strrev(temp);
if(strcmp(str,temp)==0)
printf(given word is palindrome);
else
printf(given word is not palindrome);
}

Output:
Enter a string:
madam
given word is palindrome
or
enter a string:
apple
given word is not palindrome






51

37. Write a program to check whether a given number is prime or not.
#include<stdio.h>
#include<conio.h>
int prime(int);
void main()
{
int n,i;
clrscr();
printf(enter number:\n);
scanf(%d,&n);
prime(n);
getch();
}
int prime(int n)
{
int i;
for(i=2;i<=n;i++)
if(n%i==0)
{
Printf(number is not prime);
return 1;
}
else
{
printf(number is prime);
return 0;
}
}

Output:

Enter number:
19
Number is prime
Or
Enter number:
46
Number is not prime


52

38. Write a program to print largest word from given string.
#include<stdio.h>
#include<conio.h>
Void word(int);
Void main()
{
int n;
clrscr();
word(n);
getch();
}
Void word(int n)
{
char str[10][10];
int i,max,len[10];
printf(enter n:\n);
scanf(%d,&n);
printf(enter string:\n);
for(i=0;i<n;i++)
{
gets(str[i]);
}
for(i=0;i<n;i++)
{
len[i]=strlen(str[i]);
}
max=len[10];
for(i=1;i<n;i++)
{
if(max<len[i])
{
max=len[i];
}
}
Printf(maximum length=%d\n,max);
for(i=0;i<n;i++)
{
if(strlen(str[i])==max)
{
Printf(largetst word is %s,str*i+);
}
53

}
}

Output:

Enter n:
5
apple
banana
grapes
pineapple
onion
maximum length=9
largest word is pineapple


















54

39. Write a program to print reverse string using recursive function.
#include<stdio.h>
#include<conio.h>
Void reverse(char []);
Void main()
{
Char s[10];
Clrscr();
puts(enter string:);
gets(s);
puts(reverse string is);
reverse(s);
getch();
}
Void reverse(char s[10])
{
int i=0;
if(s[i+1]!=NULL)
reverse(&s[i+1]);
putchar(s[i]);
}
Output:
Enter string:
Computer
reverse string is retupmoc
















55

40. Write a program to demonstrate use of typedef data type.

#include<stdio.h>
#include<conio.h>
Void main()
{
typedef int a;
a s;
clrscr();
printf(enter s:\n);
scanf(%d,&s);
printf(s=%d,s);
getch();
}

Output:

Enter s:10
S=10














56

41. Write a program to demonstrate use of enumerated data type.
#include<stdio.h>
#include<conio.h>
Void main()
{
enum month{jan=1,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec};
enum month m;
clrscr();
printf(enter month number:\n);
scanf(%d,&m);
printf(month name=);
switch(m)
{
Case 1:printf(January\n);
break;
Case 2:printf(february\n);
break;
Case 3:printf(march\n);
break;
Case 4:printf(april\n);
break;
Case 5:printf(may\n);
break;
Case 6:printf(june\n);
break;
Case 7:printf(July\n);
break;
Case 8:printf(august\n);
break;
Case 9:printf(september\n);
break;
Case 10:printf(october\n);
break;
Case 11:printf(november\n);
break;
Case 12:printf(december\n);
break;
default:printf(wrong input\n);
break;
}
getch();
57

}

Output:

Enter month number:
3
March



































58

42. Write a program to demonstrate use of structure.

#include<stdio.h>
#include<conio.h>
Struct student
{
int en_no;
char name[50];
}s;
Void main()
{
Clrscr();
Printf(enter en_no:\n);
Scanf(%d,&s.en_no);
Printf(enter name:\n);
gets(s.name);
printf(your data is->\n);
printf(enroll number=%d\n,s.en_no);
printf(name=%s\n,s.name);
getch();
}

Output:

Enter en_no:
1
Enter name:
abc
Your data is->
enroll number=1
name=abc







59

43. Write a program to demo nesting structure.
#include<stdio.h>
#include<conio.h>
Struct student
{
int en_no;
char name[50];
struct b_date
{
int d;
int m;
int y;
}s1
}s;
Void main(){
Clrscr();
Printf(enter en_no:\n);
Scanf(%d,&s.en_no);
Printf(enter name:\n);
gets(s.name);
printf(enter birthdate:\n);
scanf(%d %d %d,&s.s1.d,&s.s1.m,&s.s1.y);
printf(your data is->\n);
printf(enroll number=%d\n,s.en_no);
printf(name=%s\n,s.name);
printf(D.O.B=%d/%d/%d\n, s.s1.d,s.s1.m,s.s1.y);
getch();
}
Output:
Enter en_no:
1
Enter name:
abc
enter birthdate:
02
11
1997
Your data is->
enroll number=1
name=abc
D.O.B=02/11/1997
60

44. Write a program to demonstrate array of structure.

#include<stdio.h>
#include<conio.h>
Struct student
{
int en_no;
char name[50];
}s[3];
Void main()
{
int i;
clrscr();
printf(enter student en_no and name:\n);
for(i=0;i<3;i++)
{
Scanf(%d %s,&s*i+.en_no,&,s*i+.name);
}

Printf(your data is->\n);
for(i=0;i<3;i++)
{
Printf(enroll number=%d\n,s*i+.en_no);
Printf(name=%s\n,s*i+.name);
}
getch();
}

Output:
Enter student en_no and name:
1 abc
2 def
3 xyz
your data is->
enroll number=1
name=abc
enroll number=2
name=def
enroll number=3
name=xyz


61

45. Write a program to input details of four students and display marksheet.
#include<stdio.h>
#include<conio.h>
struct student
{
int en_no;
char name[50];
int marks[3];
int total;
};
void main()
{
struct student s[3],temp;
int i,j;
clrscr();
for(i=0;i<3;i++)
{
Printf(enter en_no:\n);
scanf("%d",&s[i].en_no);
printf(enter name:\n);
scanf("%s",&s[i].name);
printf("enter marks of three subjects:\n");
scanf("%d %d %d",&s[i].marks[0],&s[i].marks[1],&s[i].marks[2]);
s[i].total=s[i].marks[0]+s[i].marks[1]+s[i].marks[2];
}
printf("marksheet->\n");
printf("en_no\tname\tsub1\tsub2\tsub3\ttotal\tper\n");
for(i=0;i<3;i++)
{
printf("%d\t",s[i].en_no);
printf("%s\t",s[i].name);
printf("%d\t",s[i].marks[0]);
printf("%d\t",s[i].marks[1]);
printf("%d\t",s[i].marks[2]);
printf("%d\t",s[i].total);
}
getch();
}



62

Output:

Enter en_no :
1
Enter name:
abc
Enter marks of three subjects:
12 34 45
Enter en_no:
2
Enter name:
def
Enter marks of three subjects:
45 67 78
Enter en_no:
3
Enter name:
xyz
Enter marks of three subjects:
67 89 70

Marksheet->
En_no name s1 s2 s3 total
1 abc 12 34 45 91
2 def 45 67 78 190
3 xyz 67 89 70 226










63

46. Write a program to display merit list of students using structure.
#include<stdio.h>
#include<conio.h>
struct merit
{
int en_no;
char name[50];
int marks[3];
int total;
float per;
};
void main()
{
struct merit s[5],temp;
int i,j;
clrscr();
printf(enter five students en_no,name and marks of three subjects:\n);
for(i=0;i<5;i++)
{
scanf("%d",&s[i].en_no);
scanf("%s",&s[i].name);
scanf("%d %d %d",&s[i].marks[0],&s[i].marks[1],&s[i].marks[2]);
s[i].total=s[i].marks[0]+s[i].marks[1]+s[i].marks[2];
s[i].per=(s[i].total/3);
}
for(i=0;i<4;i++)
{
for(j=i+1;j<5;j++)
{
if(s[i].total<s[j].total)
{
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
}
}
printf("marit list->\n");
printf("en_no\tname\tsub1\tsub2\tsub3\ttotal\tper\n");
for(i=0;i<5;i++)
{
64

printf("%d\t",s[i].en_no);
printf("%s\t",s[i].name);
printf("%d\t",s[i].marks[0]);
printf("%d\t",s[i].marks[1]);
printf("%d\t",s[i].marks[2]);
printf("%d\t",s[i].total);
printf("%.2f\n",s[i].per);
}
getch();
}

Output:

Enter five students en_no,name and marks of three subjects:
1 abc 12 23 34
2 def 34 45 56
3 xyz 56 67 78
4 jkl 67 76 57
5 ghi 99 90 95
Marit list->
En_no name s1 s2 s3 total per
5 abc 99 90 95 284 94.00
3 xyz 56 67 78 201 67.00
4 jkl 67 76 57 200 66.00
2 def 34 45 56 135 45.00
1 abc 12 23 34 69 23.00










65

47. Write a program to details & search a record as ecode,name and salary.
#include<stdio.h>
#include<conio.h>
struct empoyee
{
char ename[50];
int ecode;
int esalary;
}s[3];
void main()
{
int i,flag=0,code;
clrscr();
printf("enter name,ecode and salary of three employees:\n");
for(i=0;i<3;i++)
{
scanf("%s %d %d",&s[i].ename,&s[i].ecode,&s[i].esalary);
}
printf("enter code of employee:\n");
scanf("%d",&code);
for(i=0;i<3;i++)
{
if(s[i].ecode==code)
{
flag=1;
printf("name=%s\n",s[i].ename);
printf("ecode=%d\n",s[i].ecode);
printf("salary=%d\n",s[i].esalary);
goto outer;
}
}
outer:
if(!flag)
{
printf("data not found\n");
}
getch();
}



66

Output:

Enter name,ecode and salary of three employees:
abc 123 5000
def 345 10000
xyz 567 3000
enter code of employee:
345
name=def
ecode=345
salary=10000

or

Enter name,ecode and salary of three employees:
abc 123 5000
def 345 10000
xyz 567 3000
enter code of employee:
789
data not found












67

48. Write a program to input five account holders of a bank and deposited or withdraw money as per selection
using structure.
#include<stdio.h>
#include<conio.h>
void credit(int);
void dabit(int);
struct holders
{
int accountno;
char h_name[50];
int balance;
int ammount;
}h[5];

void main()
{
char n;
int i,a,flag=0,k;
clrscr();
printf("enter holder's name,account number and bank balance\n");
for(i=0;i<5;i++)
{
scanf("%s %d %d",&h[i].h_name,&h[i].accountno,&h[i].balance);
}
printf("enter ac no.\n");
scanf("%d",&a);
for(i=0;i<5;i++)
{
if(a==h[i].accountno)
{
flag=1;
k=i;
printf("your data is->\n");
printf("holder's name=%s\n",h[i].h_name);
printf("account no.=%d\n",h[i].accountno);
printf("bank balance=%d\n",h[i].balance);
goto outer;
}
}
outer:
if(!flag)
68

{
printf("data not found");
}
printf("enter your choice d/D or c/C:\n");
scanf("%s",&n);


if(n=='d' || n=='D')


dabit(k);


else

credit(k);


getch();
}
void dabit(int k)
{
int i;
printf("enter ammount:\n");
scanf("%d",&h[k].ammount);
if(h[k].ammount>h[k].balance)
{
printf("you don't have enough balance in your account");
}
else
{
h[k].balance=h[k].balance-h[k].ammount;
printf("your new balance is %d\n",h[k].balance);
}

}

void credit(int k)
{
int i;
printf("enter ammount:\n");
scanf("%d",&h[k].ammount);
69

h[k].balance=h[k].balance+h[k].ammount;
printf("your new balance is %d\n",h[k].balance);

}

Output:

Enter holders name,account number and bank balance:
abc 123 5000
def 456 10000
ghi 678 4000
jkl 789 5900
mno 453 6000
enter ac no:
123
Your data is->
holders name=abc
account number=123
bank balance=5000
enter your choice d/D or c/C:
d
enter amount:
2000
Your new balance is 3000
or
Enter holders name,account number and bank balance:
abc 123 5000
def 456 10000
ghi 678 4000
jkl 789 5900
mno 453 6000
enter ac no:
123
Your data is->
holders name=abc
account number=123
bank balance=5000
enter your choice d/D or c/C:
c
enter amount:
4000
Your new balance is 9000
70

48. Write a program to check how to use union.

#include<stdio.h>
#include<conio.h>
void word(int);
union student
{
int en_no;
char name[50];
}s;
Void main()
{
int i;
Clrscr();
Printf(enter en_no:\n);
Scanf(%d,&s.en_no);
printf(enroll number=%d\n,s.en_no);
Printf(enter name:\n);
gets(s.name);
printf(name=%s\n,s.name);
i=sizeof(s);
printf(size of union=%d\n,i);
getch();
}

Output:

Enter en_no:
1
enroll number=1
Enter name:
abc
name=abc
size of union=50






71

49.Write a program to demonstrate union within structure.

#include<stdio.h>
#include<conio.h>
struct student
{
int en_no;
char name[50];
union collage
{
char c_name[100];
char branch[50];
}c;
}s;
void main()
{
int i,u;
clrscr();
printf("enter en_no:\n");
scanf("%d",&s.en_no);
printf("enter name:\n");
scanf("%s",&s.name);
printf("en_no=%d\n",s.en_no);
printf("student name=%s\n",s.name);
printf("enter branch name:\n");
scanf("%s",&s.c.branch);
printf("branch name=%s\n",s.c.branch);
printf("enter college name:\n");
scanf("%s",&s.c.c_name);
printf("college name=%s\n",s.c.c_name);
i=sizeof(s);
printf("size of structure=%d\n",i);
u=sizeof(s.c);
printf("size of union=%d\n",u);
getch();
}

Output:
Enter en_no:
1
Enter name:
abc
72

en_no=1
student name=abc
enter branch name:
computer
branch name=computer
enter college name:
aij
college name=aij
size of structure=152
size of union=100


50. Write a program to demonstrate simple macro using #define.

#include<stdio.h>
#include<conio.h>
#define pie 3.14
Void main()
{
int r;
float area;
clrscr();
printf(enter r:\n);
scanf(%d,&r);
area=pie*r*r;
printf(area of circle=%f\n,area);
getch();
}

Output:
Enter r:
2
area of circle=12.56









73

51. Write a program to demonstrate use of macro with argument.

#include<stdio.h>
#include<conio.h>
# define add(x,y) (x+y)
# define pr printf
void main()
{
int x,a,y;
clrscr();
printf("enter x:\n");
scanf("%d",&x);
printf("enter y:\n");
scanf("%d",&y);
a=add(x,y);
pr("addition=%d\n",a);
getch();
}
Output:
Enter x:
2
Enter y:
3
addition=5


52.Write a program to print current date and time using predefined macros.

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("%s %s %d %s",__TIME__,__DATE__,__LINE__,__FILE__);
getch();

}
Output:
time=19:01:48
date=mar 13 2014
lines:6
file name=predefine.c
74

53. Write a program which accepts a string and counts number of alphabets,digits using <ctype>.

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char str[100];
int i=0;
int d,s,p,a;
d=s=p=a=0;

clrscr();
printf("enter string:\n");
gets(str);
while(str[i]!=NULL)
{
if(isdigit(str[i]))
d++;
else if(isalpha(str[i]))
a++;
else if(isspace(str[i]))
s++;
else if(ispunct(str[i]))
p++;
i++;
}
printf("alpha=%d\n",a);
printf("digits=%d\n",d);
printf("space=%d\n",s);
printf("punct=%d\n",p);

getch();
}

Output:
Enter string:
Raman age 25,aij!
alpha=11
digits=2
space=2
punct=2
75

54. Write a program to demonstrate nested macros.

#include<stdio.h>
#include<conio.h>
#define pie 3.14
#define area(r) pie*r*r
#define volume(r) (4*area(r)*r)/3
void main()
{
int r;
clrscr();
printf("enter radius:\n");
scanf("%d",&r);
printf("area of circle=%f\n",area(r));
printf("volume of circle=%f\n",volume(r));
getch();
}

Output:
Enter radius:
2
area of circle=12.56
volume of circle=33.493333



















76

55. Write a program to display value and address of variable without using pointer.

#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("enter a:\n");
scanf("%d",&a);
printf("value of a=%d\n",a);
printf("address of a=%x\n",&a);
getch();
}

Output:
Enter a:
10
Value of a=10
address of a=fff4

56. Write a program to display value and address of variable using pointer.

#include<stdio.h>
#include<conio.h>
void main()
{
int a=2;
int *p;
clrscr();
p=&a;
printf("value of a=%d\n",a);
printf("value of pointer=%x\n",p);
getch();
}

Output:
Value of a=2
Value of pointer=fff4



77

57. Write a program to increment value of variable using pointer variable.

#include<stdio.h>
#include<conio.h>
void main()
{
int a;
int *p;
clrscr();
printf("enter a:\n");
scanf("%d",&a);
p=&a;
printf("data before using pointer->\n");
printf("name\tvalue\taddress\n");
printf("a\t%d\t%x\n",a,&a);
printf("data after using pointer->\n");
printf("a\t%d\t%x\n",*p,p);
printf("data after increment->\n");
*p=*p+1;
printf("a\t%d\t%x\n",*p,p);
getch();
}

Output:
Enter a:
2
Data before using pointer->
Name value address
a 2 fff4
data after using pointer->
a 2 fff4
data after increment->
a 3 fff4









78

58. Write a program to

#include<stdio.h>
#include<conio.h>
void main()
{

int a=10;
int *p;
int *q;
clrscr();
p=&a;
q=p;
printf("value of variable=%d\n",*q);
printf("address of variable=%x\n",q);
printf("value of pointer=%x\n",q);
getch();
}

Output:
Value of variable=10
address of variable=fff4
value of pointer=fff4



















79

59. Write a program to print value and address of pointer.

#include<stdio.h>
#include<conio.h>
void main()
{
int *p;
int a=10;
clrscr();
p=&a;
printf("value of variable=%d\n",*p);
printf("address of variable=%x\n",p);
printf("value of pointer=%x\n",p);
printf("address of pointer=%x\n",&p);
getch();
}

Output:
value of variable=10
address of variable=fff2
value of pointer=fff2
address of pointer=fff4




















80

60. Write a program to demo call by refrence.

#include<stdio.h>
#include<conio.h>
void swapping(int *,int *);
void main()
{
int *x,*y;
clrscr();
printf("enter x & y:\n");
scanf("%d %d",&x,&y);
printf("before exchange:->\n");
printf("x=%d\ty=%d\n",x,y);
swapping(&x,&y);
printf("after exchnge:->\n");
printf("x=%d\ty=%d\n",x,y);
getch();
}
void swapping(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}

Output:
Enter x & y:
2
3
before exchange:->
X=2 y=3
after exchange:->
X=3 y=2








81

61. Write a program to print reverse of given string using pointer.

#include<stdio.h>
#include<conio.h>
int length(char *s);
void reverse(char *s);
void main()
{
char s[100];
clrscr();
puts("enter string:");
gets(s);
reverse(s);
printf("reverse string is %s\n",s);
getch();
}
void reverse(char *s)
{
char *end,temp;
int len;
len=length(s);
end=s+len-1;
while(s<end)
{
temp=*s;
*s=*end;
*end=temp;
s++;
end--;
}
}
int length(char *s)
{
int count=0;
while(*s++)
count++;
return(count);
}
Output:
Enter string:
Computer
Reverse string is retupmoc
82

62. Write a program to add two numbers using pointer argument.

#include<stdio.h>
#include<conio.h>
void add(int *,int *);
void main()
{
int c,d;
int *x,*y,z;
clrscr();
add(&c,&d);
getch();
}
void add(int *x,int *y)
{
int a,b,z;
printf("enter a & b:\n");
scanf("%d %d",&a,&b);
x=&a;
y=&b;
printf("a=%d\tb=%d\n",*x,*y);
z=*x + *y;
printf("addition of two numbers=%d\n",z);
}

Output:
Enter a & b:
2
3
a=2 b=3
addition of two numbers=5











83

63. Write a program to read and print array elements using pointer.

#include<stdio.h>
#include<conio.h>
void main()
{
int *p;
int a[10];
int i,n;
clrscr();
p=a;
printf("enter size of array:\n");
scanf("%d",&n);

printf("enter array elements:\n");
for(i=0;i<n;i++,p++)
{
printf("a[%d]=",i);
scanf("%d",p);
}
p=p-n;
printf("array elements are->\n");
for(i=0;i<n;i++,p++)

printf("%d\n",*p);

getch();
}
Output:
Enter size of array:
3
Enter array elements:
a[0]=10
a[1]=20
a[2]=30
array elements are->
10
20
30



84

64. Write a program to demo void pointer.

#include<stdio.h>
#include<conio.h>
void main()
{
int a=2;
float b=2.3;
char c='a';
void *p;
clrscr();
p=&a;
printf("int a=%d\n",*(int *)p);
p=&b;
printf("float b=%.1f\n",*(float *)p);
p=&c;
printf("char c=%c\n",*(char *)p);
getch();

}

Output:
int a=2
float b=2.3
char c=a

















85

65. Write a program to demo pointer to pointer.

#include<stdio.h>
#include<conio.h>
void main()
{
int a;
int *p;
int **q;
clrscr();
printf("enter a:\n");
scanf("%d",&a);
p=&a;
q=&p;
printf("using only variable->\n\n\n");
printf("value\taddress\n\n\n");
printf("%d\t%x\n\n\n",a,&a);
printf("using pointer->\n\n\n");
printf("%d\t%x\n\n\n",*p,p);
printf("using pointer to pointer->\n\n\n");
printf("%d\t%x\n\n\n",**q,*q);
getch();
}

Output:
Enter a:
10
using only variable->
value address
10 fff4
using pointer->
10 fff4
using pointer to pointer->
10 fff4








86

66. Write a program to demo array of pointer.

#include<stdio.h>
#include<conio.h>
void main()
{
char *words[]={"ACP","FODE","BE","CP","JAVA"};
int i;
clrscr();
printf("name\taddress\n");
for(i=0;i<5;i++)
{
printf("%s\t%x\n",words[i]);
}
getch();
}

Output:
name address
ACP 37c
FODE 37c
BE 37c
CP 37c
JAVA 37c


















87

67. Write a program to arrange three words in order data using pointer.

#include<stdio.h>
#include<conio.h>
void main()
{
char *words[3][50],temp[50];
int i,j;
clrscr();
printf("enter three words:\n");
for(i=0;i<3;i++)
{
gets(words[i]);

}
for(i=0;i<2;i++)
{
for(j=i+1;j<3;j++)
{
if(strcmp(words[i],words[j])>0)
{
strcpy(temp,words[i]);
strcpy(words[i],words[j]);
strcpy(words[j],temp);
}
}
}
printf("words in order->\n");
for(i=0;i<3;i++)
{
printf("%s\n",words[i]);

}
getch();
}

Output:
Enter three words:
Pineapple
Apple
banana
Words in order->
88

Apple
Banana
pineapple


68. Write a program to demo function to pointer.

#include<stdio.h>
#include<conio.h>
void f(int *);
void main()
{
int a;
int *p;
clrscr();
f(&a);
getch();
}
void f(int *p)
{
int x=10;
p=&x;
printf("value=%d\n",*p);
printf("address=%x\n",p);

}

Output:
Value=10
address=fffec











69. Write a program to demo pointer in structure.
89

You might also like