A
Practical File
of
Introduction to Programming Language Using C
‘Submitted To : Submitted By :
Dr. Neetu Anand ‘Name : Akshat Manchanda
Enrollment No : 00914902020
EM-—I: BCA -I Shift
MAHARAJA SURAJMAL INSTITUTEDdinexun ff
‘SrNo. | Objective [ Signature
1. [A characteris enlered through Keyboard, WAP to determine whether the character is
entered capital, small, digit or special character.
2__[ WAP to find the largest of 3 nos, using conditional operators
3._[ WAP to check whether a entered year is leap year or no
4 [ WAP 10 calculate the Armstrong nos, bw 1 and 500,
3._[WAP to determine ifa no is prime of not
6. | WAP to find diameter, circumference and area oFa circle using Tunctions
7. 5
WAP to find max and min element of array
8. [Alive digit no. is taken input from user, write a program to reverse hat number and find
sum of the digit ofits digit too
9, | WAP to print the following patter,
“ “1 “55555. “A
” 12 4446 AB
” 123 333 ABC
seve 13422 ABCD
werews 19345" ABCDE”
10, | PROG. TO PRINT SUM OF THE SERIES-“I-1201/3-1/4,_...n" terms,
1, | PROG. TO FIND THE SUM OF SERIES-"X-X°9/3}1X°S/S1-X“T/TH#X99L a “ems
12, WAP to do Linear Search, Binary search, Bubble Sort, Seleotion Sort using menu driven,
program by using functions
TS WAP to printable of any no- entered by the user
14, | Wap io check whether the input characteris a vowel or not using switch case
15. | WAP to inser and delete an element to and from array at specified position
16, | WAP to print fist 20 nos. of fibonacci series
17_| WAP to find the sum and product of 2 matrix using Tunction( user defined)
18, | WAP to find the LCM and GCF of 2 entered numbers
19,| WAP 10 swap 2 names using aay of pointers
20. [ WAP to check if'a given word is a palindrome or nol
21, | WAP 1o find a no of words ina string
22, | WAP to reverse a string, concatenate two strings, length of @ Nring, copy one sling to other
using a user defined function and menu driven program,
73, | Ina company an employee is paid as under:
If is basi salary is less than Rs. 1500, then HRA = 10% of basie salary and DA = 90% of
basic salary If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA
98% of basie salary.
24, | WAP to find the sum ofthe elements of array using pointers
25. [WAP to check whether a given number is perfect number or not
26, [ WAP to calculate factorial of a number using recursion
27. [Write a program in C to swap elements using call by reference238
‘Write a program in C to store n elements in an array and print the elements using pointer
29. | Write a program in C to find the largest element in an array using Dynamic Memory
Allocation(malloc() and free() functions).
30.[ Write a program in C to print a string in reverse using a pointer.
31. | Write a program in C to count the number of vowels and consonants in a string using a
pointer.
32, | WAP to read and print employee details ike Employee ID, EName, salary using structures
33. | Create a structure item (char item name{10] int ay. float pricefloat total amt) . Enter
details regarding items. Create a pointer variable *pitem of a structure item and access the
clements or members of a structure using pointer variable by using -> operator.
34, | Create a structure student (charname[10},int marks(3],int total and float percentage). Enter
the marks of 5 students in 3 subjects and calculate the percentage (Hint-Use the concept of
array of structure)
35, | Create a structure Distance (int feet and float inch). Take two distances as input from wser
and add them (inch and feet separately). Display total distance in feets and inches.
36, | Create a union union Data {_ int i,float fichar st[20]}, WAP to show how to access and
print members of union and also print the maximum memory occupied by union members
37. | WAP to add two numbers with the help of command line arguments
38, | Write a program in C to create and store information in a text file(asing fprintf and fscant
functions)
39, | Write a program in C to create and store information in a binary file(using fread and fwrite
functions)
40, | Write a program in Cto create and store information in a data file(using gete and pute
functions)
41, | Write a program in C10 ereate and store information in a data file(using fgets and fputs
functions)ra)
Write a program in Cfo create and store information in a data fle(using getw and putw
functions)
B
WAP in C to show the fimetionality of fSeek function.
Write @ program in C to count a number of words and characters ina file.
a5.
Waite a program in C to merge two files and write tin a new file
6,
WAP in Co show the functionality of Rell Q/and rewind) functions of file handling,
a
WAP in C that takes the file name as an input from user, create a file “data” to store integer
‘numbers from | to 10. Create two more files “even” and “odd” , read the contents of
“data” and check whether the number is even and odd and copied the same in to“ even”
and “odd’ file
a
WAP in C to show the use of alloc() function
#
WAP TO SHOW THE USE OF FOLLOWING DIRE
INC
TIVES #IF, FELSE AND #ENDIF
30.
WAP TO SHOW THE USE OF STRINGIZE (#) AND TOKEN PASTING (##)
OPERATOR INC.1.A character is entered through keyboard, WAP to determine whether the character is
entered capital, small, digit or special character.
OUTPUT
1)Enter a Character
A
Ais an Uppercase Alphabet
2)Enter @ Character
bh
his an lowercase Alphabet
3)Enter a Character
2
2 is a Number
4)Enter a Character
@ is a Special Character
2.WAP to find the largest of 3 nos. using conditional operators.
Sea:OUTPUT
Enter three different numbers: $ 67
7.00 is the largest number,
3.WAP to check whether a entered year is leap year or not.
OUTPUT
Enter a year: 1996
1996 is a leap year.
4.WAP to calculate the Armstrong nos. b/w 1 and 500.
coe
OUTPUT
Lis a Armstrong number
3 is a Armstrong number
370 is a Armstrong number
371 is a Armstrong number
407 is a Armstrong number
5.WAP to determine if a no. is prime or not.1)Enter a positive integer: 3
39 is not a prime number.
2)Enter a positive integer: 29
29 isa prime number.
6.WAP to find diameter, circumference and area of a circle using functions
Erect
Pewee)
eee eens
find Diameter (
arc f
OUTPUT
Please Enter the radius of a cele : 77.WAP to find max and min element of array
OUTPUT
Enter elements in the array: 23
31
24
54
65
132
17
5
420
786
132
Ml
‘Maximum clement
Minimum element =
8. A five digit no. is taken input from user, write a program to reverse that number and
find sum of the digit of its digit too.OUTPUT
Enter a five-digit number: 23456
Reverse of no, is 65432
Sum of the digits of 23456 is: 20
9.WAP to print the following patterns.
oe “4 “55555. “A
* 12 4444 AB
ae 123 333 ABC
eee 1234 22 ABCD
seas 12345” y ‘ABCDE”
OUTPUT
Enter number of rows = 5OUTPUT
Enter number of rows=
1
2
123
1234
12345
OUTPUT
Enter number of rows= §
55555
4444
fOUTPUT
Enter number of rows= 5
A
AB
ABC
‘ABCD
ABCDE
10.PROG. TO PRIN
SUM OF THE SERIES-“1-1/2+1/3-1/4..
OUTPUT
Enter the number of terms to print series 1 - 1/24 1/3 - 1/44 1/5 .. Un terms: 5
V1-12+ 13-445
Sum of Series upto 5 terms : 0.783333,
11.PROG. TO FIND THE SUM OF SERIES-“X-X‘3/3!+X‘*5/5!-X“7/7!+X‘9/91....0
“terms.OUTPUT
Input the value of x :2
Input number of terms : 5
‘The values of the series:
2
8
32
-128
512
‘The sum = 410
12.WAP to do Linear Search, Binary search, Bubble Sort, Selection Sort using menu
driven program by using functions.
SORT emETeS TESOUTPUT
Enter no, of elements u want to sort : $
Enter 1 Element : 13,
Enter 2 Element : 4
Enter 3 Element : 16
Enter 4 Element :3
Enter $ Element : 21
Please select any option Given Below for Sorting
1. Bubble Sort
2. Selection Sort
3. Insertion Sort
4, Display Array.
5. Exit the Program.
Enter your Choice : 4
13.416 3 21
1. Bubble Sort
2. Selection Sort
3. Insertion Sort
4. Display Array,
5. Exit the Program.
Enter your Choice : 1
‘After Bubble sort Elements are: 3 4 13 16 21
Bubble Sort
Selection Sort
insertion Sort
Display Array.
Exit the Program,
1
4,
Enter your Choice : 2
‘After Selection sort Elements are: 34 13 16 21
1. Bubble Sort
2. Selection Sort
3. Insertion Sort
4, Display Array,
5. Exit the Program.
Enter your Choice : 3
‘After Insertion sort Elements are; 3 4 13 16 21
1. Bubble Sort
2. Selection Sort
3. Insertion Sort,
4, Display Array.
5. Exit the Program,
Enter your Choice : 513.WAP to print table of any no, entered by the user.
OUTPUT
Enter an integer: 4
4e1=4
49228
4e3=12
494-16
4*5=20
4°6=24
497-28
498232
499=36
4° 10-40
14.Wap to check whether the input character is a vowel or not using switch case.
ears
Sorted gDOUTPUT
1)Enter any alphabet:
Vowel
2)Enter any alphabet: £
‘Consonant
15.WAP to insert and delete an element to and from array at specified position
OUTPUT
Delete an element at desired position from an array
Input the size of array : 8
Input 8 elements in the array in ascending order
clement -0: 4
clement - 1:12
element -2: 16
clement -3 :32
clement -4: 40
element - 5: 56
clement - 6:72
clement -7: 108
Input the position where to delete: 4
‘The new listis: 4 12 16 40 56 72 10816.WAP to print first 20 nos. of fibonacci seric
ain()
Panett
OUTPUT
Fibonacci + 610, 9
17.WAP to find the sum and product of 2 matrix using function( user defined)\
Stent Sa
Seta
peers cere era see eee
estisauas
esc esteae
Stuiee
malt (i) (3)
i- 1
i
OUTPUT
Enter rows and column for first matrix: 3 3
Enter rows and column for second matrix: 3 3
Enter elements of matrix 1
Enter elements al: 1
Enter elements a12: 2
Enter elements a13: 3
Enter elements a21: 2
Enter elements a22: 3
Enter elements a23: 4
Enter elements a3]: 3
Enter elements 032: 4
Enter elements a33: 5
Enter elements of matrix 2:
Enter elements 611: 5
Enter elements 612:
Enter elements b13:
Enter elements 62
Enter elements 622:
Enter elements b23:
Enter elements 631
Enter elements 32:Enter elements b33: 1
‘Output Matrix
22 16 10
34.25 16
46 34:22
18.WAP to find the LCM and GCF of 2 entered numbers.
OUTPUT
Enter two integers
48296
Greatest common divisor of 48 and 296 = &
Least common multiple of 48 and 296 = 1776
20.WAP to check if a given word is a palindrome or not.OUTPUT
1)Enter a string:Akshat
‘Akshat is not a palindrome
2)Enter a string: ATGTA,
ATGTA is a palindrome
21.WAP to find a no of words in a string.
sued
OUTPUT
Enter the string:
‘Akshat is awesome and he is the best guy.
‘Number of words in given string are: 9
22.WAP to reverse a string, concatenate two strings, length of a string, copy one string to
other using a user defined function and menu driven program,
emer eerie
Seen areaOUTPUT
1)Enter any option
1: Find out length of the string
2: Concatenate of the two string
3: Reverse of the string
4: Copy of the string
Enter the choices]
Enter any string
Awesome?
‘The length of the string &
2)Enter any option
1: Find out length of the string
2: Coneatenate of the two string,
3: Reverse of the string,
4: Copy of the string
Enter the choice:2
String Concatenation
Enter the First string:
ATGEnter Second string GTA,
The Concatenated string is ATGGTA
3)Enter any option
1: Find out length of the string
2: Concatenate of the two string
3: Reverse of the string
4: Copy of the string
Enter the choice:3
Reverse the string
Enter the string Eggis
sigeE.
4)Enter any option
1: Find out length of the string
2: Coneatenate of the two string,
3: Reverse of the string,
4: Copy of the string
Enter the choice:4
String copying
Enter Ist string :Awesome
Enter 2st string ‘Hero
Hero
23.In a company an employee is paid as under:
If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA = 90% of
basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA
= 98% of basic salary.
OUTPUT
1)Enter basic salary:1000
You Entered Basic Salary ~ 1000.00HRA = 100,00
DA= 900.00
Gross salary = Rs. 2000.00
2)Enter basic salary:3000
‘You Entered Basic Salary ~ 3000.00
HRA = 500,00
DA = 2940.00
oss salary = Rs. 6440,00
24.WAP to find the sum of the elements of array using pointers
OUTPUT
Sum of array elements is:28
25.WAP to check whether a given number is perfect number or not.
OUTPUT
1)Enter a number : 153
153 is not a Perfect Number2)Enter a number : 6
6 is not a Perfect Number
26.WAP to calculate factorial of a number using recursion.
reer
multiplyNumber
OUTPUT
Enter a positive integer: 7
Factorial of 7 = 5040
27.Write a program in C to swap elements using call by reference.
OUTPUT
Enter a, b and c respectively: 4 8 12
Value before swapping:
a4
b=8en 12
‘Value after swapping:
a=12
bea
ok
28.Write a program in C to store n elements in an array and print the elements using
pointer.
OUTPUT
Enter the number of elements(<=30): 10
Enter clements: 2.6 10 12 16 22 28 34 4050
‘You entered:
6
10
12
16
2
28
34
40
50
29.Write a program in C to find the largest element in an array using Dynamic Memory
Allocation(malloc() and free() functions).OUTPUT
Enter the total number of elements: 8
Enter numberl: -12.4
Enter number2: -8.7
Enter number3: 9.2
Enter number: Enter numberS: -9.2
Enter number6: 17.5
Enter number: 23.9
Enter number8: 4.1
Largest number = 23,90
30.Write a program in C to print a string in reverse using a pointer.
OUTPUT
ENTER A STRING: Captain Awesome
THE REVERSE OF THE STRING IS: emosewA niatpaC
31.Write a program in C to count the number of vowels and consonants in a string using
a pointer.OUTPUT
Enter any string: User: Akshat
Number of Vowels in String: 4
Number of Consonants in String: 7
32.WAP to read and print employee details like Employee ID, EName, salary using
structures
OUTPUT
Enter details
Name ?:Akshat
17-4021
Salary ?:800000
Entered detail is:Name: Akshat Id: 4021 Salary: 800000,00000033.Create a structure item (char item_name[10],int qty,float price,float total_amt) . Enter
details regarding items. Create a pointer variable *pitem of a structure item and access
the elements or members of a structure using pointer variable by using > operator.
poe
estos
seeToRe
OUTPUT
Enter product name: Asus Laptop
Enter price: 60000
Enter quantity: S
Name: Asus Laptop
Price: 60000,000000
Quantity: 5
Total Amount: 300000.000000
34.Create a structure student (charname{10],int marks[3],,int total and float percentage).
Enter the marks of 5 students in 3 subjects and calculate the percentage (Hint:Use the
concept of array of structure).OUTPUT
Enter information of students:
For roll number:
8
Enter first name: Alen
Enter marks: 94
For roll number:
9
Enter first name: Anant
Enter marks: 82
For roll number:
10
Enter first name: Akshat
Enter marks: 98.6
For roll number
"1
Enter first name: Joel
Enter marks: 88
For roll number:
12
Enter first name: Vishrut
Enter marks: 99.8
Displaying Information:
1)Roll number: 8
First name; AlenMarks: 94.0
2)Roll number: 9
First name: Anant
Marks: 82.0
3)Roll number: 10
First name: Akshat
Marks: 98.6
4)Roll number: 11
First name: Joel
Marks: 88.0
5)Roll number: 12
First name: Vishrut
Marks: 99.8
35.Create a structure Distance (int feet and float inch). Take two distances as input from
user and add them (inch and feet separately). Display total distance in feets and inches.
OUTPUT
Enter Ist distance
Enter feet: 5
Enter inch: 8Enter 2nd distance
Enter feet: 6
Enter inch: 2
Sum of distances ~ 11'-10.0"
38.Write a program in C to create and store information in a text file(using fprintf and
fscanf functions)
OUTPUT
Enter the id
4331
Enter the name
Akshat
Enter the salary
900000
Name= Akshat
Salary= 9000.00
39.Write a program in C to create and store information in a binary file(using fread and
fwrite functions)40.Write a program in C to create and store information in a data file(using gete and
pute functions)
sy
— erica
Peete
41.Write a program in C to create and store information in a data file(using fgets and
{puts functions)
42.Write a program in C to create and store information in a data file(using getw and
putw functions)Pa
Pee
Pecrucrc ry45.Write a program in C to merge two files and write it in a new file.
fnamel)
acta
47.WAP in C that takes the file name as an input from user, create a file “data” to store
integer numbers from 1 to 10. Create two more files “even” and “odd” , read the contents
of “data” and check whether the number is even and odd and copied the same in to “
even” and “odd” file.eos]
Sees)OUTPUT
Enter number of elements: 4
Enter elements of array: 2 4.6 8
Sum=20
49.WAP TO SHOW THE USE OF FOLLOWING DIRECTIVES #IF, #ELSE AND
#ENDIF IN C
50.WAP TO SHOW THE USE OF STRINGIZE (#) AND TOKEN P/
OPERATOR IN C.
OUTPUT
This is a string without double quotes
2050