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

Practical no 1 rajashri

The document contains two C programs demonstrating basic data structure operations. The first program finds the minimum and maximum elements in an array, while the second program searches for a target element within the array. Both programs include user input for the number of elements and the elements themselves, along with output results.
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)
6 views4 pages

Practical no 1 rajashri

The document contains two C programs demonstrating basic data structure operations. The first program finds the minimum and maximum elements in an array, while the second program searches for a target element within the array. Both programs include user input for the number of elements and the elements themselves, along with output results.
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

Practical no : 1 class : SYCO roll no : 56

Course : data Structure Using C course code : 313301


Academic year : 2024-2025
Name : Khedkar Rajashri Ramkisan

1.
#include <stdio.h>
int main() {
int arr[100];
int n, i, min, max;

printf("Enter the number of elements: ");


scanf("%d", &n);

printf("Enter %d elements:\n", n);


for (i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
min = arr[0];
max = arr[0];

for (i = 1; i < n; i++) {


if (arr[i] < min) {
min = arr[i];
}
if (arr[i] > max) {
max = arr[i];
}
}
printf("Minimum element: %d\n", min);
printf("Maximum element: %d\n", max);

return 0;
}
\*
Output:
Enter the number of elements: 6
Enter 6 elements:
44 12 3 58 9 20
Minimum element: 3
Maximum element: 58

=== Code Execution Successful ===


*\
2.
#include <stdio.h>
int main() {
int arr[100];
int n, i, target, found = 0;

printf("Enter the number of elements: ");


scanf("%d", &n);

printf("Enter %d elements:\n", n);


for (i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
printf("Enter the target element: ");
scanf("%d", &target);

for (i = 0; i < n; i++) {


if (arr[i] == target) {
found = 1;
break;
}
}
if (found) {
printf("Element %d found at index %d\n", target, i);
} else {
printf("Element %d not found in the array\n", target);
}
return 0;
}
\*
Output:

Enter the number of elements: 5


Enter 5 elements:
12 33 9 15 4
Enter the target element: 9
Element 9 found at index 2

=== Code Execution Successful ===


\*

You might also like