Click here to Skip to main content
15,910,787 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

[^]s

this is the problem from hackerearth.com

how can we take 10^100 as input in c and c++.

What I have tried:

long long int but its range is not that much
Posted
Updated 27-Nov-17 7:31am
Comments
CHill60 27-Nov-17 11:53am    
Double?
jatinp510 27-Nov-17 11:54am    
not working
Dave Kreskowiak 27-Nov-17 12:02pm    
Did you want to define "not working" because that's not a problem description. That's a complaint.

What do you see, what errors do you get, any unexpected values in the variables you're using, ...?

We also can't see your code and that's a big part of getting a problem solved.
jatinp510 27-Nov-17 12:06pm    
i guess double can't store value of 10^100.

doubles don't have that much range.
jeron1 27-Nov-17 12:24pm    
I imagine you are going to have to use custom big integer class like GitHub - sercantutar/infint: Arbitrary-Precision Integer Arithmetic[^], you could google bigint to see what else may exist,

1 solution

Read carefully the requirements. They asked you to establish if a number can be exactly divided by two (is even). You know, you have to test only the last digit. Hence you don't even need an array: read and discard all but last digit, then test the last digit for even or odd parity.
 
Share this answer
 
Comments
jatinp510 27-Nov-17 13:36pm    
#include <stdio.h>
#include<string.h>

int main()
{


int t,len,u;
scanf("%d",&t);
while(t--)
{
char a[101];
scanf("%s",&a);
len=strlen(a);
u=a[len-1];

if(u%2==0)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

sir,i have tried this.
is this correct method.
CPallini 27-Nov-17 13:38pm    
This is one of the possible solutions.
jatinp510 27-Nov-17 13:42pm    
can u suggest me other solutions.
what else i can try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900