Professional Documents
Culture Documents
M GROUP OF COLLEGES
PRACTICAL FILE OF
C
PROGRAMMING
SUBMITTED TO : SUBMITTED BY :
1
INDEX
S.N PROGRAM NAME Page.NO REMARKS
o
1 W.A.P to Find even or odd
number.
2 W.A.P to find print of 1
12
123
3 W.A.P to find largest of
three numbers.
4 W.A.P to find square root
of number.
5 W.A.P to calculate factorial
of a number .
6 W.A.P to print table of any
number.
7 W.A.P to calculate total
marks and average of a
student.
8 W.A.P to calculate simple
interest.
9 W.A.P to perform
swapping of two number .
10 W.A.P to find the year is
entered is leap or not.
11 W.A.P to perform an
arithmetic operation.
12 W.A.P function using call
by reference.
13 W.A.P to print table of any
2
number.
14 W.A.P to print addition of
two numbers.
15 W.A.P function using call
by value.
16 W.A.P to find the power of
number.
17 W.A.P to calculate
percentage of a student.
18 W.A.P to find function
value.
19 W.A.P by show use of
formal and actual
parameter.
20 W.A.P by using structure of
student.
21 W.A.P by using switch
statement.
22 W.A.P to illustrate the use
of pointer.
23 W.A.P to show the
concatination of two
string.
24 W.A.P to show the length
of the string.
25 W.A.P to find out the
numbers is prime or not.
3
WAP TO FIND OUT THE NUMBER IS
EVEN OR ODD.
#include<stdio.h>
#include<conio.h>
void main()
int n;
clrscr();
printf("enter a number:");
scanf("%d",&n);
if(n%2==0)
printf("number is even");
else
printf("number is odd");
getch();
4
OUTPUT:
5
WAP TO FIND PRINT OF PATTERN.
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
for(i=1;i<=5;i++)
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
getch();
6
OUTPUT:
7
WAP TO FIND LARGEST OF THREE
NUMBERS.
#include<stdio.h>
#i.nclude<conio.h>
void main()
float a,b,c,big;
clrscr();
scanf("%f%f%f",&a,&b,&c);
if(a>b)
if(a>c) big=a;
else big=c;
else
if(b>c) big=b;
else big=c;
getch();
8
OUTPUT:
9
WAP TO FIND SQUARE ROOT OF
NUMBER.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
int n;
clrscr();
float result;
scanf("%d",&n);
if(n<0)
goto start;
else
result=sqrt(n);
getch();
10
OUTPUT:
11
WAP TO CACULATE FACTORIAL OF A
NUMBER.
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
scanf("%d",&num);
while(num>=1)
fac=fac*num;
num--;
getch();
12
OUTPUT:
13
WAP TO PRINT TABLE OF ANY NUMBER.
#include<stdio.h>
#include<conio.h>
void main()
int number,i;
scanf("%d",&number);
for(i=1;i<=10;i++)
printf("%3d",i*number);
getch();
OUTPUT:
14
WAP TO CALCULATE TOTAL MARKS
AND AVERAGE OF A STUDENT.
#include<stdio.>
#include<conio.h>
void main()
float sum=0,number,mean;
int n,i;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%f",&number);
sum+=number;
mean=sum/n;
getch();
15
OUTPUT:
16
WAP TO CALCULATE SIMPLE INTEREST.
#include<stdio.h>
#include<conio.h>
void main()
float p,r,t,si;
clrscr();
scanf("%d%d%d",&p,&r,&t);
si=(p*r*t)/100;
getch();
17
OUTPUT:
18
WAP TO PERFORM SWAPPING OF TWO
NUMBERS.
#include<stdio.h>
#include<conio.h>
void main()
int a,b,c;
clrscr();
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
getch();
19
OUTPUT:
20
WAP TO FIND THE YEAR IS ENTERED
IS LEAP OR NOT.
#include<stdio.h>
#include<conio.h>
void main()
int year;
clrscr();
scanf("%d",&year);
if(year%4==0)
printf("year is leap");
else
getch();
21
OUTPUT:
22
WAP TO PERFORM AN ARITHMETIC
OPERATIONS.
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
scanf("%d%d",&a,&b);
sum=a+b;
diff=a-b;
mul=a*b;
div=a/b;
mod=a%b;
getch();
23
OUTPUT:
24
WAP FUNTION USING CALL BY
REFERENCE.
#include<stdio.h>
#include<conio.h>
void call_ref(int*);
void main()
clrscr();
int a;
a=10;
call_ref(&a);
getch();
void call_ref(int* n)
*n=*(n)+1;
25
OUTPUT:
26
WAP TO PRINT ADDITION OF TWO
NUMBERS.
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
int a[10][10],b[10][10],s[10][10],i,j,m,n;
scanf("%d%d",&m,&n);
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
scanf("%d",&a[i][j]);
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
scanf("%d",&b[i][j]);
27
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
s[i][j]=a[i][j]+b[i][j];
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
printf("%4d",s[i][j]);
printf("\n");
getch();
OUTPUT:
28
WAP TO PRINT TABLE OF ANY
NUMBERS.
#include<stdio.h>
#include<conio.h>
void main()
int i;
for (i=1;i<=20;i++)
printf("\n%d",i);
getch();
OUTPUT:
29
WAP FUCTION USING CALL BY VALUE.
#include<stdio.h>
#include<conio.h>
void call_value(int);
void main()
clrscr();
int a;
a=10;
call_value(a);
getch();
void call_value(int n)
n=n+1;
30
OUTPUT:
31
WAP TO FIND THE POWER OF NUMBER.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
clrscr();
int x,y,t;
scanf("%d%d",&x,&y);
t=pow(x,y);
printf("%d",t);
getch();
OUTPUT:
32
WAP TO CALCULATE PERCENTAGE OF
STUDENT.
#include<stdio.h>
#include<conio.h>
void main()
int per;
clrscr();
printf("Enter percentage");
scanf("%d",&per);
printf("1st division");
printf("2nd division");
printf("pass");
33
else
printf("fail");
getch();
OUTPUT:
34
WAP TO FIND FUNCTION VALUE.
#include<stdio.h>
#include<conio.h>
void main()
int sum(int,int);
int a,b,ans;
scanf("%d%d",&a,&b);
ans =sum(a,b);
getch();
int result;
result=f1+f2;
return(result);
35
OUTPUT:
36
WAP TO SHOW THE USE OF FORMAL
AND ACTUAL PARAMETER.
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
void sum();
sum();
getch();
void sum()
int a,b;
scanf("%d%d",&a,&b);
37
OUTPUT:
38
WAP BY USING STRUCTURE OF
STUDENT.
#include<stdio.h>
#include<conio.h>
struct student
int rollno;
clrscr();
char name[10];
char course[5];
float fees;
};
void main()
scanf("%d",&s1.rollno);
scanf("%s",&s1.name);
scanf("%s",&s1.course);
scanf("%f",&s1.fees);
39
printf("\n the fees of student is:%f",s1.fees);
getch();
Output:
40
WAP BY USING SWITCH STATEMENT.
#include<stdio.h>
#include<conio.h>
void main()
int month,days,year;
clrscr();
scanf("%d%d",&month,&year);
switch(month)
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days=31;
break;
case 4:
case 6:
case 9:
case 11:
days=30;
break;
41
case 2:
if(year%4==0)
days=29;
else
days=28;
break;
getch();
OUTPUT:
42
WAP TO ILLUSTRSTE THE USE OF
POINTER.
#include<stdio.h>
#include<conio.h>
void main()
int var1=100;
int var2=200;
clrscr();
int*ptr;
ptr=&var1;
ptr=&var2;
getch();
43
OUTPUT:
44
WAP TO SHOW THE CONCATENATION
OF TWO STRING.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
char s1[20],s2[20];
clrscr();
gets(s1);
gets(s2);
strcat(s1,s2);
getch();
OUTPUT:
45
WAP TO SHOW THE LENGTH OF THE
STRING .
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
clrscr();
char str[21];
int n;
printf("\nEnter astring:");
gets(str);
n=strlen(str);
getch();
OUTPUT:
46
WAP TO FIND OUT THE NUMBER IS
PRIME OR NOT.
#include<stdio.h>
#include<conio.h>
void main()
int n,i;
clrscr();
printf("Enter anumber:");
scanf("%d",&n);
i=2;
while(i<=n/2)
if(n%i==0)
printf("not prime");
goto end;
i++;
printf("prime number");
end:7
getch();
47
OUTPUT:
48