hi
This is Poornima.L
any one can u help me
how to convert double to int ????
int int_var=(int)double_var;
wen i give the above stmt
i get floating point error:abnormal termination in my console screen
help me out

One example:

#include <stdio.h>

int main() {
int i, n ;
double d = 0.0;
d = 3.33 * 3;
n = d;
printf("\n N=%d  D=%lf", n, d);

i = getchar(); ++i;
return 0;
}

Note how anything after the decimal point is truncated.

>>i get floating point error:abnormal termination in my console screen

Must be some other problem in your program because the code you posted should not give you that error. Post the entire program so that we can see what you did.

The prob is we have to enter a 3 digit no (n) we have to find 2^n+1 and also we have to find that (2^n+1) is prime or not .if it is not prime then what are its factors

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n,g=0,j,r,m;
double a=1.0,b,f,c;
clrscr();
printf("enter the 3 digit no");
scanf("%d",&n);
for(i=0;i<n;i++)
{
a=2*a;
}
printf("n%lf",a);

c=a/2;
m=(int)(c);
printf("%d",m);
}

for(j=2;j<c;j++)
{
f=b/j;
r=b-(f*j);
//printf("%d",r);
if((r)==0)
{
g=1;
if(j>0)
printf("%dn",j);
}
}
if(g==0)
printf("it is  prime number");
getch();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.