hi, i trying to list out the array of power,amps,res
and vots input by user.
But only available to list out the first input of power,amps..etc.
Second input gave me 0s.
thanks in advance...
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#define SIZE 50
char input[SIZE];
int choice;
float vots[SIZE],amps[SIZE],res[SIZE],power[SIZE],*v,*i,*r,*p;
*v=vots;
*i=amps;
*r=res;
*p=power;
void main()
{
some codes...
}
void high_low(void)
{
int x,hi=0,li=0;
float hpower,lpower;
for (x=0; x < 2; x++)
{
system("cls");
printf("\n");
printf("\tThe calculated DC powers are:\n");
printline();
printf("\n\tNo.\tCurrent\t\tVoltage\t\tResistance\ tPower");
printf("\n\t\t(amps)\t\t(volt)\t\t(ohms)\t\t(watts )\n");
printline();
printf("\t%2d\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\n",x+1 ,*(i+x),*(v+x),*(res+x),*(power+x));
x=x+0;
}
}
void power_VI (void)
{
system("cls");
printline();
printf("\t\tDC Power calculation using Voltage and Current\n");
printline();
printf("\n\t\tEnter the value of voltage <vots> : ");
gets(input);
*v=(float)atof(input);
printf("\t\tEnter the value of current <amps> : ");
gets(input);
*i=(float)atof(input);
printf("\n\t\tThe computed values are :\n");
*r = (*v)/(*i);
*p = (*v**v)/(*r);
printf("\n\t\tResistance = %.2f ohms\tDC power = %.2f watts\n", *r,*p);
}
void power_VR (void)
{
system("cls");
printline();
printf("\t\tDC Power calculation using Voltage and Resistance\n");
printline();
printf("\n\t\tEnter the value of voltage <vots> : ");
gets(input);
*v=(float)atof(input);
printf("\t\tEnter the value of resistance <ohms> : ");
gets(input);
*r=(float)atof(input);
printf("\n\t\tThe computed values are :\n");
*i = (*v)/(*r);
*p = (*i)*(*i)*(*r);
printf("\n\t\tCurrent = %.2f amps\tDC power = %.2f watts\n", *i,*p);
}
void power_IR (void)
{
system("cls");
printline();
printf("\t\tDC Power calculation using Current and Resistance\n");
printline();
printf("\n\t\tEnter the value of current <amps> : ");
gets(input);
*i=(float)atof(input);
printf("\t\tEnter the value of resistance <ohms> : ");
gets(input);
*r=(float)atof(input);
printf("\n\t\tThe computed values are :\n");
*v = (*i)*(*r);
*p = (*v)*(*v)/(*r);
printf("\n\t\tVoltage = %.2f ohms\tDC power = %.2f watts\n", *v,*p);
}