0% found this document useful (0 votes)
9 views23 pages

23BCE20025 ITP Compressed

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views23 pages

23BCE20025 ITP Compressed

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

INTRODUCTION TO

PROGRAMMING ASSIGNMENT .

NAME : CHANDIKA BALA MANOJ.

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:

9. Declare a structure to store the following


information of an employee: employee code,
employee name, salary, department number, hire
date. Write a program to store the data of ‘n’
employees where ‘n’ is given by user dynamically.
(i) Use a function to display the employee records
in ascending order according
to their salary.
(ii) Use a function with a pointer to structure as
argument to display the
department wise employee records.
(iii) Use a function to display the details of
employees whose salary is more than
70% of average salary
PROGRAM :
OUTPUT:
10. An organization has employees with varying
types of compensations:
• Full-time employees are given a monthly salary
(as float).
• Part-time employees are paid based on the
number of hours worked (as int).
• Contract-based employees receive a lump-sum
payment for the contract (as
double).
Create a C program that:
• Uses a union inside a structure to store the
salary details based on the type of
employment.
• Accepts the details for different types of
employees (employee name, ID, type
of employment) and their respective salary
information.
• Displays the employee details along with their
respective salary.

PROGRAM :
OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy