Вы находитесь на странице: 1из 77

# PRACTICAL ASSIGNMENT – PROGRAMING

IN ‘C’
Program 01.01:-
/* Write a program to interchange value of two variables
without

## Karan Jain B.C.A 1st year 1205 */

#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;

## printf("\na= %d\nb= %d ",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.

## Karan Jain B.C.A.1st year 1205.*/

#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;

",a,b);

getch();

## Enter thw second no 20

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

## karan jain B.C.A 1 1205 */

#include<stdio.h>

#include<conio.h>

main()

float c,f;

clrscr();

## printf("\n Enter the fahrenheit ");

scanf("%f",&f );

c=(5.0/9.0)*(f-32.0);

## printf("\n Temperature in celsius ");

printf("\n%f",c);

getch();

## Enter the fahrenheit 213

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.

## karan jain B.C.A.1 1205 */

# include <iostream>

# include <cmath>

# include <string>

## using namespace std;

double feet;

double inches;

double meters;

double centimeters;

double final;

double conversion();//prototype

## cin >> inches;

output ();

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
double conversion ()

## centimeters = 2.54 * inches;

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();

## the simple interest is 54

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;

## printf("\n Area of the Rectangle=%d",area);

perimeter=2*(l+b);

getch();

## Perimetre of the Rectangle=74

Program05.02:-
/*W.A.P to find the area and perimeter of circle.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
#include<conio.h>

void main()

getch();

## Area of circle is = 452.160004

Program06:-
/* Write a program to calculate the gross salary for any
basic salary entered

## through keyboard where dearness allowance is 15% of

basic salary and house

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
rent is 25% of basic salary .

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

int net_sal,gro_sal,dear_all,ho_rent;

clrscr();

## printf("\n Enter the net salary");

scanf("%d" ,&net_sal);

dear_all=0.14*net_sal;

## printf("\n the dearness alloeance is %d" ,dear_all);

ho_rent=0.25*net_sal;

## printf("\n the house rnnt is %d" ,ho_rent);

gro_sal=net_sal+dear_all+ho_rent;

getch();

## gross salary paid 3475

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’

Program07:-
/* Write a program to find the sum,div,pro,sub,mod of two
no.

## Karan Jain B.C.A 1st year 1205 */

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;

## printf("\n The mod = %d",g);

getch();

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
Enter the first no 65

The sum = 88

The sub = 42

## The pro = 1495

The div = 2

The mod = 19

Program08:-
/* W.A.P to check the no is odd or even.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()

int n ;

clrscr();

## printf("enter a number :");

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.

## Karan Jain B.C.A 1st year 1205 */

#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);

## printf("\nEnter the element ");

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 (-ve) no

There are 1 0 no

Program10:-
/* W.A.P to input the current year and date joining year of
an empolyee if the

3000/-as bonous.

## Karan Jain B.C.A.1 1205.*/

#include<stdio.h>

#include<conio.h>

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()

int cur_yr=2010,dt_of_yr,ser_time;

## printf("The date of year is ");

scanf("%d",&dt_of_yr);

ser_time=cur_yr-dt_of_yr;

## printf("\nthe service time is %d",ser_time);

if(ser_time>3)

printf("\n3000/-as bonus");

else

printf("\nno bonous");

getch();

3000/-as bonus

## the service time is 1

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 &&||.

## Karan Jain B.C.A 1st year 1205.*/

#include<stdio.h>

#include<conio.h>

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()

int year;

if (year%4==0)

else

getch();

## The year is a Leap Year.

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’

Program12:-
/*W.A.P to find the seller made profit or incurred loss. Also
determine how

## Karan Jain B.C.A.1st year 1205.*/

#include<stdio.h>

#include<conio.h>

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()

int cost_price,sell_price,profit_loss;

clrscr();

## printf("Enter the cost price ");

scanf("%d",&cost_price);

## printf("Enter the selling price ");

scanf("%d",&sell_price);

profit_loss=sell_price-cost_price;

## printf("The Profit or loss is %d",profit_loss);

if(profit_loss>0)

## printf("\nProfit earned %d",profit_loss);

else

if(profit_loss<0)

## printf("\nLoss earned %d",profit_loss);

else

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("\nThere is no profit loss earned %d
",profit_loss);

getch();

## There is no profit loss earned 0

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’

Program13:-
/* W.A.P a discount of 10% is offered if the quantity
purchased more than 1000.

## Karan Jain B.C.A.1st year 1205.*/

#include<stdio.h>

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
#include<conio.h>

void main( )

## scanf ( "%f", &bs ) ;

if ( bs < 1500 )

hra = bs * 10 / 100 ;

da = bs * 90 / 100 ;

else

hra = 500 ;

da = bs * 98 / 100 ;

gs = bs + hra + da ;

## printf ( "gross salary = Rs. %f", gs ) ;

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

basic salary.

## If his salary is either equal to or above \$ 1500, then HRA =

\$ 500 and DA = 98% of

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
basic salary. If the employee's salary is input through the
keyboard

## Karan Jain B.C.A 1st year 1205.*/

#include<stdio.h>

#include<conio.h>

void main( )

## scanf ( "%f", &bs ) ;

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

## Karan Jain B.C.A 1st year 1205 */

#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);

## printf("\nEnter the marks in fifth subject ");

scanf("%d",&m5);

per=(m1+m2+m3+m4+m5)/5;

## printf("\nThe precent in marks=%d",per);

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();

## The precent in marks=65

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

not.

## Karan Jain B.C.A.1st year 1205.*/

#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)

## printf ("Driver is insured");

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
else

getch();

## Enter age, sex, marital status:35

Driver is insured

Program17:-
/*W.A.P to determine the character rntered is capital
letter ,lower letter

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()

char charac;

## printf ("Enter the character ");

scanf("%c", &charac);

Letter");

## else if ((charac>=0) && (charac<=47) ||(charac>=58)

&& (charac<=64) ||(charac>=91) && (charac<=96) ||
(charac>=123) && (charac<=127))

## printf("The entered character is a special symbol.

");

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}

getch();

## The entered character is a Capital Letter

Program18:-
/* W.A,P to cnvert decimal to binary number system.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

#include<math.h>

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
void main()

clrscr();

## printf("Enter the number in binary form= ");

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];

## printf("Decimal form =%ld",sum);

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
getch();

## Decimal form =22

Program19:-
/*W.A.P to sum up series 1+1/2+1/3+1/4+--------------
+pow(-1)n*1/n.

## Karan Jain B.C.A 1st year 1205 */

#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();

## printf("Enter the no ");

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.

## Karan Jain B.C.A 1st year 1205 */

#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();

## Enter the Number 123 .The reverse no is 321

Program21:-
/*Write a program to find the factorial value of number

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

## int number, factorial, temp;

clrscr();

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
printf("Enter the number ");

## scanf ("%d", &number);

temp=1;

factorial=1;

while (temp<=number)

factorial=factorial*temp;

temp++;

getch();

## The factorial is=720

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’

Program22:-
/*W.A.P to check a no is armstrong or not.

## Karan Jain B.C.A 1st year 1205 */

#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();

## Enter a number= 2 not armstromg

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’

Program24:-
/*W.A.P program to find the sum of entered digit.

## Karan Jain B.C.A 1st year 1205 */

#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();

## Enter a number=659 Sum of digits of a number=20

Program25:-
/*W.A.P to print prime numbers.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

int i,j,n;

clrscr();

## printf(" Enter the number= ");

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();

## Enter the number= 123

2 3 5 7 11 13 17 19 23

29 31 37 41 43 47 53 59 61 67

## 71 73 79 83 89 97 101 103 107

109

113

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’

Program26:-
/* Write a program to calculate the n tables.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

int i,n,j,r;

clrscr();

## printf("Enter the no ");

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.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

int a=0,b=1,i,n,c;

clrscr();

## printf(" Enter the no= ");

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();

## Enter the no= 12

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.

## Karan Jain B.C.A 1st year 1205 */

#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

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

int i, j, k;

clrscr();

## printf("\n%d %d %d", i, j, k);

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.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

## printf("Enter the index:");

scanf("%d", &index);

result=1;

temp=1;

while(temp<=index)

result = result*num1;

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
temp++;

## printf("%d raised to %d is: %d ", num1, index, result);

getch(); }

Program32:-
/*W.A.P to print all the ASCII values and their equivalent

0 to 255.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

int num;

num = 1;

while(num<=255)

## printf("\nValue:%d = ASCII Character:%c", num,

num);

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!.

## Karan Jain B.C.A 1st year 1205 */

#include<conio.h>

#include<stdio.h>

## float fact (int n);

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.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<string.h>

#define size 26

void main()

char strsrc[size];

char strtmp[size];

clrscr();

## printf("\n Enter String:= "); gets(strsrc);

strcpy(strtmp,strsrc);

strrev(strtmp);

if(strcmp(strsrc,strtmp)==0)

## printf("\n Entered string \"%s\"

ispalindrome",strsrc);

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}

else

## printf("\n Entered string \"%s\" is not

palindrome",strsrc);

getch();

## Entered string "123" is not palindrome

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’

Program35:-
/*W.A.P to check the no is divisible by 3and 7 or not.

## Karan Jain B.C.A 1st year 1205 */

#include<stdio.h>

#include<conio.h>

void main()

int num;

clrscr();

## printf("Enter the no ");

scanf("%d",&num);

if((num%3==0)&&(num%7==0))

else

## printf("\nNumber is not divisible by 3 and 7 ");

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
}

getch();

Enter the no 21

Enter the no 25

## Number is not divisible by 3 and 7]

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("\n3. Odd/ Even");

printf("\n4. Exit");

## scanf ("%d", &choice);

switch (choice)

case 1:

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’
//logic for factorial of a number

break;

case 2:

case 3:

## //logic for odd/even

break;

case 4:

exit();

getch();

Page 1
PRACTICAL ASSIGNMENT – PROGRAMING
IN ‘C’

Program40:-
/* W.A.P to to multiply two matrices.

## Karan Jain B.C.A.1st year 1205.*/

#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();

## printf("Order of matrix A : \n");

scanf("%d",&m,&n);

## printf("Order of matrix B : \n");

scanf("%d",&p,&q);

if(n==p)

## printf("Enter A's element: \n ");

for(i=0;i<m;i++)

for(j=0;j<n;j++)

scanf("%d",&a[i][j]);

## printf("Enter B's elements: \n ");

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.

## Karan JAin B.C.A.1st year 1205.*/

#include<stdio.h>

#include<conio.h>

void main()

int a[20],b[20],i,j,m,n;

clrscr();

## printf("\nOrder of matrix : ");

scanf("%d%d",&m,&n);

## printf("\nEnter the elements : ");

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.

## Karan Jain B.C.A.1st year 1205 */

#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();

## printf("The Order of matrix A=\n ");

scanf("%d%d",&m,&n);

## printf("\nThe Order of natrix B=\n ");

scanf("%d%d",&p,&q);

if(n==p)

## printf("\nEnter A's element=\n ");

for(i=0;i<m;i++)

for(j=0;j<n;j++)

scanf("%d%d",&a[i][j]);

## printf("\nEnter B's element=\n ");

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

## Нижнее меню

### Получите наши бесплатные приложения

Авторское право © 2021 Scribd Inc.