Here is the the source code for my Omhs Law program, I can't figure how to attach it.Fell free to use this progam , modifi it as lone reconise me A.Mac Hugh as the author.
Code:
#include <stdio.h>
#include <stdlib.h>
/*Omhs Law program
Author :A.Mac Hugh
Date:-30-09-2002
Version:-*/
void voltage (); /* function prototype*/
void current (); /* function prototype*/
void reistance (); /* function prototype*/
void main(void)
{ int x;
void menu (void); /* function prototype*/
printf("\n\tWelcome to Machsofts Omhs Lawn. \n\tThis program will culate thr ristance , current or voltage.");
printf("\n\tThis is copyright Machsoft inc 2002");
printf("\n\tVersion 1\n\n\n");/* intoduction*/
menu (); /*fuction beging run*/
printf( "please hit any x and enter to continue\n\t");
scanf("%d",&x) ;
}
void menu (){
int nums;
printf("To calulate the voltage press\n\t 1\n\n\t\n");/* ask user for therir option*/
printf("To calulate current press \n\n\t2\n\n\t\n");
printf("To caulate reistance press \n\n\t3\n\n\t\n");
scanf("%d",& nums);/*get option*/
if (nums == 1)
voltage () ; /*fuction beging run*/
else if(nums == 2)
current (); /*fuction beging run*/
else if(nums==3)
reistance ();
}
void voltage (){ /* Voltagre fuction varibles v i r*/
int v;
int i;
int r;
printf(" Please enter in the values for the current (i)\n" );/*ask user enter in values*/
printf("and the reistance (r)\n");
scanf("%d",&i);/* get values*/
scanf("%d",&r);
v= i*r;
printf("\nThe voltage is %d volts\n\t",v);/* prints out voltage*/
}
void current (){ /* Current fuction varibles v i r*/
int v;
int i;
int r;
printf(" Please enter in the values for the voltage (v) and the reistance (r)\n\t");/*ask user enter in values*/
scanf("%d%d",&v,&r);;/* get values*/
i= v/r;
printf("\nThe curremt is %d amps\n\t",i);/* prints out current*/
}
void reistance (){ /* Reistance fuction varibles v i r*/
int v;
int i;
int r;
printf(" Please enter in the values for the current (i) and the voltage (v)\n\t");/*ask user enter in values*/
scanf("%d%d",&v,&i);;/* get values*/
r= v/i;
printf("\nThe reistance is %d omhs\n\t",r);/* prints out resistance*/
}
[EDIT]Code tags added by Hammer. Please read this thread.