23BCE20025 ITP Compressed
23BCE20025 ITP Compressed
PROGRAMMING ASSIGNMENT .
REG NO : 23BCE20025.
SLOT : F1.
1. Write a C program to create a string array
using pointer and store 10 names of the students.
Also create a function “order” and call using
pointer to function and sort it in alphabetical order.
PROGRAM :
OUTPUT:
2. Write a C program to read an integer array of
size 4 using pointers and allocate memory using
dynamic memory allocation elements. Write a
function “cyclicswap” by passing the array using
Call by Reference and no of swaps to perform
cyclic swapping of 4 elements in the array and
also print it as a 4-digit number.
Input
1 2 3 4
No of swaps=2
Output
Value after swapping:1
4 1 2 3
4digit number-4123
Value after swapping:2
3 4 1 2
4-digit number-3412
PROGRAM :
OUTPUT:
3. Create a structure to specify data of customers
in a bank. The data to be stored is: Account
number, Name, Balance in account. Write
function “withdraw” and “deposit”. Assume
maximum of 200 customers in the bank(Use array
of structure) Write a C program to print the
Account number and name of each customer with
balance below Rs.100.
PROGRAM :
OUTPUT:
4. Create a Union “library” with the details sname,
sid, bname, bid, noofdays and fine. A library
charges a fine for every book returned late. For
first 5 days the fine is 50 paise, for 6-10 days the
fine is one rupee and above 10 days fine is 5
rupees. If you return the book after 30 days your
membership will be cancelled. Write a C program
to accept the details for 5 students and create a
function finecalc() to find the Member is late to
return the book and display the fine or the
appropriate message.
PROGRAM :
OUTPUT:
5. A record contains the name of the cricketer, his
age, the number of test matches that he has
played and the average runs that he has scored
in each test match. Create an array of structure to
hold records of 20 such cricketers and then write
a program to read these n records and arrange
them in ascending order by average runs by
passing n and array of structure as pointers and
to the function “sort”.
PROGRAM :
OUTPUT:
6. Write a C program to read a one-dimensional
array of integers using pointer and write a
function to find the sum of contiguous subarray
within a pointer array of integer which returns the
largest sum.
PROGRAM :
OUTPUT:
7. You are developing a program that tracks daily
transactions for a small business. The number of
transactions is not known at compile-time, so you
must dynamically allocate memory to store the
number of transaction and amounts. The program
should allow the user to add transactions, view
the total and average transactions amount, and
dynamically adjust the memory allocated as more
transactions are added.
Write a C program that uses malloc() to allocate
memory for storing transaction amounts.
PROGRAM :
OUTPUT:
8. Design a scanner which reads in a line of text
using a pointer to a character on a character-by-
character basis until a new line character(“\n”) is
encountered, and then displays the characters in
reverse order. The program utilizes recursion to
carry out the reversal of the characters.
PROGRAM :
OUTPUT:
PROGRAM :
OUTPUT: