IN ‘C’
Program 01.01:-
/* Write a program to interchange value of two variables
without
#include<stdio.h>
#include<conio.h>
void main()
int a,b;
clrscr();
scanf("%d",&a );
scanf("%d",&b );
a=a+b;
b=a-b;
a=a-b;
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
getch();
The value of a = 20
The value of b = 40
The value of a = 60
The value of b = 20
The value of a = 40
a= 40
b= 20
Program 01.02:-
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
/* W.A.P to interchange two no with using third variable.
#include<stdio.h>
#include<conio.h>
void main()
int a,b,c;
clrscr();
scanf("%d",&a);
scanf("%d",&b);
c=a;
a=b;
b=c;
getch();
The value of a is 20
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
The value of b is 10
Program 2:-
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
/* Write a program to convert temperature in degree
fahrenheit to degree
#include<stdio.h>
#include<conio.h>
main()
float c,f;
clrscr();
scanf("%f",&f );
c=(5.0/9.0)*(f-32.0);
printf("\n%f",c);
getch();
Temperature in celsius
100.555557
Program3:-
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
/*W.A.P to change in kilometers into
meter,inchies,centimeters,feet.
# include <iostream>
# include <cmath>
# include <string>
double feet;
double inches;
double meters;
double centimeters;
double final;
double conversion();//prototype
output ();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
double conversion ()
return 0;
Program4:-
/*W.A.p to find the simple interest.
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Karan Jain B.C.A 1st year 1205 */
#include<stdio.h>
#include<conio.h>
void main()
int p,t,r,si;
clrscr();
scanf("%d",&p);
scanf("%d",&r);
scanf("%d",&t);
si=(p*t*r)/100;
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program05.01:-
/*W.A.P to find the area and parameter of rectangle. Karan
Jain B.C.A 1st year 1205 */
#include<stdio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
#include<conio.h>
void main()
scanf("%d",&l);
scanf("%d",&b);
area=l*b;
perimeter=2*(l+b);
getch();
Program05.02:-
/*W.A.P to find the area and perimeter of circle.
#include<stdio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
#include<conio.h>
void main()
float radius,perimeter,area;
scanf("%f",&radius);
perimeter=2*3.14*radius;
area=3.14*radius*radius;
getch();
Program06:-
/* Write a program to calculate the gross salary for any
basic salary entered
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
rent is 25% of basic salary .
#include<stdio.h>
#include<conio.h>
void main()
int net_sal,gro_sal,dear_all,ho_rent;
clrscr();
scanf("%d" ,&net_sal);
dear_all=0.14*net_sal;
ho_rent=0.25*net_sal;
gro_sal=net_sal+dear_all+ho_rent;
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program07:-
/* Write a program to find the sum,div,pro,sub,mod of two
no.
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
#include<stdio.h>
#include<conio.h>
void main()
int a,b,c,d,e,f,g;
clrscr();
scanf("%d" ,&a);
scanf("%d" ,&b);
c=a+b;
d=a-b;
e=a*b;
f=a/b;
g=a%b;
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Enter the first no 65
The sum = 88
The sub = 42
The div = 2
The mod = 19
Program08:-
/* W.A.P to check the no is odd or even.
#include<stdio.h>
#include<conio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()
int n ;
clrscr();
scanf("%d",&n);
if(n%2==0)
printf("no is even\n");
else
printf("no. is odd\n");
getch();
enter a number :6
no is even
enter a number :5
no. is odd
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program09:-
/*W.A.P to enter a no and find out that the no is (+ve),(-
ve),0.
#include<stdio.h>
#include<conio.h>
void main()
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
{
int i,a[20],n,countp=0,countn=0,countz=0;
clrscr();
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
if(a[i]>0)
countp++;
else if(a[i]<0)
countn++;
else
countz++;
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}
getch();
Enter the no 3
-2
There are 1 0 no
Program10:-
/* W.A.P to input the current year and date joining year of
an empolyee if the
#include<stdio.h>
#include<conio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()
int cur_yr=2010,dt_of_yr,ser_time;
scanf("%d",&dt_of_yr);
ser_time=cur_yr-dt_of_yr;
if(ser_time>3)
printf("\n3000/-as bonus");
else
printf("\nno bonous");
getch();
3000/-as bonus
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
no bonous
Program11:-
/*W.A.P to determine whether the input year is leap or not
use logical
operator &&||.
#include<stdio.h>
#include<conio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()
int year;
if (year%4==0)
else
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program12:-
/*W.A.P to find the seller made profit or incurred loss. Also
determine how
#include<stdio.h>
#include<conio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()
int cost_price,sell_price,profit_loss;
clrscr();
scanf("%d",&cost_price);
scanf("%d",&sell_price);
profit_loss=sell_price-cost_price;
if(profit_loss>0)
else
if(profit_loss<0)
else
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("\nThere is no profit loss earned %d
",profit_loss);
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program13:-
/* W.A.P a discount of 10% is offered if the quantity
purchased more than 1000.
#include<stdio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
#include<conio.h>
void main( )
if ( bs < 1500 )
hra = bs * 10 / 100 ;
da = bs * 90 / 100 ;
else
hra = 500 ;
da = bs * 98 / 100 ;
gs = bs + hra + da ;
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program14:-
/*Example : In a company an employee is paid as under: If
his basic salary is less than
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
basic salary. If the employee's salary is input through the
keyboard
#include<stdio.h>
#include<conio.h>
void main( )
if ( bs < 1500 )
hra = bs * 10 / 100 ;
da = bs * 90 / 100 ;
else
hra = 500 ;
da = bs * 98 / 100 ;
gs = bs + hra + da ;
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf ( "gross salary = Rs. %f", gs ) ;
Program15:-
/*W.A.P to calculate the grade of students according to
marks obetained in 5
subjects:-
a) % above or = 60 first
b) % between 50 to 59 second
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
c) % between 40 to 49 third
#include<stdio.h>
#include<conio.h>
void main()
int m1,m2,m3,m4,m5,per;
clrscr();
scanf("%d",&m1);
scanf("%d",&m2);
scanf("%d",&m3);
scanf("%d",&m4);
scanf("%d",&m5);
per=(m1+m2+m3+m4+m5)/5;
if(per>=60)
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("\nfirst division");
else
if(per>=50<=60)
printf("\nsecond division");
else
if(per>=40<=50)
printf("\nthird division");
else
printf("\nfail");
getch();
first division
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program16:-
/*Write a program is to determine whether an employee is
male and unmerried above 30 years
#include<stdio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
#include<conio.h>
main()
char sex,ms;
int age;
if (ms=='M')
else
if (sex=='M')
if (age>30)
else
else
if (age>25)
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
else
getch();
Driver is insured
Program17:-
/*W.A.P to determine the character rntered is capital
letter ,lower letter
#include<stdio.h>
#include<conio.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()
char charac;
scanf("%c", &charac);
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}
getch();
Program18:-
/* W.A,P to cnvert decimal to binary number system.
#include<stdio.h>
#include<conio.h>
#include<math.h>
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()
clrscr();
scanf("%ld",&n);
for (i=0;n>=1;i++)
a[i]=n%10;
n=n/10;
count=count + 1;
for (i=0;i<=count-1;i++)
b[i]=pow(2,i);
for (i=0;i<=count-1;i++)
c[i]=a[i] * b[i];
sum=sum +c[i];
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
getch();
Program19:-
/*W.A.P to sum up series 1+1/2+1/3+1/4+--------------
+pow(-1)n*1/n.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
{
int n,i,count;
float sum;
clrscr();
scanf("%d",&n);
i=1;
count=1;
sum=0.0;
while(count<=n)
sum+=(float)pow(-1,count-1)/i;
i++;
count++;
printf("\n%f",sum);
getch();
Enter the no 21
0.716390
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program20:-
/*W.A.P to Reverse of the Number.
#include<stdio.h>
#include<conio.h>
void main()
int a,b,c,d,e;
clrscr();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("Enter the Number ");
scanf("%d",&a);
while(a!=0)
b=a%10;
c=a/10;
printf("%d",b);
a=c;
getch();
Program21:-
/*Write a program to find the factorial value of number
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("Enter the number ");
temp=1;
factorial=1;
while (temp<=number)
factorial=factorial*temp;
temp++;
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program22:-
/*W.A.P to check a no is armstrong or not.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
int n,sum=0,rem=0,cube=0,n1,i;
clrscr();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("Enter a number= ");
scanf("%d",&n);
n1=n;
while(n!=0)
rem=n%10;
cube=pow(rem,3);
sum=sum+cube;
n=n/10;
if(sum==n1)
printf("\n\tangstrom");
else
printf("\n\tnot armstromg");
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program24:-
/*W.A.P program to find the sum of entered digit.
#include<stdio.h>
#include<conio.h>
void main()
int n,num,x,sum=0;
clrscr();
printf("Enter a number=");
scanf("%d",&n);
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
while(n>0)
x=n%10;
sum=sum+x;
n=n/10;
getch();
Program25:-
/*W.A.P to print prime numbers.
#include<stdio.h>
#include<conio.h>
void main()
int i,j,n;
clrscr();
scanf("%d",&n);
printf("\n");
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
for(i=2;i<=n;i++)
for(j=2;j<=i-1;j++)
if(i%j==0)
break;
if(i==j)
printf("\t%d",i);
getch();
2 3 5 7 11 13 17 19 23
29 31 37 41 43 47 53 59 61 67
113
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program26:-
/* Write a program to calculate the n tables.
#include<stdio.h>
#include<conio.h>
void main()
int i,n,j,r;
clrscr();
scanf("%d",&n);
for (i=1;i<=n;i++)
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("\n The table of %d is " ,i);
for (j=1;j<=10;j++)
r=i*j;
printf(" \n%d*%d=%d",i,j,r);
getch();
Enter the no 4
The table of 1 is
1*1=1
1*2=2
1*3=3
1*4=4
1*5=5
1*6=6
1*7=7
1*8=8
1*9=9
1*10=10
The table of 2 is
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20
The table of 3 is
3*1=3
3*2=6
3*3=9
3*4=12
3*5=15
3*6=18
3*7=21
3*8=24
3*9=27
3*10=30
The table of 4 is
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
4*1=4
4*2=8
4*3=12
4*4=16
4*5=20
4*6=24
4*7=28
4*8=32
4*9=36
4*10=40
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program27:-
/* Write a program to print the fibbonoci series.
#include<stdio.h>
#include<conio.h>
void main()
int a=0,b=1,i,n,c;
clrscr();
scanf("\n%d" ,&n);
for (i=0;i<n;i++)
c=a+b;
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("\t%d" ,c);
a=b;
b=c;
getch();
1 2 3 5 8 13 21 34 55
89 144 233
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program28:-
/*W.A.P to print the prime no from 1-100.
#include<stdio.h>
#include<conio.h>
void main()
int i,number=1;
clrscr();
while(number<=100)
i=2;
while(i<=number)
if(number%i==0)
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
break;
i++;
if(i==number)
printf("\n%d is Prime",number);
number++;
getch();
2 is Prime
3 is Prime
5 is Prime
7 is Prime
11 is Prime
13 is Prime
17 is Prime
19 is Prime
23 is Prime
29 is Prime
31 is Prime
37 is Prime
41 is Prime
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
43 is Prime
47 is Prime
53 is Prime
59 is Prime
61 is Prime
67 is Prime
71 is Prime
73 is Prime
79 is Prime
83 is Prime
89 is Prime
97 is Prime
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program30:-
/*W.A.P to combinations of 1, 2, 3 using for loop
#include<stdio.h>
#include<conio.h>
void main()
int i, j, k;
clrscr();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}
getch();
111
112
113
121
122
123
131
132
133
211
212
213
221
222
223
231
232
233
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
311
312
313
321
322
323
331
332
333
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program31:-
/*W.A.P tofind the value of one number raised to the
power of another.
#include<stdio.h>
#include<conio.h>
void main()
scanf("%d", &index);
result=1;
temp=1;
while(temp<=index)
result = result*num1;
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
temp++;
getch(); }
Program32:-
/*W.A.P to print all the ASCII values and their equivalent
#include<stdio.h>
#include<conio.h>
void main()
int num;
num = 1;
while(num<=255)
num++;
printf("\n\nEND\n");
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
getch();
Program33:-
/*W.A.P to add first sevan terms of the following series
using for loop
1/1!+2/2!+3/3!+4/4!+5/5!+6/6!+7/7!.
#include<conio.h>
#include<stdio.h>
void main()
int i,n=7;
float s=0;
clrscr();
scanf("%d",&n);
for(i=1;i<=n;i++)
s+=(i/fact(i));
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("\n\tSum= %f",s);
getch();
float fact(int x)
if(x<=7)
return(1);
else
return(x*fact(x-1));
Sum= 28.000000
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program34:-
/*W.A.P to check whether the string is palindrome or not.
#include<stdio.h>
#include<string.h>
#define size 26
void main()
char strsrc[size];
char strtmp[size];
clrscr();
strcpy(strtmp,strsrc);
strrev(strtmp);
if(strcmp(strsrc,strtmp)==0)
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}
else
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program35:-
/*W.A.P to check the no is divisible by 3and 7 or not.
#include<stdio.h>
#include<conio.h>
void main()
int num;
clrscr();
scanf("%d",&num);
if((num%3==0)&&(num%7==0))
else
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}
getch();
Enter the no 21
Enter the no 25
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program36:-
/*W.A.driven program of factorial values, prime or not,odd
or even,exit.*/
#include<stdio.h>
#include<conio.h>
void main()
int choice;
clrscr();
while (1)
printf("\n1. Factorial");
printf("\n2. Prime");
printf("\n4. Exit");
switch (choice)
case 1:
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
//logic for factorial of a number
break;
case 2:
case 3:
break;
case 4:
exit();
getch();
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program40:-
/* W.A.P to to multiply two matrices.
#include<stdio.h>
#include<conio.h>
void main()
int a[10][10],b[10][10],c[10][10],m,n,p,q,i,j,x;
clrscr();
scanf("%d",&m,&n);
scanf("%d",&p,&q);
if(n==p)
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
for(i=0;i<p;i++)
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
for(j=0;j<q;j++)
scanf("%d",&b[i][j]);
for(i=0;i<m;i++)
for(j=0;j<q;j++)
c[i][j]=0;
for(x=0;x<p;x++)
c[i][j]=c[i][j]+(a[i][x]*b[x][j]);
for(i=0;i<m;i++)
for(j=0;j<q;j++)
printf(" %d ",c[i][j]);
printf(" ");
printf("\n");
getch(); }
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Program41:-
/* W.A.P to find transpose of a matrix.
#include<stdio.h>
#include<conio.h>
void main()
int a[20],b[20],i,j,m,n;
clrscr();
scanf("%d%d",&m,&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=0;j<n;j++)
b[j][i]=a[i][j]);
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("\nTransepose is \n ");
for(i=0;i<n;i++)
for(j=0;j<m;j++)
printf("%d",b[i][j]);
printf(" ");
printf("\n");
getch();
Program42:-
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
/* WAP to calculate product of two matrices.
#include<stdio.h>
#include<conio.h>
void main()
int a[10][10],b[10][10],c[10][10],m,n,p,q,i,j,k;
clrscr();
scanf("%d%d",&m,&n);
scanf("%d%d",&p,&q);
if(n==p)
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d%d",&a[i][j]);
for(i=0;i<p;i++)
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
for(j=0;j<q;j++)
scanf("%d%d",&b[i][j]);
for(i=0;i<m;i++)
for(j=0;j<q;j++)
c[i][j]=0;
for(k=0;k<n;k++)
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");
Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}
getch();
Page 1