Resistor color code reader
Author:- A.Chermarajan.
Author Email:- chermarajan [at] yahoo.co.in
Description:- This program is for resistor color code useful for basic Electronic students.Just mention the color code for resistor program gives the exact value for it. If the value might be greater itself onvert to Kilo or Mega ohm as per.
Code :
#include
#include
#include
#include
void main()
{
start:
clrscr();
int i;
float r=0;
char a[10],b[10],c[10],d[10];
cout<<"_____________________________!Color code Reader
1.0!____________________________";
cout<<"Design by:A.Cherma rajan.BE.,";
cout<<"Enter your Resister colour code here
";
cout<<"Code 1:";
cin>>a;
cout<<"Code 2:";
cin>>b;
cout<<"Code 3:";
cin>>c;
{
if(!(strcmp(a,"black")))
r=0;
else if(!(strcmp(a,"brown")))
r=10;
else if(!(strcmp(a,"red")))
r=20;
else if(!(strcmp(a,"orenge")))
r=30;
else if(!(strcmp(a,"yellow")))
r=40;
else if(!(strcmp(a,"green")))
r=50;
else if(!(strcmp(a,"blue")))
r=60;
else if(!(strcmp(a,"violet")))
r=70;
else if(!(strcmp(a,"gray")))
r=80;
else if(!(strcmp(a,"white")))
r=90;
}
{
if(!(strcmp(b,"black")))
r+=0;
else if(!(strcmp(b,"brown")))
r+=1;
else if(!(strcmp(b,"red")))
r+=2;
else if(!(strcmp(b,"orenge")))
r+=3;
else if(!(strcmp(b,"yellow")))
r+=4;
else if(!(strcmp(b,"green")))
r+=5;
else if(!(strcmp(b,"blue")))
r+=6;
else if(!(strcmp(b,"violet")))
r+=7;
else if(!(strcmp(b,"gray")))
r+=8;
else if(!(strcmp(b,"white")))
r+=9;
}
{
if(!(strcmp(c,"black")))
r*=1;
else if(!(strcmp(c,"brown")))
r*=10;
else if(!(strcmp(c,"red")))
r*=100;
else if(!(strcmp(c,"orenge")))
r*=1000;
else if(!(strcmp(c,"yellow")))
r*=10000;
else if(!(strcmp(c,"green")))
r*=100000;
else if(!(strcmp(c,"blue")))
r*=1000000;
else if(!(strcmp(c,"violet")))
r*=10000000;
else if(!(strcmp(c,"gray")))
r*=100000000;
else if(!(strcmp(c,"white")))
r*=1000000000;
}
cout<<"Colour code value for your Resister:";
if(r/999999>=1)
cout<
cout<
cout<
char ch=234,op;
cout<
Continue (y/n):";
cin>>op;
if(op=='y')
goto start;
else
exit(1);
getch();
}
1 comment:
Hai friend,
This is my code. This is a old version, after i further optimized this code using basic pointer concept. you can also try
Post a Comment