re:array of notation (full code)
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#define SIZE 50
int menu(void);
void printline(void);
void power_VI(void);
void power_VR(void);
void power_IR(void);
void high_low(void);
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()
{
//float num1,num2;
while(1)
{
choice=menu();
switch(choice)
{
case '1': power_VI();
break;
case '2':
power_VR();
break;
case '3':
power_IR();
break;
case '4':
high_low();
break;
case '5':
printf("\n\t\t");
break;
default :
printf("\n\t\tInvalid Key -- try again!\n");
}
if(choice == '5')
break;
printf("\n\t\tPress any key to continue!");
getch();
}
}
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);
}
int menu(void)
{
system("cls");
printline();
printf("\t\tCALCULATION OF DC POWER\n");
printline();
printf("\t\t(1)\tUsing Voltage and Current\n");
printf("\t\t(2)\tUsing Voltage and Resistance\n");
printf("\t\t(3)\tUsing Current and Resistance\n");
printf("\t\t(4)\tDisplay Highest & Lowest Power\n");
printf("\t\t(5)\tExit\n");
printline();
printf("\n\t\tPlease enter your choice : ");
return getche();
}
void printline (void)
{
int count;
printf("\t");
for(count=0; count<65; count++)
{
printf("=");
}
printf("\n");
}