Docsity

C Programming Practical File, Study Guides, Projects, Research of C programming

Partial preview of the text

Download C Programming Practical File and more Study Guides, Projects, Research C programming in PDF only on Docsity!

PRACTICAL FILE

BASED ON

PROBLM SOLVING THROUGH “C”

(BCA-16-106 : LAB BASED ON BCA-16-104)

Submitted to Panjab University Chandigarh for the

partial fulfilment of the award of BCA – 1

st

Semester

SUBMITTED TO: SUBMITTED BY:

Prof. Sarabjeet Kaur Name : Varun Shah

P.G. Dept. of Computer Science College Roll No.: 136

Sign……………… University Roll No…………

ARYA COLLEGE LUDHIANA

INDEX

Sr.No Contents Page No. Remarks

  1. Write Algorithms and Flowcharts for the following-: 1. Find simple interest. 2. Find largest number between 2 numbers. 3. Print GRADE according to percentage. 4. Find Factorial of a given number. 5. Print the Fibonacci series upto N terms

6

  1. (^) Write a program to print “Hello” message. 13
  2. (^) Write a program to find average of 3 numbers initialised in the program itself.

14

  1. Write a program to convert temperature given in ゚F to ゚C.

15

  1. Write a program to interchange the value of 2 variables without using 3rd variable.

16

  1. Write a program to take a character using getch(), getche(), getchar(), and display using putchar().

17

  1. (^) Write a program to take a string using gets(), and display using puts()

18

  1. Write a program to show the working of arithmetic operators

19

  1. Write a program to show the working of logical operators

20

  1. Write a program to show the working of assignment operators

21

  1. Write a program to show the working of Bitwise operators

22

  1. (^) Write a program to show the working of conditional operator

24

  1. Write a program to find whether the given number is even or odd

25

  1. Write a program to find whether entered number is in uppercase, lowercase or a digit

26

  1. Write a program to find largest among 3 numbers

27

  1. Write a program to multiply 2 matrices 52
  2. Write a program to find transport of a matrix 55
  3. Write a program to store and print the address of a variable using the concept of pointers

57

  1. Write a program to take and print 5 names using pointers.

58

  1. Write a program to perform various valid operations on pointers

59

  1. Write a program to illustrate the concept of array of pointers

61

  1. Write a program to illustrate the concept of pointer to an array

62

  1. Write a program to illustrate the concept of pointer to pointer

63

  1. Write a program to add, subtract, multiply and divide 2 numbers using functions

64

  1. Write a program to swap 2 numbers by passing arguments by value

66

  1. (^) Write a program to swap 2 numbers by passing arguments by reference

67

  1. Write a program to calculate factorial of a number using recursion

68

  1. Write a program to copy a string into another 69
  2. Write a program to concatenate a string after another

70

  1. Write a program to find length of a string 71
  2. Write a program to compare 2 strings 72
  3. Write a program to convert a string into uppercase

73

  1. (^) Write a program to convert a string into lowercase

74

  1. Write a user-defined function to copy a string into another

75

  1. Write a user-defined function to concatenate a string after another

76

  1. Write a program to illustrate accessing members of an object of a structure using dot operater

77

  1. Write a program to illustrate accessing members of an object of a structure using arrow operater

78

  1. Write a program to compare structure members 80
  2. (^) Write a program to enter records of a book shop using array of structure

81

  1. Write a program to illustrate the concept of nested structures

83

  1. Write a program to illustrate initialising union members

84

  1. Write a program to allocate memory to an integer using malloc()

85

  1. Write a program to deallocate memory using free()

86

  1. (^) Write a program to write and read the contents of a text file

87

  1. Write a program to write and read the contents of a binary file

88

  1. Write a program to copy contents of one file to another

89

  1. Write a program to append the contents of one file at the end of another file

90

  1. Write a program to write and read records to/from a file using fwrite() and fread()

92

2.Find largest number between 2 numbers.

ALGORITHM:

FLOWCHART:

3.Print GRADE according to percentage.

ALGORITHM:

4.Find Factorial of a given number.

ALGORITHM:

FLOWCHART:

5.Print the Fibonacci series upto N terms.

ALGORITHM:

Ques.2 Write a program to print “Hello”message.

#include<stdio.h>

#include<conio.h>

int main()

/* printf function displays the content that is

* passed between the double quotes.

printf("Hello World");

return 0;

Ques.3 Write a program to find average of 3 numbers

initialised in the program itself.

#include<stdio.h>

#include<conio.h>

int main()

{

float num1, num2, num3;

float sum, avg;

printf("Enter three Numbers: ");

scanf("%f %f %f",&num1, &num2, &num3);

sum = num1 + num2 + num3;

avg = sum / 3;

printf("Entered numbers are: %.2f, %.2f and %.2f\n",num1,

num2, num3);

printf("Sum=%.2f\n", sum);

printf("Average=%.2f\n",avg );

return 0;

}

Ques.5 Write a program to interchange the value of 2

variables without using 3rd variable.

#include<stdio.h>

#include<conio.h>

int main()

{

int a=10, b=20;

printf("Before swap a=%d b=%d",a,b);

a=a+b; //a=30 (10+20)

b=a-b; //b=10 (30-20)

a=a-b; //a=20 (30-10)

printf("\nAfter swap a=%d b=%d",a,b);

return 0;

}

Ques.6 Write a program to take a character using getch(),

getche(), getchar(), and display using putchar().

#include<stdio.h>

#include<conio.h>

int main()

{

char ch;

printf("Enter a character :");

ch=getchar();

printf("\nEntered character is :");

putchar(ch);

return 0;

}

Ques.8-Write a program to show the working of arithmetic

operators.

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,s,p,d,r,div; clrscr(); printf("\nEnter the values of a and b: "); scanf("%d%d",&a,&b); s=a+b; d=a-b; p=a*b; div=a/b; r=a%b; printf("\nAddition = %d",s); printf("\nSubtraction = %d",d); printf("\nMultiplacation = %d",p); printf("\nDivision = %d",div); printf("\nRemainder = %d",r); getch();

}

Ques.9 Write a program to show the working of logical

operators.

#include<stdio.h>

#include<conio.h>

int main()

{

int a = 5, b = 5, c = 10, result; result = (a == b) && (c > b); printf("(a == b) && (c > b) is %d \n", result);

result = (a == b) && (c < b); printf("(a == b) && (c < b) is %d \n", result);

result = (a == b) || (c < b); printf("(a == b) || (c < b) is %d \n", result);

result = (a != b) || (c < b); printf("(a != b) || (c < b) is %d \n", result);

result = !(a != b); printf("!(a != b) is %d \n", result);

result = !(a == b); printf("!(a == b) is %d \n", result); return 0;

}