Tuesday, August 14, 2012

C language coding of a Resistance Calculator



C or C++ compiler is needed to run this coding. Any kind of suggestion about this coding will be received gratefully.


Coding:


#include <stdio.h>
 #include<math.h>
 int main()
 {
     char ara[3],ar[3],ax[3],azim[3];
     int a,b,c,d,e,f,Resistance;

     do{
     printf("\n\nFirst Band\t");
     gets(ara);
     if(ara[0]=='b'&&ara[1]=='l'&&ara[2]=='a'){a=0;}
     else{ if(ara[0]=='b'&&ara[1]=='r'){a=1;}
     else{ if(ara[0]=='r'&&ara[1]=='e'){a=2;}
     else{ if(ara[0]=='o'&&ara[1]=='r'){a=3;}
     else{ if(ara[0]=='g'&&ara[1]=='r'&&ara[2]=='e'){a=5;}
     else{ if(ara[0]=='b'&&ara[1]=='l'&&ara[2]=='u'){a=6;}
     else{ if(ara[0]=='v'&&ara[1]=='i'){a=7;}
     else{ if(ara[0]=='g'&&ara[1]=='r'){a=8;}
     else{ if(ara[0]=='w'&&ara[1]=='h'){a=9;}
     else{ if(ara[0]=='y'&&ara[1]=='e'){a=4;}
     else{a=10;};};};}};}}}}}
     printf("\t%d",a);

          printf("\n\nSecond Band\t");
          gets(ar);
     if(ar[0]=='b'&&ar[1]=='l'&&ar[2]=='a'){b=0;}
     else{ if(ar[0]=='b'&&ar[1]=='r'){b=1;}
     else{ if(ar[0]=='r'&&ar[1]=='e'){b=2;}
     else{ if(ar[0]=='o'&&ar[1]=='r'){b=3;}
     else{ if(ar[0]=='g'&&ar[1]=='r'&&ar[2]=='e'){b=5;}
     else{ if(ar[0]=='b'&&ar[1]=='l'&&ar[2]=='u'){b=6;}
     else{ if(ar[0]=='v'&&ar[1]=='i'){b=7;}
     else{ if(ar[0]=='g'&&ar[1]=='r'){b=8;}
     else{ if(ar[0]=='w'&&ar[1]=='h'){b=9;}
     else{ if(ar[0]=='y'&&ar[1]=='e'){b=4;}
     else{b=10;};};};}};}}}}}
     printf("\t%d",b);


     printf("\n\nThird Band\t");
          gets(ax);
     if(ax[0]=='b'&&ax[1]=='l'&&ax[2]=='a'){c=0;}
     else{ if(ax[0]=='b'&&ax[1]=='r'){c=1;}
     else{ if(ax[0]=='r'&&ax[1]=='e'){c=2;}
     else{ if(ax[0]=='o'&&ax[1]=='r'){c=3;}
     else{ if(ax[0]=='g'&&ax[1]=='r'&&ax[2]=='e'){c=5;}
     else{ if(ax[0]=='b'&&ax[1]=='l'&&ax[2]=='u'){c=6;}
     else{ if(ax[0]=='v'&&ax[1]=='i'){c=7;}
     else{ if(ax[0]=='g'&&ax[1]=='r'){c=8;}
     else{ if(ax[0]=='w'&&ax[1]=='h'){c=9;}
     else{ if(ax[0]=='y'&&ax[1]=='e'){c=4;}
     else{c=10;};};};}};}}}}}
     printf("\t%d",c);


     d=10*a;
     e=d+b;
     f=pow(10,c);

     Resistance=e*f;

     printf("\n\nResistance is: %dohm",Resistance);
     printf("\n\ndo you want to repeat (y/n)? ");
     getch(azim[3]);
     }


     while(azim[0]!='n');

     getch();

 }





If you face any kind of problems please inform me in comments. And if you need any kind of coding about engineering software tell us, our team will try to solve it.

No comments:

Post a Comment

wait_i_will_reply_within_24_hours

Post a Comment