C programming - This is what I have so far but it is not working correctly. It must contain the function and it also needs a provision to write output to a file. Can anyone help?
//The file will get created once you run this code.
#include<stdio.h>
#include<math.h>
float calPow(int V, float Rint, float RL)
{
FILE *file = fopen("Rint.txt", "ab+");
//i am creating a file if doesnt exist, if exist
then it will just append data
float i,p;
if (file)
{
for(i=RL;i<Rint;i++)
// Rl = Rint-100, so we should begin from RL
till it reaches Rint value
{
p =
pow(V,2)/i;
//printf("\nRL
Rint Power Power");
//printf("\nn
Rint RL");
fprintf(file,
"\n%.2f %.2f %.2f %.2f",RL,Rint,i,p); // printing all
the data to a file.
}
fclose(file); //closing
the file
}
return p; //returning last p value to
where the function call occurs
}
int main( ) //i just removed void, because if you use void you
dont need to return
{
int V;
float Rint,RL=0,p=0;
printf("\nNew power supply voltage: ");
scanf("%d",&V);
printf("\nEnter a valid internal resistance (Rint)
range between 200 and 5k ohms: ");
scanf("%f",&Rint);
if(V>=1 && V<=15)
{
if(Rint>=200 &&
Rint<=5000)
{
RL =
Rint-100;
p =
calPow(V,Rint,RL); //here you are
getting some value from calPow and assigning to float variable.
Then the function should be float
printf("\nMaxmimul power transferred to RL is : %f\n",p);
}
else
printf("\nEntered values of Rint are invalid in the range");
}
else
printf("\nEntered values of V is
not valid in the range");
return 0;
}
C programming - This is what I have so far but it is not working correctly....
So I have a question in regards to my program. I'm learning to program in C and I was curious about the use of functions. We don't get into them in this class but I wanted to see how they work. Here is my program and I would like to create a function for each of my menu options. I created a function to display and read the menu and the option that is entered, but I would like to...
C Programming - RSA encryption Hi there, I'm struggling with writing a C program to encrypt and decrypt a string using the RSA algorithm (C90 language only). It can contain ONLY the following libraries: stdio, stdlib, math and string. I want to use the following function prototypes to try and implement things: /*Check whether a given number is prime or not*/ int checkPrime(int n) /*to find gcd*/ int gcd(int a, int h) void Encrypt(); void Decrypt(); int getPublicKeys(); int getPrivateKeys();...
C Programming I have this cost estimation program, but I want to add to it more functions to be more accurate and more useful. I want to add to the program an array and a loop that can help me with the materials that can be use to the building, as ceramic, wood and concrete and extra functions. ########## #include <stdio.h> int main(void) { float wid,len,yrs; int metersq = 2000; int floors,rooms,win,doors,restrooms,umet; char floortype[20]; char ti[20]; int woodfloor = 25;...
Write a complete C program. Define a structure type element_t to represent one element from the periodictable of elements. Components should include the atomic number (aninteger); the name, chemical symbol, and class (strings); a numeric field forthe atomic weight; and a seven-element array of integers for the number ofelectrons in each shell. The following are the components of an element_t structure for sodium.11 Sodium Na alkali_metal 22.9898 2 8 1 0 0 0 0 Have the user enter the data...
#include<stdio.h> int main() { int i; printf("Type an integer value: "); scanf("%d",&i); evaluate(i); return(0); } void evaluate(int x) { if(x > 10) printf("Value entered by you is greater than 10"); else if(x < 10) printf("Value entered by you is less than 10"); else printf("Value entered by you is equal 10"); } _______________________________________ report for this in hr ?
Please, I need help, I cannot figure out how to scan variables in to the function prototypes! ******This is what the program should look like as it runs but I cannot figure out how to successfully build the code to do such.****** My code: #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <conio.h> float computeSeriesResistance(float R1, float R2, float R3); float computeParallelResistance(float R1, float R2, float R3); float computeVoltage(int current, float resistance); void getInputR(float R1, float R2, float R3); void getInputCandR(int...
Dear Helpers, this is my final project for programming in C. I am not a programmer but need to pass this class please help!! I do not have a clue as how to start this project : Project for This Course Goal: Develop a program that will automatically adjust a variable resistor until the maximum power is transferred to a load resister. Purpose: For this project, you will create a prototype of a circuit designed to transfer the maximum power...
I need the programming to be in language C. I am using a program called Zybook Prompt: Write a statement that outputs variable numObjects. End with a newline. Given: #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); return 0; } What I did so far. I am not sure if its right tho? #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); printf(" num Objects is "); printf("%d\n", userAge); return 0; }
I am trying to write C programming code and output will be as below but I donno how to get the result analysis part. help me to add the 2nd part with my code: here is my code below: #include <stdio.h> #define MAX 100 struct studentMarkVariable{ int id; float marks; }; void getData(struct studentMarkVariable arrs[]); void show(struct studentMarkVariable arrs[]); int main() { printf ("####### Marks Analyzer V3.0 ####### \n"); struct studentMarkVariable arrs[MAX]; getData(arrs); show(arrs); return 0; }...
C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...