Answer:
Explanation:
R1 and R2 are in series =R1+R2=10K+20K=30KΩ
Req=50Ω
R3 is parallel with R1 and R2=>
(1/30k)+(1/r)=(1/Req)
r=50.0834Ω
explain the structure of c program with example
Answer:
A C program typically consists of a number of components, including preprocessor directives, function prototypes, global variables, functions, and a main function.
Explanation:
Here's an explanation of each component, followed by an example C program that demonstrates their usage:
Preprocessor Directives: Preprocessor directives are instructions to the C preprocessor, which processes the source code before compilation. They usually start with a '#' symbol. Some common directives are #include for including header files and #define for defining constants.
Function Prototypes: Function prototypes provide a declaration of functions that will be used in the program. They specify the function's name, return type, and the types of its parameters.
Global Variables: Global variables are variables that can be accessed by any function in the program. They are usually defined outside of any function.
Functions: Functions are blocks of code that can be called by name to perform specific tasks. They can accept input parameters and return a value. Functions are generally declared before the main function.
Main Function: The main function is the entry point of the program. It's where the execution starts and ends. It has a return type of int and typically takes command-line arguments via two parameters: argc (argument count) and argv (argument vector).
Here's an example C program that demonstrates the structure:
// Preprocessor directives
#include <stdio.h>
// Function prototypes
void print_hello_world(void);
// Global variable
int global_var = 10;
// Functions
void print_hello_world(void) {
printf("Hello, World!\n");
}
// Main function
int main(int argc, char *argv[]) {
// Local variable
int local_var = 20;
printf("Global variable value: %d\n", global_var);
printf("Local variable value: %d\n", local_var);
print_hello_world();
return 0;
}
This simple C program demonstrates the use of preprocessor directives, a function prototype, a global variable, a function, and the main function. When run, it prints the values of a global and a local variable, followed by "Hello, World!".