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

Lab Task 2 PDF

The document is a lab assessment for a student named Sabbir Ahmed in the Data Structure Lab course. It includes a coding task to delete an element from an array and provides a sample C program to accomplish this. The assessment also includes a marking scheme and comments section for the course teacher.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Lab Task 2 PDF

The document is a lab assessment for a student named Sabbir Ahmed in the Data Structure Lab course. It includes a coding task to delete an element from an array and provides a sample C program to accomplish this. The assessment also includes a marking scheme and comments section for the course teacher.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Lab Assessment - 02

Only for Course Teacher


Needs Developing Sufficient Above Total
Improvement Average Mark

Allocate mark & Percentage 25% 50% 75% 100% 15


Problem Analysis 03
Solution Design 02
Code Development 06
Accuracy 04
Total obtained mark

Comments

Semester: Spring 2025


Student Name: Sabbir Ahmed
Student ID:241-35-196
Batch: 42 Section: D2
Course Code: SE 132 Course Name: Data Structure Lab
Course Teacher Name: Mr. Md. Sakib Ali Mazumdar
Designation: Lecturer
Submission Date:18 /02/2025
1. Delete one element , if exist. If exist multiple times then the last one.
2. Solve the problem and upload the file here.

Answer:

#include <stdio.h>

int main()
{
int n;
printf("Enter the size of the array: ");
scanf("%d", &n);

char a[n];
int i;

getchar();
for (i = 0; i < n; i++)
{
printf("Enter element no.%d: ", i + 1);
scanf("%c", &a[i]);
getchar();
}

int index;
printf("Enter the index number of the element you want to delete: ");
scanf("%d", &index);

if (index < 0 || index >= n)


{
printf("Invalid index! Must be between 0 and %d.\n", n - 1);
return 1;
}

for (i = index; i < n - 1; i++)


{
a[i] = a[i + 1];
}

n--;
printf("New array after deletion:\n");
for (i = 0; i < n; i++)
{
printf("Element no.%d = %c\n", i + 1, a[i]);
}

return 0;
}

OUTPUT:
:

You might also like