Help regarding gmp programme.

Sisyphus sisyphus1 at optusnet.com.au
Sun Mar 1 13:13:08 CET 2009


----- Original Message ----- 
From: "Krishna Prasad" <kprasad.iitd at gmail.com>

> #include<iostream>
> #include<stdio.h>
> #include<gmp.h>
> using namespace std;
> int
> main(void)
> {
> mpz_t a,b,c;
> mpz_init(c);

You also need to :
   mpz_init(a);
   mpz_init(b);

> gmp_printf("enter the large no.");

For clarity, make that:
   gmp_printf("enter the first large no.");

> gmp_scanf("%Zd",a);

And then also include:
   gmp_printf("enter the second large no.");

> gmp_scanf("%Zd",b);
> mpz_add(c,a,b);
> gmp_printf("Sum is %Zd",c);
> }

That's possibly all that's wrong. If you remove the '#include<iostream>' and 
the 'using namespace std;' the program builds and executes fine as a C 
program. (Beyond that, I haven't checked.)

Cheers,
Rob




More information about the gmp-discuss mailing list