Practical 9
Practical 9
SET A
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n <= 0) {
scanf("%d", &array[i]);
printf("\n");
return 0;
array.
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n <= 0) {
scanf("%d", &array[i]);
}
// Initialize min and max
min = array[i];
max = array[i];
return 0;
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
// Check for valid input
if (n <= 0) {
scanf("%d", &array[i]);
return 0;
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n <= 0) {
int number;
scanf("%d", &number);
frequency[number]++;
}
// Display the frequency of each number
if (frequency[i] > 0) {
return 0;
5.SAME
6. Write a function to accept n numbers and display the array in the reverse
#include <stdio.h>
// Function prototypes
int main() {
int n;
scanf("%d", &n);
acceptNumbers(array, n);
displayReverse(array, n);
return 0;
scanf("%d", &arr[i]);
}
7. Write a function to accept n numbers and store all prime numbers in
#include <stdio.h>
#include <stdbool.h>
// Function prototypes
int main() {
int n;
scanf("%d", &n);
displayPrimes(prime, primeCount);
return 0;
return true;
// Function to accept numbers and store prime numbers in the prime array
scanf("%d", &arr[i]);
if (isPrime(arr[i])) {
prime[*primeCount] = arr[i];
} else {
SET B
1. Write a program to accept n numbers and count Even and Odd Elements in an
Array
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
scanf("%d", &array[i]);
if (array[i] % 2 == 0) {
evenCount++;
} else {
oddCount++;
return 0;
Even Position
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
scanf("%d", &array[i]);
return 0;
}
3. Write a program to accept n numbers and print Array Elements Present in Odd
Position
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
scanf("%d", &array[i]);
return 0;
4. Write a program to accept n numbers and write a function to print the Sum of
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n <= 0) {
int totalEvenSum = 0;
// Accept numbers and calculate sum of even and product of odd digits
int number;
printf("Enter number %d: ", i + 1);
scanf("%d", &number);
int evenSum = 0;
totalEvenSum += evenSum;
return 0;
*evenSum += digit;
*oddProduct *= digit;
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
scanf("%d", &array[i]);
}
// Get the element to delete
int element;
scanf("%d", &element);
return 0;
if (arr[i] == element) {
i--; // Adjust index to check the new element at the current position
}
if (!found) {
6. Write function to accept n numbers and print Array Elements Present in Even
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
scanf("%d", &array[i]);
printEvenPositionElementsAndSum(array, n);
return 0;
int sum = 0;
sum += arr[i];