0

I am just trying to do a problem in C that may give us 64 bit integers. It cannot support in displaying such big number. So what can i do?

#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ long int a,b,n,c; scanf("%ld %ld %ld",&a,&b,&n); n-=2; while(n--){ c=(b*b)+a; a=b; b=c; } printf("%ld",c); return 0; } 
1
  • Use type long long which is at least 64-bit. Commented Jul 21, 2015 at 2:15

1 Answer 1

2

You should use %lld.

scanf("%lld %lld %lld",&a,&b,&n); printf("%lld",c); 

But long int is not an 64bit integer. Use long long int or int64_t from inttypes.h.

Sign up to request clarification or add additional context in comments.

5 Comments

To be clear, a, b, c and n must have type long long int in order to use %lld. There is a different format specifier for int64_t.
long int might be a 64 bit integer, but it isn't required to be one.
The "%lld" format specifier tells scanf or printf that the units are long long int, yes. Don't use "%lld" in conjunction with int64_t; use "%"PRId64 for printf or "%"SCNd64 for scanf.
int64_t may be defined in stdint.h, not inttypes.h. The latter just contains the format specifiers for the types defined in stdint.h.
1002992 integer length......if 123 has a length of 3....can i display upto that extent

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.