Practical related questions
1) Write expression using operators in C for finding Serial resonance?
#include <stdio.h>
#include <math.h>
int main() {
double L, C, fr;
printf("Enter the inductance (L) in henries: ");
scanf("%lf", &L);
printf("Enter the capacitance (C) in farads: ");
scanf("%lf", &C);
fr = 1 / (2 * M_PI * sqrt(L * C));
printf("The resonant frequency (fr) is: %.2f Hz\n", fr);
return 0;
}
Output:
Enter the inductance (L) in henries: 0.01
Enter the capacitance (C) in farads: 0.001
The resonant frequency (fr) is: 1591.55 Hz
(2) Write a program to find acceleration by asking following values to user: initial
velocity, final velocity, time period.
#include <stdio.h>
int main() {
double initial_velocity, final_velocity, time_period, acceleration;
printf("Enter the initial velocity (m/s): ");
scanf("%lf", &initial_velocity);
printf("Enter the final velocity (m/s): ");
scanf("%lf", &final_velocity);
printf("Enter the time period (s): ");
scanf("%lf", &time_period);
if (time_period == 0) {
printf("Error: Time period cannot be zero.\n");
} else {
// Calculate acceleration
acceleration = (final_velocity - initial_velocity) / time_period;
// Display the result
printf("The acceleration is: %.2f m/s²\n", acceleration);
}
return 0;
}
Output:
Enter the initial velocity (m/s): 10
Enter the final velocity (m/s): 20
Enter the time period (s): 5
The acceleration is: 2.00 m/s²
(3) Write a program for calculating voltage when current and resistance is given in
OHMs law?
#include <stdio.h>
int main()
{
double current, resistance, voltage;
printf("Enter the current (in amperes): ");
scanf("%lf", ¤t);
printf("Enter the resistance (in ohms): ");
scanf("%lf", &resistance);
voltage = current * resistance;
printf("The voltage is: %.2f volts\n", voltage);
return 0;
}
Output:
Enter the current (in amperes): 5
Enter the resistance (in ohms): 10
The voltage is: 50.00 volts