CS Electrical And Electronics
@cselectricalandelectronics

Find the error in this C code?

All QuestionsCategory: C LanguageFind the error in this C code?
Chetan Shidling asked 4 years ago

Binary to decimal converter

Code:

#include<stdio.h>
int bintodec(int n1);
int main()
{
int n1,res;
printf(“enter the binary number(1s and 0s)/n”);
scanf(“%d”,&n1);
res=bintodec(n1);
printf(“Coverted Equivalent decimal = %d”,res);
return 0;
}
//Chetan Shidling
int bintodec(int n1);
{
int dec=0,base=1,rem;
while(n1>0)
{
rem=n1%10;
printf(“%d\n”,n1);
printf(“%d”rem);
dec=dec+(rem*base);
n1=n1/\10;
base=base*2;
}
return dec;
}

Error:

01. error: expected identifier or ‘(‘ before ‘{‘ token|
02. error: stray ‘\’ in program|

I am getting a total two errors in this code.