Lab1 - C PROGRAM
Lab1 - C PROGRAM
int main() {
// Define parameters for the sine wave
double amplitude = 1.0; // Amplitude of the sine wave
double frequency = 1.0; // Frequency of the sine wave (in Hz)
double sampling_rate = 44100.0; // Sampling rate (samples per second)
double duration = 5.0; // Duration of the sine wave (in seconds)
return 0;
}
int main() {
// Define parameters for the sine wave
double amplitude = 1.0; // Amplitude of the sine wave
double frequency = 1.0; // Frequency of the sine wave (in Hz)
int num_samples = 100; // Number of samples in the discrete sine wave
// Print the sine value (you can output it to a file or process it further)
printf("%lf\n", sine_value);
}
return 0;
}
int main() {
// Define parameters for the cosine wave
double amplitude = 1.0; // Amplitude of the cosine wave
double frequency = 1.0; // Frequency of the cosine wave (in Hz)
double sampling_rate = 44100.0; // Sampling rate (samples per second)
double duration = 5.0; // Duration of the cosine wave (in seconds)
// Print the cosine value (you can output it to a file or a sound device)
printf("%lf\n", cosine_value);
}
return 0;
}
int main() {
// Define parameters for the cosine wave
double amplitude = 1.0; // Amplitude of the cosine wave
double frequency = 1.0; // Frequency of the cosine wave (in Hz)
int num_samples = 100; // Number of samples in the discrete cosine wave
// Generate and print the discrete cosine wave
for (int i = 0; i < num_samples; i++) {
// Calculate the current angle in radians
double angle = 2.0 * M_PI * frequency * i / num_samples;
// Print the cosine value (you can output it to a file or process it further)
printf("%lf\n", cosine_value);
}
return 0;
}
5. Unit impulse
#include <stdio.h>
int main() {
// Define the length of the impulse function
int length = 10; // Change this to the desired length
return 0;
}
6. Ramp
#include <stdio.h>
int main() {
// Define the length of the ramp function
int length = 10; // Change this to the desired length
// Create an array to store the ramp function
int ramp[length];
return 0;
}
7. Square Wave
#include <stdio.h>
int main() {
// Define parameters for the square wave
int period = 10; // Number of samples per period
int num_periods = 5; // Number of periods
int length = period * num_periods; // Total length of the wave
return 0;
}
8. Parabola
#include <stdio.h>
int main() {
// Define parameters for the parabolic function
double a = 1.0; // Coefficient for x^2
double b = 2.0; // Coefficient for x
double c = 1.0; // Constant term
int num_points = 10; // Number of points on the parabola
double x, y;
return 0;
}