#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SIZE 10 // Size of the array
// Function to update date and time format
void updateDateTimeFormat(char *dateTime) {
// Your implementation to update date and time format goes here
// This function can be implemented according to your specific requirements
// For demonstration purposes, let's just print the updated format
printf("| %-15s", dateTime); // Print the updated date and time format
}
// Function to calculate standard deviation
double calculateStandardDeviation(int data[], int size) {
double mean = 0.0, variance = 0.0, stddev = 0.0;
// Calculate mean
for (int i = 0; i < size; i++) {
mean += data[i];
}
mean /= size;
// Calculate variance
for (int i = 0; i < size; i++) {
variance += pow(data[i] - mean, 2);
}
variance /= size;
// Calculate standard deviation
stddev = sqrt(variance);
return stddev;
}
// Function to calculate cumulative frequency
void calculateCumulativeFrequency(int data[], int size, int cumulative[]) {
cumulative[0] = data[0];
for (int i = 1; i < size; i++) {
cumulative[i] = cumulative[i - 1] + data[i];
}
}
// Function to sort an array in ascending order using bubble sort
void sortArray(int arr[], int size) {
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
// Swap elements
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
int main() {
int array[SIZE] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; // Predefined array
// Sort the array
sortArray(array, SIZE);
// Update date and time format
char dateTimeFormat[] = "DD/MM/YYYY HH:MM:SS";
printf("| %-15s", "Date"); // Print the header for the date
updateDateTimeFormat(dateTimeFormat);
printf("\n");
// Calculate standard deviation
double stddev = calculateStandardDeviation(array, SIZE);
printf("| %-15s%.2lf\n", "Std Deviation:", stddev);
// Calculate variance
double variance = pow(stddev, 2);
printf("| %-15s%.2lf\n", "Variance:", variance);
// Calculate frequency
int frequency[SIZE];
for (int i = 0; i < SIZE; i++) {
frequency[i] = array[i];
}
// Calculate cumulative frequency
int cumulativeFrequency[SIZE];
calculateCumulativeFrequency(frequency, SIZE, cumulativeFrequency);
// Print the cumulative frequency
printf("| %-15s", "Cumulative Freq:");
for (int i = 0; i < SIZE; i++) {
printf("%d ", cumulativeFrequency[i]);
}
printf("\n");
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: