Anda di halaman 1dari 35
Semester- 1st Subject: - Programm ing in C Lab Manual Contents 2 Write a C Program

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual Contents 2 Write a C Program

Contents

  • 2 Write a C Program swa pping of Two Numbers without using 3 rd variable .

3

PAGE NO

NAME OF THE PROGR AM

  • 1 Write a C Program swa pping of Two Number with using Third Variable

SL NO
SL NO
3
3

11

11

8

14

13

13

12

12

!

13

11

10

10

9

9

.......

8

4

Write a C Program inpu t a number, check the no is Armstrong or not.

14

15

Write a C Program inpu t a number, check the no is prime or not.

16

17

Write a C Program inpu t a number, check the no is perfect or not

18

Write a C Program inpu t a number ,check the no is palindrome or not

  • 20 Write a C Program prin t the pattern-1

  • 21 Write a C Program prin t the pattern-2

  • 22 Write a C Program prin t the pattern-3

+x^n/n

x^2/2!+x^4/4!+

  • Write a C Program inpu t a number, find the factorial of given no.
    19 Write a C program Disp lay Floyd Triangle

  • 5 Write a C Program of G rading System

10

9

8

  • 7 Write a C programme f ind the sum of individual digits of a positive inte ger.

  • 6 Write a C Program to fi nd the Roots of Quadratic Equation

12

  • 4 Write a C Program con vert cellceius to ferhenit

  • 3 Write a C Program find the simple interest

Write a C Program to fi nd LCM Write a C Program find prime no between
Write a C Program to fi nd LCM
Write a C Program find prime no between 1 to 100.
Write a C Program Eval uate the Series s=1 -
Write a C program Prin t the Fibonacci Series
Write a C Program cou nt the digits from a Number
Write a C Program Rev erse of a number
11 11 8 14 13 13 12 12 ! 13 11 10 10 9 9 .......
4 5 6 6 7 7
4
5
6
6
7
7
2 Write a C Program swa pping of Two Numbers without using 3 variable . 3
Semester- 1st Subject: - Programm ing in C Lab Manual Contents 2 Write a C Program
Semester- 1st Subject: - Programm ing in C Lab Manual Contents 2 Write a C Program

Prepared By: Asst.Professor. Santosh Kumar Rath

Page 1

Semester- 1st Subject: - Programm ing in C Lab Manual 25 Write a C program Del

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 25 Write a C program Del
  • 25 Write a C program Del ete an element from the array

17

  • 24 Write a C program inse rt an element into the array

  • 23 Write a C program to fi nd the sum of elements from array

24 Write a C program inse rt an element into the array 23 Write a C
16
16
15
15

28

34

33

33

32

32

31

30

29

29

25

28

27

26

of the diagonal elements of the matrix

24

23

22

21

Write a C Program inpu t a string, check the string is palindrome or not

42

  • 46 Write a C Program to d isplay Student detail with address using Nested Structure

  • 45 Write a C program Add ition of two complexes no.

  • 44 Write a C Program disp lay the Student Details using Structure

  • 43 Write a C Program prin t the string pattern

35

Write a C Program to in put a string count the no of alphabets, digits, vowels present in strin g.

41

20

40

39

38

Write a C program reve rse of string without using string function

37

Write a C program find the length of string without using string functio n

36

Write a C program inpu t a number, check the no is Armstrong or not us ing function name ARM.

34

33

32

  • 31 Write a C Program sum

  • 30 Write a C Program Tran spose of Matrix

  • 29 Write a C Program find the large and smallest no form list of integers

  • 28 Write a C program mer ging of two arrays Write a C Program find the sum of individual digits of a positive integer using function name S UM.

  • 27 Write a C Program sort ing the List of integers

19

18

Write a C Program Perf orm Matrix Multiplication Write a C program con vert upper case
Write a C Program Perf orm Matrix Multiplication
Write a C program con vert upper case to lower case
Write a C program con vert lower case to upper case
Write a C Program Con catenation of Two String
Write a C Program Perf orm Addition of two Matrix
28 34 33 33 32 32 31 30 29 29 25 28 27 26 of the
28 34 33 33 32 32 31 30 29 29 25 28 27 26 of the
  • 26 Write a C program sear ch an element from list of integers

25 Write a C program Del ete an element from the array 17 24 Write a
Semester- 1st Subject: - Programm ing in C Lab Manual 25 Write a C program Del
Semester- 1st Subject: - Programm ing in C Lab Manual 25 Write a C program Del

Prepared By: Asst.Professor. Santosh Kumar Rath

Page 2

Semester- 1st Subject: - Programm ing in C Lab Manual 1. Write a C Program s

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 1. Write a C Program s

1.

Write a C Program s wapping of Two Number with using Third Variab le

Program:

#include<stdio.h> #include<conio.h> Void main() { Int a,b,c; Clrscr(); Printf(“\n Enter the value of a a nd b:”); Scanf(“%d%d”,&a,&b); C=a; a=b; b=c; printf(“\n Swapping of two num bers :%d\t%d”,a,b); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 1. Write a C Program s
2.
2.

a=a^b;b=a^b;a=a ^b

Write a C Program s wapping of Two Numbers without using 3 rd varia ble.

Semester- 1st Subject: - Programm ing in C Lab Manual 1. Write a C Program s

Program:

#include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf(“\n enter a nad b”); scanf(“%d%d”,&a,&b); a=a+b; b=a-b;

a=a-b; printf(“\n swapping of two num bers:%d%d”,a,b); getch(); }

(Note: way-2

Way-3 a=a*b; b=a/b; a= a/b;)

Semester- 1st Subject: - Programm ing in C Lab Manual 1. Write a C Program s
Semester- 1st Subject: - Programm ing in C Lab Manual 3. Write a C Program f

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 3. Write a C Program f
  • 3. Write a C Program f ind the simple interest

Program:

#include<stdio.h> #include<conio.h> Void main() { Int p,t,r; Float si; Clrscr(); Printf(“\n Enter p,r and t:”); Scanf(“%d%d%d”,&p,&t,&r);
#include<stdio.h>
#include<conio.h>
Void main()
{
Int p,t,r;
Float si;
Clrscr();
Printf(“\n Enter p,r and t:”);
Scanf(“%d%d%d”,&p,&t,&r);
Si=(p*t*r)/100;
Printf(”Simplet Interst is:%f”,si);
Getch();
}
4.
Write a C Program c onvert celiceus to ferhenit
Program:
#include<stdio.h>
#include<conio.h>
Void main()
{
Int f;
Float c;
Clrscr();
Printf(“\n Enter ferhenit”);
Scanf(“%d”,&f);
C=5/9*(f-32);
Printf(“%f”,c);
Getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 3. Write a C Program f
Semester- 1st Subject: - Programm ing in C Lab Manual 5. Write a C Program i

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 5. Write a C Program i
  • 5. Write a C Program i nput three different subject marks, find total, av g.

If avg>=60 “1st class” If avg>=50 and avg <=59 “2 nd Class” If avg>=40 and avg <=49 ”3 rd Class”

If avg<=39 “Fail”

Program:

#include<stdio.h> #include<conio.h> void main() { int m1,m2,m3,t,avg; clrscr(); printf(“\n enter three marks:”); scanf(“%d%d%d”,&m1,&m2,&m 3);

Semester- 1st Subject: - Programm ing in C Lab Manual 5. Write a C Program i
Semester- 1st Subject: - Programm ing in C Lab Manual 5. Write a C Program i

t=m1+m2+m3;

avg=t/3;

if(avg>=60)

{ printf(“1 st class”); } else if(avg>=50 && avg<=59) { printf(“2 nd class”); } else if(avg>=40 && avg<=49) { printf(“3 rd class”); } else printf(“fail”); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 5. Write a C Program i
Semester- 1st Subject: - Programm ing in C Lab Manual 6. Write a C Program t

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 6. Write a C Program t
  • 6. Write a C Program t o find the Roots of Quadratic Equation

Program:

#include<stdio.h> #include<conio.h> #include<math.h> void main() { int a,b,c,d; float r1,r2; clrscr(); printf("Enter the value of a, b and c:"); scanf("%d%d%d",&a,&b,&c) ;

d=(b*b)-(4*a*c);

if(d>0)

{

r1=(-b+sqrt(d))/(2*a);

r2=(-b-sqrt(d))/(2*a);

Semester- 1st Subject: - Programm ing in C Lab Manual 6. Write a C Program t
7.
7.

printf("\nRoots Are:%f%f",r 1,r2); } else printf("Roots Are Imaginary "); getch(); }

Write a C programm e find the sum of individual digits of a positive i nteger.

Program:

#include<stdio.h> #include<conio.h> void main() { int no,rem,sum=0; clrscr(); printf("\n Enter a No:"); scanf("%d",&no);

while(no>0)

{

rem=no%10;

sum=sum+rem;

no=no/10;

} printf("\nSum of Indivisual Di gits is:%d",sum); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 6. Write a C Program t
Semester- 1st Subject: - Programm ing in C Lab Manual 8. Write a C Program R

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 8. Write a C Program R
  • 8. Write a C Program R everse of a number

Program:

#include<stdio.h> #include<conio.h> void main() { int no,rem,rev=0; clrscr(); printf(“\n enter a number:”); scanf(“%d”,&no);

while(no!=0)

{

rem=no%10;

rev=rev*10+rem;

no=no/10;

} printf(”\n reverse of no is:%d”,r ev); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 8. Write a C Program R
9. Write a C Program c ount the digits from a Number
9.
Write a C Program c ount the digits from a Number

Program:

#include<stdio.h> #include<conio.h> void main() { int no,count=0; clrscr(); printf(“\n enter a number:”); scanf(“%d”,&no);

while(no!=0)

{ count++;

no=no/10;

}

printf(“%d”,count);

getch();

}

Semester- 1st Subject: - Programm ing in C Lab Manual 8. Write a C Program R
Semester- 1st Subject: - Programm ing in C Lab Manual 10. Write a C Program i

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 10. Write a C Program i
  • 10. Write a C Program i nput a number; find the factorial of given no.

Program:

#include<stdio.h> #include<conio.h> void main() { int no,f=1; clrscr(); printf("\nEnter a Number:") ; scanf("%d",&no);

while(no>0)

{ f=f*no; no--; } printf("Factorial of a Numbe r is:%d",f); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 10. Write a C Program i
11. Write a C program P rint the Fibonacci Series
11. Write a C program P rint the Fibonacci Series

Program:

#include<stdio.h> #include<conio.h> void main() { int a=0,b=1,c,n; clrscr(); printf("\n Enter The Range:"); scanf("%d",&n); printf("%d%d",a,b);

while(n>2)

{

c=a+b;

printf("%d",c);

a=b;

b=c;

n--;

}

getch();

}

Semester- 1st Subject: - Programm ing in C Lab Manual 10. Write a C Program i
Semester- 1st Subject: - Programm ing in C Lab Manual 12. Write a C Program i

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 12. Write a C Program i
  • 12. Write a C Program i nput a number ,check the no is palindrome or no t

Program:

#include<stdio.h> #include<conio.h> void main() { int no,rem,rev=o,x; clrscr(); printf(“\n enter a number:”) ; scanf(“%d”,&no); x=no;

while(x>0)

{

rem=x%10;

rev=rev*10+rem;

x=x/10;

} if(no==rev) printf(“no is palindrome”); else printf(“not a palidrome”); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 12. Write a C Program i
13.
13.

Write a C Program i nput a number, check the no is Armstrong or not .

Program:

#include<stdio.h> #include<conio.h> void main() { int no,x,rem,s=0; clrscr(); printf(“\n enter a number:”); scanf(“%d”,&no); x=no;

while(x>0)

{

rem=x%10;

s=s+(rem*rem*rem);

x=x/10;

} if(no==s) printf(“no is armstrong”); else printf(“no”); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 12. Write a C Program i
Semester- 1st Subject: - Programm ing in C Lab Manual 14. Write a C Program t

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 14. Write a C Program t
14. Write a C Program t o find LCM Program: #include<stdio.h> #include<conio.h> Void main() { int
14.
Write a C Program t o find LCM
Program:
#include<stdio.h>
#include<conio.h>
Void main()
{
int n1,n2,x,y;
clrscr();
printf("\nEnter two numbers:") ;
scanf("%d %d",&n1,&n2);
x=n1,y=n2;
while(n1!=n2){
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
printf("L.C.M=%d",x*y/n1);
getch();
}
15.
Write a C Program i nput a number, check the no is prime or not.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,c=0;
clrscr();
printf("enter a number");
scanf("%d",&num);
while(i<=num)
{
if(num%i==0)
i=i+1;

c=c+1;

}

if(c==2)

printf("prime no is %5d",nu m); else printf("not a prime %d",num );

}

getch();

}

Semester- 1st Subject: - Programm ing in C Lab Manual 14. Write a C Program t
Semester- 1st Subject: - Programm ing in C Lab Manual 16. Write a C Program f

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 16. Write a C Program f
  • 16. Write a C Program f ind prime no between 1 to 100.

Program:

#include<stdio.h> #include<conio.h> void main() { int i,num=1; clrscr();

while(num<=100)

{

i=2;

while(i<=num) {

if(num%i==0)

break; i++; } if(i==num) printf("\n%d is Prime",num); num++; } getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 16. Write a C Program f
17.
17.

Write a C Program i nput a number, check the no is perfect or not

Program:

#include<stdio.h> #include<conio.h> main() { int n,i,s; clrscr(); printf("\n enter a number"); scanf("%d",&n);

i=1;

s=0;

while(i<n) {

if(n%i==0)

s=s+i; i++; } if(s==n) printf("%d is Perfect N umber",n); else printf("%d is not Perfe ct Number",n); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 16. Write a C Program f
Semester- 1st Subject: - Programm ing in C Lab Manual 18. Write a C Program E

Semester- 1st Subject: - Programm ing in C Lab Manual

18. Write a C Program E valuate the Series s=1 - x^2/2!+x^4/4!+ ....... +x^ n/n!
18. Write a C Program E valuate the Series s=1 - x^2/2!+x^4/4!+
.......
+x^
n/n!

Program:

#include<stdio.h> #include<conio.h> #include<math.h> void main() { int i,x,n,c=0,f=1; float s=1; clrscr(); printf("Enter the value of x a nd n:"); scanf("%d%d",&x,&n);

for(i=2;i<n;i++)

{ f=f*i;

c=i/2;

Semester- 1st Subject: - Programm ing in C Lab Manual 18. Write a C Program E
19. Write a C program D isplay Floyd Triangle
19. Write a C program D isplay Floyd Triangle

if(c%2==0)

{ s=s+pow(x,i)/f; } else s=s-pow(x,i)/f; } printf("Evaluation is: %f",s); getch(); }

Program:

#include<stdio.h> #include<conio.h> void main() { int i,j,n,k=1; clrscr(); printf("Enter the value of n"); scanf("%d",&n);

for(i=1;i<n;i++)

{

for(j=1;j<=i;j++)

{ printf("%d",k++); } printf("\n"); } getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 18. Write a C Program E
Semester- 1st Subject: - Programm ing in C Lab Manual 20. Write a C Program P

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 20. Write a C Program P

20.

Write a C Program P rint the pattern

*

**

***

****

 

Program:

#include<stdio.h>

#include<conio.h>

void main()

{

int

i, j,n;

clrscr(); printf(“\n enter the limi t:”); scanf(“%d”,&n);

for(i=0;i<n;i++) { for(j=0;j<=i;j++) { printf(“*”); } printf(“\n”); } getch(); } 21. Write a C Program P
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf(“*”);
}
printf(“\n”);
}
getch();
}
21. Write a C Program P rint the pattern
1
12
123
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int
i, j,n;
Semester- 1st Subject: - Programm ing in C Lab Manual 20. Write a C Program P

clrscr(); printf(“\n enter the limi t:”); scanf(“%d”,&n);

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

{

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

{ printf(“%d”,j); } printf(“\n”); } getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 20. Write a C Program P
Semester- 1st Subject: - Programm ing in C Lab Manual 22. Write a C Program P

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 22. Write a C Program P

22. Write a C Program P rint the pattern

1

11

111

1111

111

11

1

Semester- 1st Subject: - Programm ing in C Lab Manual 22. Write a C Program P

Program:

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

int

i, j,n;

clrscr(); printf(“\n enter the limi t:”); scanf(“%d”,&n);

for(i=0;i<n;i++) { for(j=0;j<=i;j++) { printf(“1”); } printf(“\n”); } for(i=n;i>0;i--) { for(j=0;j<=i;j++) { printf(“1”); } printf(“\n”); }
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf(“1”);
}
printf(“\n”);
}
for(i=n;i>0;i--)
{
for(j=0;j<=i;j++)
{
printf(“1”);
}
printf(“\n”);
}
getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 22. Write a C Program P
Semester- 1st Subject: - Programm ing in C Lab Manual 23. Write a C program t

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 23. Write a C program t

23. Write a C program t o find the sum of elements from array.

Program:

#include<stdio.h> #include<conio.h> void main() { int a[20],i,sum=0,n; clrscr(); printf(“\ enter the size of ar ray”); scanf(“%d”,&n); printf(“\n enter the data int o the array:”);

Semester- 1st Subject: - Programm ing in C Lab Manual 23. Write a C program t
for(i=0;i<n;i++) { scanf(“%d”,&a[i]); } for(i=0;i<n;i++) { sum=sum+a[i]; } printf(“%d”,sum); getch(); }
for(i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
}
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
printf(“%d”,sum);
getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 24. Write a C program i

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 24. Write a C program i

24. Write a C program i nsert an element into the array

Program:

#include<stdio.h> #include<conio.h> void main() { int a[10],i,n,pos,item; clrscr(); printf("Enter the size of array:"); scanf("%d",&n); printf("\nEnter Datas in to Array:");

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

{ scanf("%d",&a[i]); } printf("\nEnter the posit ion of element:"); scanf("%d",&pos); printf("\nEnter the item to be inserted:"); scanf("%d",&item);

for(i=pos-1;i<n;i++) { a[i+1]=a[i]; } a[pos-1]=item; printf("\nAfter Insertion of New element:"); for(i=0;i<(n+1);i++) printf("%d\t",a[i]); getch(); }
for(i=pos-1;i<n;i++)
{
a[i+1]=a[i];
}
a[pos-1]=item;
printf("\nAfter Insertion of New element:");
for(i=0;i<(n+1);i++)
printf("%d\t",a[i]);
getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 24. Write a C program i
Semester- 1st Subject: - Programm ing in C Lab Manual 24. Write a C program i
Semester- 1st Subject: - Programm ing in C Lab Manual 25. Write a C program D

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 25. Write a C program D

25. Write a C program D elete an element from the array

Program:

#include<stdio.h> #include<conio.h> void main() { int a[10],i,n,pos; clrscr(); printf("Enter the size of array:"); scanf("%d",&n); printf("\nEnter Datas in to Array:");

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

{ scanf("%d",&a[i]); } printf("\nEnter the posit ion of element:"); scanf("%d",&pos);

for(i=pos-1;i<n;i++) { a[i-1]=a[i]; } printf("\nAfter Deletion of element from array:"); for(i=0;i<(n-1);i++) printf("%d\t",a[i]); getch(); }
for(i=pos-1;i<n;i++)
{
a[i-1]=a[i];
}
printf("\nAfter Deletion of element from array:");
for(i=0;i<(n-1);i++)
printf("%d\t",a[i]);
getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 25. Write a C program D
Semester- 1st Subject: - Programm ing in C Lab Manual 25. Write a C program D
Semester- 1st Subject: - Programm ing in C Lab Manual 26. Write a C program s

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 26. Write a C program s

26. Write a C program s earch an element from list of integers.

Program:

#include<stdio.h> #include<conio.h> void main() { int a[20],i,item,n; clrscr(); printf(“\n enter the size of array:”); scanf(“%d”,&n); printf(“\n enter datas in to array:”);

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

{ scanf(“%d”,&a[i]); }

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

{ if(a[i]==item) { printf(“\n position of ele ment is:%d”,i); break; } } if(i==n) printf(“\n the no is not p resent in the list”); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 26. Write a C program s
Semester- 1st Subject: - Programm ing in C Lab Manual 26. Write a C program s
Semester- 1st Subject: - Programm ing in C Lab Manual 26. Write a C program s
Semester- 1st Subject: - Programm ing in C Lab Manual 27. Write a C Program s

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 27. Write a C Program s

27. Write a C Program s orting the List of integers

Program:

#include<stdio.h> #include<conio.h> void main() { int a[10],i,j,n,temp; clrscr(); printf("Enter the size of array:"); scanf("%d",&n); printf("\nEnter Datas into Array :");

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

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

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

{

Semester- 1st Subject: - Programm ing in C Lab Manual 27. Write a C Program s
Semester- 1st Subject: - Programm ing in C Lab Manual 27. Write a C Program s

for(j=i+1;j<=n;j++)

{ if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } }} printf("\nSorting of Element :");

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

printf("%d\t",a[i]);

getch();

}

Semester- 1st Subject: - Programm ing in C Lab Manual 27. Write a C Program s
Semester- 1st Subject: - Programm ing in C Lab Manual 28. Write a C program merging

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 28. Write a C program merging

28. Write a C program

merging of two arrays.

Program:

#include<stdio.h> #include<conio.h> void main() { int a[10],b[10],i,j,m,n,temp; clrscr(); printf("Enter the size of array:"); scanf("%d\t%d",&m,&n); printf("\nEnter Datas into Array -1:");

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

{ scanf("%d",&a[i]); } printf("\nEnter Datas into Array -2:");

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

Semester- 1st Subject: - Programm ing in C Lab Manual 28. Write a C program merging
Semester- 1st Subject: - Programm ing in C Lab Manual 28. Write a C program merging

{ scanf("%d",&b[j]); } printf("\nMerging of Two Arrays :");

for(i=m,j=0;i<(m+n);i++,j++)

{ a[i]=b[j]; }

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

printf("%d\t",a[i]);

getch();

}

Semester- 1st Subject: - Programm ing in C Lab Manual 28. Write a C program merging
Semester- 1st Subject: - Programm ing in C Lab Manual 29. Write a C Program f

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 29. Write a C Program f

29. Write a C Program f ind the large and smallest no form list of integer s

Program:

#include<stdio.h> #include<conio.h> void main() { int a[10],i,large,small,n; clrscr(); printf("\n Enter the size of an ar ray:"); scanf("%d",&n); printf("\n Enter the Datas into a rray:");

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

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

large=small=a[0];

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

Semester- 1st Subject: - Programm ing in C Lab Manual 29. Write a C Program f
Semester- 1st Subject: - Programm ing in C Lab Manual 29. Write a C Program f

{ if(a[i]>large) { large=a[i]; } if(a[i]<small) { small=a[i]; } } printf("\n Largest No is:%d",larg e); printf("\n Smallest NO is:%d",sm all); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 29. Write a C Program f
Semester- 1st Subject: - Programm ing in C Lab Manual 30. Write a C Program T

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 30. Write a C Program T

30. Write a C Program T ranspose of Matrix

Program:

#include<stdio.h> #include<conio.h> void main() { int a[10][10],i,j; clrscr(); printf(“enter data into the matri x:”); for(i=0;i<2;i++) {
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],i,j;
clrscr();
printf(“enter data into the matri x:”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“\n transpose of matrix is :”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“%d”,a[j][i]);
}
printf(“\n”);
}
getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 30. Write a C Program T
Semester- 1st Subject: - Programm ing in C Lab Manual 31. Write a C Program s

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 31. Write a C Program s

31. Write a C Program s um of the diagonal elements of the matrix

Program:

#include<stdio.h> #include<conio.h> void main() { int a[10][10],i,j,sum=0; clrscr(); printf(“\n enter the data into m atrix:”);

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

{

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

{ scanf(“%d”,&a[i][j]); }

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

{

Semester- 1st Subject: - Programm ing in C Lab Manual 31. Write a C Program s
Semester- 1st Subject: - Programm ing in C Lab Manual 31. Write a C Program s

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

{

if(i==j||(i+j==2))

{ sum=sum+a[i][j]; } } } printf(“\n sum of diagonal matri x is:%d”,sum); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 31. Write a C Program s
Semester- 1st Subject: - Programm ing in C Lab Manual 32. Write a C Program P

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 32. Write a C Program P

32. Write a C Program P erform Addition of two Matrix

Program:

#include<stdio.h> #include<conio.h> void matrix(int[][3],int[][3]); void main() { int a[3][3],b[3][3],i,j; clrscr(); printf("Enter Datas into Array-1: "); for(i=0;i<3;i++)
#include<stdio.h>
#include<conio.h>
void matrix(int[][3],int[][3]);
void main()
{
int a[3][3],b[3][3],i,j;
clrscr();
printf("Enter Datas into Array-1: ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter Datas into Array-2: ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&b[i][j]);
}
}
matrix(a,b);
getch();
}
void matrix(int x[3][3],int y[3][3] )
{
int i,j;
printf("Addition of Matrix is:\n") ;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",x[i][j]+y[i][j]);

}

printf("\n");

}

getch();

}

Semester- 1st Subject: - Programm ing in C Lab Manual 32. Write a C Program P
Semester- 1st Subject: - Programm ing in C Lab Manual 33. Write a C Program P

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 33. Write a C Program P

33. Write a C Program P erform Matrix Multiplication

Program:

#include<stdio.h> #include<conio.h> void mul(int[][2],int[][2]); void main() { int a[2][2],b[2][2],i,j; clrscr(); printf("Enter Datas into Array-1: "); for(i=0;i<2;i++)
#include<stdio.h>
#include<conio.h>
void mul(int[][2],int[][2]);
void main()
{
int a[2][2],b[2][2],i,j;
clrscr();
printf("Enter Datas into Array-1: ");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter Datas into Array-2: ");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&b[i][j]);
}
}
mul(a,b);
getch();
}
void mul(int x[2][2],int y[2][2])
{
int z[2][2],i,j,k;
printf("Multiplication of Matrice s is:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
for(k=0;k<2;k++)

{

z[i][j]=0;

z[i][j]=z[i][j]+(x[i][k]*y[k][j]); }}}

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

{

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

{ printf("%d\t",z[i][j]);}printf("\n") ;}getch();}

Semester- 1st Subject: - Programm ing in C Lab Manual 33. Write a C Program P
Semester- 1st Subject: - Programm ing in C Lab Manual 34. Write a C Program f

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 34. Write a C Program f

34. Write a C Program f ind the sum of individual digits of a positive inte ger using function name SUM.

Program:

#include<stdio.h> #include<conio.h> void sum(int); void main() { int no; clrscr(); printf(“\n enter a numb er:”); scanf(“%d”,&no); sum(no); getch(); } void sum(int x) { int rem,s=0;

while(x>0) { rem=x%10; s=s+rem; x=x/10; } printf(“sumo of digits:% d”,s); getch(); }
while(x>0)
{
rem=x%10;
s=s+rem;
x=x/10;
}
printf(“sumo of digits:% d”,s);
getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 34. Write a C Program f
Semester- 1st Subject: - Programm ing in C Lab Manual 34. Write a C Program f
Semester- 1st Subject: - Programm ing in C Lab Manual 35. Write a C program i

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 35. Write a C program i

35. Write a C program i nput a number, check the no is Armstrong or not name ARM.

using function

Program:

#include<stdio.h> #include<conio.h> int arm(int); void main() { int no,s; clrscr(); printf(“\n enter a numb er:”); scanf(“%d”,&no); s=arm(no); if(s==no) { printf(“armstrong no ”); } else printf(“not”); getch(); } int arm(int x) { int rem,sum=0;

while(x>0) { rem=x%10; sum=sum+rem*rem*re m; x=x/10; } return(sum); }
while(x>0)
{
rem=x%10;
sum=sum+rem*rem*re m;
x=x/10;
}
return(sum);
}
Semester- 1st Subject: - Programm ing in C Lab Manual 35. Write a C program i
Semester- 1st Subject: - Programm ing in C Lab Manual 35. Write a C program i
Semester- 1st Subject: - Programm ing in C Lab Manual 36. Write a C program f

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 36. Write a C program f

36.

Write a C program f ind the length of string without using string func tion

Program:

#include<stdio.h> #include<conio.h> void main() { char a[20]; int len=0,i; clrscr(); printf(“enter a string”); scanf(“%s”,a);

for(i=0;a[i]!=null;i++)

{ len++; } printf(“length of string:%d”, len); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 36. Write a C program f
37. Program: #include<stdio.h> #include<conio.h> void main() { char a[20]; int len=0,i; clrscr(); printf(“\nenter a string: ”);
37.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
char a[20];
int len=0,i;
clrscr();
printf(“\nenter a string: ”);
scanf(“%s”,a);
for(i=0;a[i]!=null;i++)
{
len++;
}
for(i=len-1;i>=0;i--)
{
printf(“%c”,a[i]);
}
getch();
}

Write a C program r everse of string without using string function

Semester- 1st Subject: - Programm ing in C Lab Manual 36. Write a C program f
Semester- 1st Subject: - Programm ing in C Lab Manual 38. Write a C program c

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 38. Write a C program c
  • 38. Write a C program c onvert upper case to lower case

Program:

#include<stdio.h> #include<conio.h> void main() { char a[20]; int i; clrscr(); printf(“\n Enter a string: ”); scanf(“%s”,a);

for(i=0;a[i]!=null;i++)

{

a[i]=a[i]+32;

}

printf(“%s”,a);

getch();

} 39. Write a C program c onvert lower case to upper case Program: #include<stdio.h> #include<conio.h>
}
39. Write a C program c onvert lower case to upper case
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
char a[20];
int i;
clrscr();
printf(“\n Enter a string: ”);
scanf(“%s”,a);
for(i=0;a[i]!=null;i++)
{
a[i]=a[i]-32;
}
printf(“%s”,a);
getch();
Semester- 1st Subject: - Programm ing in C Lab Manual 38. Write a C program c

}

Semester- 1st Subject: - Programm ing in C Lab Manual 38. Write a C program c
Semester- 1st Subject: - Programm ing in C Lab Manual 40. Write a C Program i

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 40. Write a C Program i

40. Write a C Program i nput a string, check the string is palindrome or n ot.

Program:

#include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[20],b[20],i,j,k=0,l=0; clrscr(); printf("\nEnter A String:"); scanf("%s",a); for(i=0;a[i]!=NULL;i++) { l++;
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20],b[20],i,j,k=0,l=0;
clrscr();
printf("\nEnter A String:");
scanf("%s",a);
for(i=0;a[i]!=NULL;i++)
{
l++;
}
for(i=l-1;i>=0;i--)
{
b[k++]=a[i];
b[k]=NULL;
}
if(strcmp(a,b)==0)
{
printf("String Palindrome");
}
else
printf("Not");
getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 40. Write a C Program i
Semester- 1st Subject: - Programm ing in C Lab Manual 41. Write a C Program t

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 41. Write a C Program t

41. Write a C Program t o input a string count the no of alphabets, digits, vowels present in string.

Program:

#include<stdio.h> #include<conio.h> void main() { char a[20]; int alp=0, dig=0, v=0;

clrscr(); printf(“\n enter a string ”); scanf(“%s”,a);

for(i=0;a[i]!=null;i++)

{

if(a[i]>=65 && a[i]<= 90 { alp++; } if(a[i]>=48 && a[i]<=57) { dig++; }

Semester- 1st Subject: - Programm ing in C Lab Manual 41. Write a C Program t
Semester- 1st Subject: - Programm ing in C Lab Manual 41. Write a C Program t

||a[i]>=97 && a[i]<= 122)

Semester- 1st Subject: - Programm ing in C Lab Manual 41. Write a C Program t

if(a[i]==’a’||a[i]==’e’||a [i]==’i’||a[i]==’o’||a[i]==’u’||a[i]==’a’||a[i]==’e’ ||a[i]==’i’||a[i]==’o’ ||a[i]==’u’) { v++; } printf(“%d%d%d”,alp,di g,v); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 41. Write a C Program t
Semester- 1st Subject: - Programm ing in C Lab Manual 42. Write a C Program C

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 42. Write a C Program C
  • 42. Write a C Program C oncatenation of Two String

Program:

#include<stdio.h> #include<conio.h> #include<string.h> void main() { char a[10],b[10]; int l,m,i,j; clrscr(); printf("Enter a String:"); gets(a); printf("Enter
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[10],b[10];
int l,m,i,j;
clrscr();
printf("Enter a String:");
gets(a);
printf("Enter a String:");
gets(b);
l=strlen(a);
m=strlen(b);
printf("\nString Concatenation:" );
for(i=l,j=0;i<=(l+m);i++,j++)
{
a[i]=b[j];
}
puts(a);
getch();
}
43. Write a C program p rint the string pattern
Program:
G
GC
GCE
GCEK
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20];
int len,i,j;
clrscr();
printf("\n Enter a String:"); gets( a);
len=strlen(a);

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

{ for(j=0;j<=i;j++) { printf("%c",a[j] ); }printf("\n"); } getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 42. Write a C Program C
Semester- 1st Subject: - Programm ing in C Lab Manual 44. Write a C Program d

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 44. Write a C Program d
  • 44. Write a C Program d isplay the Student Details using Structure.

Program :

#include<stdio.h> #include<conio.h> void main() { struct student { int roll; char name[20]; int mark; }; struct student s; clrscr(); printf("Enter Roll No:"); scanf("%d",&s.roll); printf("\nEnter Name:"); scanf("%s",s.name); printf("\nEnter Mark:"); scanf("%d",&s.mark); printf("\n Information about Stu dent:"); printf("\nRoll:=%d\n",s.roll); printf("\nName:=%s\n",s.name) ; printf("\nMark:=%d\n",s.mark); getch(); }

Semester- 1st Subject: - Programm ing in C Lab Manual 44. Write a C Program d
45. Write a C program A ddition of two complexes no.
45. Write a C program A ddition of two complexes no.

Program:

#include<stdio.h> #include<conio.h> void main() { struct complex { int a,b,c,d, x,y; }real,img; clrscr(); printf("\nEnter Complex No-1:") ; scanf("%d%d",&real.a,&img.b); printf("\nEnter Complex No-2:") ; scanf("%d%d",&real.c,&img.d); real.x=real.a+real.c; img.y=img.b+img.d; printf("\nAddition of Two COmp lex No Is:");printf("%d+i%d",real.x,img.y);getch( );}

Semester- 1st Subject: - Programm ing in C Lab Manual 44. Write a C Program d
Semester- 1st Subject: - Programm ing in C Lab Manual 46. Write a C Program t

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 46. Write a C Program t

46. Write a C Program t o display Student detail with address using Nest ed Structure

Program:

#include<stdio.h> #include<conio.h> void main() { struct student { int roll; char name[20]; int mark; struct address { char city[20]; char state[20]; int pin; }a; }s; clrscr(); printf("Enter Roll No:"); scanf("%d",&s.roll); printf("\nEnter Name:") ; scanf("%s",s.name); printf("\nEnter Mark:"); scanf("%d",&s.mark); printf("\nEnter City:"); scanf("%s",s.a.city); printf("\nEnter State:");

scanf("%s",s.a.state); printf("\nEnter Pin:"); scanf("%d",&s.a.pin); printf("\nInformation ab out Student:"); printf("\nRoll:=%d\n",s. roll); printf("\nName:=%s\n", s.name); printf("\nMark:=%d\n", s.mark); printf("\nCity:=%s\n",s. a.city);
scanf("%s",s.a.state);
printf("\nEnter Pin:");
scanf("%d",&s.a.pin);
printf("\nInformation ab out Student:");
printf("\nRoll:=%d\n",s. roll);
printf("\nName:=%s\n", s.name);
printf("\nMark:=%d\n", s.mark);
printf("\nCity:=%s\n",s. a.city);
Semester- 1st Subject: - Programm ing in C Lab Manual 46. Write a C Program t

printf("\nState:=%s\n",s

.a.state);

printf("\nPin:=%d\n",s.a .pin);

getch();

}

Semester- 1st Subject: - Programm ing in C Lab Manual 46. Write a C Program t
Semester- 1st Subject: - Programm ing in C Lab Manual 47. Write a C Program t

Semester- 1st Subject: - Programm ing in C Lab Manual

Semester- 1st Subject: - Programm ing in C Lab Manual 47. Write a C Program t

47. Write a C Program t o display 5 Student detail.

Program:

#include<stdio.h> #include<conio.h> void main() { struct student { int roll; float mark;

}s[100];

int i; clrscr(); printf("Enter Details of S tudents:");

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

{ scanf("%d%f",&s[i].roll, &s[i].mark); } printf("\nInformation ab out Student:");

for(i=0;i<5;i++) printf("\nRoll :=%d\n",s [i].roll); printf("\nMark:=%f\n",s [i].mark); getch(); }
for(i=0;i<5;i++)
printf("\nRoll :=%d\n",s [i].roll);
printf("\nMark:=%f\n",s [i].mark);
getch();
}
Semester- 1st Subject: - Programm ing in C Lab Manual 47. Write a C Program t
Semester- 1st Subject: - Programm ing in C Lab Manual 47. Write a C Program t