Advertisement
bobbinz

Resistance Calculator

Oct 7th, 2011
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. //Resistance Calculator
  2. //Adam Robbins 2011
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. float v,i,r;                                                        //set up various variables
  8. char vin[256];
  9. char iin[256];
  10.  
  11. int main()
  12. {
  13.     printf("What is the Voltage?\n");                               //ask for the voltage
  14.     scanf("%s",&vin);                                               //read the input
  15.     v = atof(&vin);                                                 //convert to floats
  16.     printf("\nWhat is the Current?\n");                             //ask for the current
  17.     scanf("%s",&iin);                                               //read the input
  18.     i = atof(&iin);                                                 //convert to floats
  19.  
  20.     r = v / i;                                                      //do the sum
  21.  
  22.     printf("\n\nThen the Resistance must be... %f\n\n",r);          //print the answer
  23.  
  24.     return 0;                                                       //stop moaning and shut up
  25. }
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement