Professional Documents
Culture Documents
InSRuniversitythestudentrecordsinformation, includingtheirstudentID Is Stored
InSRuniversitythestudentrecordsinformation, includingtheirstudentID Is Stored
InSRuniversitythestudentrecordsinformation, includingtheirstudentID Is Stored
SECTION:G1
BATCH:13
HN:2303A5164
1. In SRuniversity thes tudent records information,including their studentID is stored in an array. As part of the
functionality, you need to implement a feature that allows the removal of a student's record when they withdraw
from a course.
a C program segment that takes an array of student records, the size of the array, and the position of the
student to be removed. Implement a function to delete the student record at the speci ed position and update
fi
the array accordingly. Ensure the program handles invalid positions gracefully.
Requirements:
Handle cases where the user provides an invalid position (e.g., negative position, position greater than or equal
to the array size).
Example:
Enter the size of the student records array: 4 Enter student details for each record: Student 1 - ID: 101
program:
#include <stdio.h>
void deleteStudent(int students[], int *size, int posion) { if (posion <= 0 || posion > *size) {
return; }
(*size)--; }
int main() {
int maxSize = 100;
int students[maxSize];
int size;
scanf("%d", &size);
for (int i = 0; i < size; ++i) {
scanf("%d", &students[i]); }
int posion;
scanf("%d", &posion); deleteStudent(students, &size, posion); for (int i = 0; i < size; ++i) {
Question:
1. WriteaCprogramthataccomplishesthefollowing:
2. Declareanarraytostoretheinitialinventorywithatleast5products.
3. Displaythecurrentinventorytothestoremanager.
4. Promptthestoremanagertoentertheposition(index)oftheproductthey
5. want to insert.
6. Implementthedeletionprocessbyshiftingtheremainingproductstofill
7. the gap.
8. Displaytheupdatedinventoryaftertheinsertion.
Handle cases where the store manager provides an invalid position (e.g., negative position, position greater
than or equal to the array size).
Initial Inventory:
1. ProductID:101 2. ProductID:102 3. ProductID:103 4. ProductID:104 5. ProductID:105
PROGRAM:
#include <stdio.h>
void insertProduct(int inventory[], int *size, int posion, int productID) {
}
for (int i = *size - 1; i >= posion; --i) {
inventory[i + 1] = inventory[i]; }
inventory[posion] = productID;
(*size)++; }
int main() {
int maxSize = 100;
int inventory[maxSize]; int size;
scanf("%d", &size);
for (int i = 0; i < size; ++i) {
scanf("%d", &inventory[i]); }
Question:
Write a C program that accomplishes the following:
1. Declareanarraytostorethedailytemperaturesforaweek(atleast7 days).
2. Displaytheunsortedtemperaturestothemeteorologist.
3. Implementasortingalgorithmtoarrangethetemperaturesinascending
4. order directly within the array.
5. Displaythesortedtemperaturesafterthesortingprocess.
6. Ensuretheprogramhandlesanydatatyperelatedissues.
Example:
Initial Temperatures:
PROGRAM:
int daysInWeek;
scanf("%d", &daysInWeek);
int temperatures[daysInWeek]; for (int i = 0; i < daysInWeek; ++i) {
scanf("%d", &temperatures[i]); }
temperatures[j + 1] = temperatures[j];
j=j-1; }
temperatures[j + 1] = key; }
}}
4 .To develop an application for a ticketing system that records seat numbers for a concert. The seat numbers
are stored in an array, where each element represents the seat number. As part of the ticketing system, you
need to implement a feature that counts and identifies any duplicate seat numbers.
Question:
1. WriteaCprogramthataccomplishesthefollowing:
2. Declareanarraytostoretheseatnumbersforasectionoftheconcerthall
Example:
Initial Seat Numbers:
PROGRAM:
int numSeats;
scanf("%d", &numSeats);
int seats[numSeats];
int countDuplicates = 0;
scanf("%d", &seats[i]); }
duplicates[i] = 0; }
for(inti=0;i<numSeats-1;++i){ if (duplicates[i])
connue;
}}
}}
if (hasDuplicates) {
}}
prin("No Duplicates\n"); }
return 0; }