C Language
January 30, 2017 | Author: Sonu Pal | Category: N/A
Short Description
Download C Language...
Description
Practical file On C language
Submitted to:
Submitted by:
Mrs. Pooja
Gaurav BCA I Roll no.
1
Index: Sr. no. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29.
Program name
Page no. Signature
Program to find the sum of two numbers Program to check whether given no. is odd/even Program to find the greatest of three numbers Program to find the percentage of marks obtained Program to find the roots of quadratic equation Program to add, subtract, multiply, divide two numbers using switch Program to find the average of n numbers using while loop Program to find the factorial using while loop Program to print Fibonacci series using do while loop Program to print palindrome number using do while loop Program to print 1,2,3...ānā using for loop Program to print asterisk (*) using for loop Program to calculate factorial using function Program to print the Fibonacci series using recursion Program to find the greatest of three numbers using function Program to search a given number from the given list using linear search Program to search a given number from the given list using binary search Program to sort a given list of numbers using bubble sort Program to find the sum of two matrices Program to find the product of two matrices Program for swapping numbers using pointer Program to find the average of n numbers using arrays Program to demonstrate use of address of operator (&) and indirection operator (*) for different purposes Program to demonstrate array elements are stored in contiguous memory location Program to sort the elements of an array using pointer Program to interchange value of two numbers using call by reference Program to show operators work in case of pointers Program to show how strings are initialized Program to copy a string to another using library function strcpy()
4 6 8 10 12 14
2
16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60
30. 31. 32. 33. 34.
Program to reverse a given string without using library function Program to concatenate two strings without using library function Program to sort the characters of string alphabetically Program to access the member of structure in which we have pointer to a structure Program to calculate marks obtained by 10 students in different subjects
3
62 64 66 68 69
1. /* TITLE:Sum Of Two Numbers */ #include #include void main() { int a,b,sum; clrscr(); printf("\n Enter The Value Of a:"); scanf("%d",&a); printf("\n Enter The Value of b:"); scanf("%d",&b); sum=a+b; printf("\n Sum of two numbers is:%d",sum); getch(); }
4
Output
5
2. /* TITLE:To check whether given number is odd/even */ #include #include void main() { int n,c; clrscr(); printf("\n Enter a number:"); scanf("%d",&n); c=n%2; if (c==0) printf("\n Number is EVEN"); else printf("\n Number is ODD"); getch(); }
6
Output
7
3. /* TITLE:Greatest Of Three numbers */ #include #include void main() { int a,b,c; clrscr(); printf("\n Enter the value of a:"); scanf("%d",&a); printf("\n Enter the value of b:"); scanf("%d",&b); printf("\n Enter the value of c:"); scanf("%d",&c); if(a>b) { if(a>c) printf("\n %d is greatest i.e. a",a); else printf("\n %d is greatest i.e. c",c); } else { if(b>c) printf("\n %d is greatest i.e. b",b); else printf("\n %d is greatest i.e. c",c); } getch(); }
8
Output
9
4. /* TITLE:Percentage of marks obtained */ #include #include void main() { int a,b,c,d,e,f,sum; float per; clrscr(); printf("\n Enter marks in COM:"); scanf("%d",&a); printf("\n Enter marks in PBI:"); scanf("%d",&b); printf("\n Enter marks in PCS:"); scanf("%d",&c); printf("\n Enter marks in MATHS:"); scanf("%d",&d); printf("\n Enter marks in ENG:"); scanf("%d",&e); printf("\n Enter marks in C:"); scanf("%d",&f); sum=(a+b+c+d+e+f); printf("\n Total Marks=%d\n",sum); per=(a+b+c+d+e+f)/6; printf("\n Percentage= %f\n",per); if(per>=90) printf("\n Grade A"); else if(per>=80) printf("\n Grade B"); else if(per>=70) printf("\n Grade C"); else if(per>=60) printf("\n Grade D"); else printf("\n Grade E"); getch(); }
10
Output
11
5. /* TITLE:Roots Of Quadratic equation */ #include #include #include void main() { int a,b,c; float x1,x2,d; clrscr(); printf("\n Enter value of a:"); scanf("%d",&a); printf("\n Enter value of b:"); scanf("%d",&b); printf("\n Enter value of c:"); scanf("%d",&c); d=(b*b)-(4*a*c); if(d==0) { x1=x2=(-b)/(2*a); printf("\n Roots are equal \n\n x1= %f \n\n x2= %f",x1,x2); } if(d0) { x1=((-b)+sqrt(d))/(2*a); x2=((-b)-sqrt(d))/(2*a); printf("\n Roots are "); printf("\n\n x1=%f",x1); printf("\n\n x2=%f",x2); } getch(); }
12
Output
13
6. /* TITLE:To add, subtract, multiply, divide two numbers using switch */
#include #include void main() { int a,b,choice,c; clrscr(); printf("\n Enter two numbers:"); scanf("%d%d",&a,&b); printf("\n 1. Addition"); printf("\n 2. Subtraction"); printf("\n 3. Multiplication"); printf("\n 4. Division"); printf("\n\n Enter your choice:"); scanf("%d",&choice); { switch(choice) { case 1:c=a+b; printf("\n Sum is %d",c); break; case 2:c=a-b; printf("\n Difference is %d",c); break; case 3:c=a*b; printf("\n Mulitplication is %d",c); break; case 4:c=a/b; printf("\n Quotient is %d",c); } } getch(); }
14
Output
15
7. /* TITLE: Average of n no's using while loop */
#include #include void main() { int n,i=1; float sum=0,avg,x; clrscr(); printf("\n Enter the value of n:"); scanf("%d",&n); while(i
View more...
Comments