Professional Documents
Culture Documents
Practical File OF Programming in C: Submitted To
Practical File OF Programming in C: Submitted To
Practical File OF Programming in C: Submitted To
Submitted By: Name: Neha Rani Course: PGDCA Subject:- Programming using C Paper code:- PGDCA-106 Roll No: Semester: 1st
1
INDEX
Sr. No.
1. 2. 3. 4. 5. 6. 7.
Page No. 5 7 9 11 13 15 17 19 22 24 26 29 32 34 36
Remarks
8.
9. 10. 11. 12. 13. 14. 15
16. 17.
W.A.P to find factorial of a no. W.A.P to print 1 23 456 7 8 9 10 W.A.P to print * ** *** W.A.P to print the nos. using 1.D array. W.A.P to add 2 matrices W.A.P to multiply 2 matrices. W.A.P to search an element using linear statement. W.A.P to calculate length of a string. W.A.P to copy of a string. W.A.P to concatenation of a string W.A.P to reserve of a string. W.A.P to illustrate the concept of function. W.A.P to illustrate the concept of function prototyping. W.A.P to illustrate the conceptof call by reference. W.A.P to illustrate the concept of call by value.
3
38 40
18.
42
19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30.
45 47 50 53 57 59 61 63 66 68 70 72
34.
W.A.P to illustrate the concept of factorial of recursion. W.A.P to read and write the library data by using structure. W.A.P to find average marks of three subjects of n student by using array of structure. W.A.P to handle bank customer data by using nesting of structure. W.A.Pto show arithmetic operations by using pointer. W.A.P to display the use of pointer. W.A.P to illustrate the concept of array with pointer.
74 77 79 82 86 88 90
OUTPUT
OUTPUT
OUTPUT
10
11
OUTPUT
12
13
OUTPUT
14
15
OUTPUT
16
17
OUTPUT
18
19
OUTPUT
20
CONTROL STATEMENTS
21
22
OUTPUT
23
24
OUTPUT
25
#include<conio.h> void main() { int a,b,c; printf("Enter the value of a"); scanf("%d",&a); printf("Enter the value of b"); scanf("%d",&b); printf("Enter the value of c"); scanf("%d",&c); if(a>b) { if(a>c) { printf("Greatest is a"); } else { printf("Greatest is c"); } } else
26
27
OUTPUT
28
break; case 4: printf("\n colour is Yellow"); break; default: printf("\n Colour does not find"); } getch(); }
30
OUTPUT
31
32
OUTPUT
33
34
OUTPUT
35
36
OUTPUT
37
38
OUTPUT
39
40
OUTPUT
41
42
OUTPUT
43
Arrays
44
45
OUTPUT
46
} for(i=0;i<n;i++) for(i=0;j<n;j++) { c[i][j]= a[i][j]+b[i][j]; } } printf("\n The resultant matrix c is:\n"); for(i=0;i<n;i++) { for(j=0;j<m;j++) { printf("%d",c[i][j]); } printf("\n"); } getch(); }
48
OUTPUT
49
scanf("%d",&b[i][j]); } for(i=0;i<m;i++) for(j=0;j<q;j++) { for(k=0;k<n;k++) { c[i][j]=c[i][j]+a[i][k]*b[k][j]; } }} for(i=0;i<m;i++) { for(j=0;j<q;j++) { printf("%d",c[i][j]); printf(" "); } printf("\n"); } getch(); }
51
OUTPUT
52
printf("The number is present %d time",count); else printf("item is not present in the list"); getch(); }
54
OUTPUT
55
Strings
56
57
OUTPUT
58
59
OUTPUT
60
61
OUTPUT
62
63
OUTPUT
64
Function
65
66
OUTPUT
67
68
OUTPUT
69
70
OUTPUT
71
72
OUTPUT
73
OUTPUT
75
Structures
76
32. W.A.P to read and write the library data by using structure in C.
#include<stdio.h> #include<conio.h> void main() { struct library { char title [20]; char name [20]; int pages; float price; } book1; clrscr(); printf("Enter the title, name,page and price of a book"); scanf("%s%s%d%f",book1.title,book1.name,&book1.pages,&book1.price); printf("\n name of book=%s",book1.title); printf("\n name of author = %s",book1.name); printf("\n no.of pages=%d",book1.pages); printf("\n price=%f",book1.price); getch(); }
77
OUTPUT
78
33. W.A.P to find average marks of 3 subjects of n students in a class by using array of structure.
#include<stdio.h> #include<conio.h> void main() { struct student { int sub1; int sub2; int sub3; } st[10]; int i,n,total; floatavg; clrscr(); printf("Enter the no.of students"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\n Enter marks of three sub of %d the student:",i+1); total=0; scanf("%d%d%d",&st[i].sub1,&st[i].sub2,&st[i].sub3); total=st[i].sub1+st[i].sub2+st[i].sub3; avg=total/3;
79
80
OUTPUT
81
{ printf("\n Enter customer name,address and phone no.:"); scanf("%s%s%d",cust[i].name,cust[i].address,&cust[i].phone_no); printf("\n Enter the bank branch data:"); for(j=1;j<=m;j++) { printf("\n Enter branch name,account number :"); scanf("\n %s%d%f",cust[i].acc[j].b_name,&cust[i].acc[j].account_no); } } printf(" \n Customer data is as:"); for(i=0;i<n;i++) { printf("\n customer name is:%s",cust[i].name); printf("\n customer address is:%s",cust[i].address); printf("\n customer phone no is :%d",cust[i].phone_no); printf("\n The bank branch data is:"); for(j=1;j<=m;j++) { printf("\n branch name is:%d",cust[i].acc[j].b_name); printf("\n Account number is :%d",cust[i].acc[j].account_no); } } getch();}
83
OUTPUT
84
pointer
85
86
OUTPUT
87
88
OUTPUT
89
90
OUTPUT
91