EmbLogic's Blog

error: expected expression before double

#include<stdio.h>

int main()
{
double d = 3.2,x;
int i = 2,y;
x = (y=d/i)*2;
printf(“%g\t%g\n”,double(x),double(y));
y = (x=d/i)*2;
printf(“%g\t%g\n”,double(x),double(y));
y = d*(x=2.5/d);
printf(“%g\n”,double(y));
x = d*(y=((int) 2.9+1.1/d));
printf(“%g\t%g\n”,double(x),double(y));
return 0;
}

2 Responses to error: expected expression before double

  1. siddarth says:

    Make changes in the code as shown below:
    printf(“%g\t%g\n”,(double)x,(double)y);
    printf(“%g\t%g\n”,(double)x,(double)y);
    printf(“%g\n”,(double)y);
    printf(“%g\t%g\n”,(double)x,(double)y);

    Whenever we want to do any typecasting from one data type to another the general syntax is:
    (data type)variable_name;

  2. ashutosh says:

    thanks sir

Leave a Reply to ashutosh Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>