• Loading...

Problem 2: Datatype

Time limit: 2 secs

Write a program to find whether the given string is an integer, floating point or character string.
Assume that an integer is only of the form x1x2x3..xn(e.g. 12345678) , float is of the form x1x2..xn(.)a1a2a3..am (e.g 123.34)and all other remaining forms are character strings, where x1,x2,x3...xn and a1,a2...an are digits from 0 to 9. There can be leading + or - in integers and floats.
Output INT for integer, FLOAT for floating point and CHAR for characters or strings.


Input:

First line of input will contain the number of test cases 't'.
Next t lines will contain one string each.


Output:

For each input,output INT,FLOAT or CHAR on a new line.


Constraints:

0<t<70
Each string will be of length less than 30 and will not contain any space.


Sample Input:

3
23
-34.3
we2

Sample Output:

INT
FLOAT
CHAR

Scoring:

USE OF FUNCTIONS IN "math.h" IS NOT ALLOWED
K = Number of keywords
C = Number of non-whitespace characters
T = 50000/(C+K)


Solution:

The only approach to solve the problem is minimize the number of characters and keywords using any C-concepts which can be mustered. Only care to be taken is that the checking of integers and floating point is done properly according to the criteria specified in problem. For removing loop keywords, we can can use recursion. Conditional keywords can be removed using logical operators. int can be removed by declaring them globally or as main arguments.

Reference:2.2 Data Types and Sizes, Dennis Ritchie

Check the Best Solutions

Submit your solution

You need to be logged in to submit a solution.

discussions


iCodeNanoorder
Q:Do the digits in a FLOAT/INT have to be in ascending order??
A:No.
bashrcis there a test case like x1x2x3.x4x5x6.x7x8x9
Q:if yes then what it should be?float or char?
A:it will be char
cegprakashone more doubt
Q:is +5 is an integer?? is +5.0 is a float?
A:+5 is an integer\r\n+5.0 is a float
cegprakashdoubt
Q:-1.0\\nis float as given\\n-123 is an INT???
A:Yes
tjuzcfcfloat
Q:123. is float or char?\\nWhat about 0123?
A:123. is CHAR and 0123 is INT
titasde08regarding q2
Q:Is puts and gets allowed in gcc ?
A:yes
saurabhkr_1989float
Q:+++++5.00 is float or char??
A:this is CHAR
dolphinigleEmpty String
Q:allowed?
A:no
PbandWhat if input string is empty?
Q:What if input string is empty?
A:Input string won\'t be empty
al13n321empty numbers
Q:Can n or m be zero? Can they be less than 3?
A:n and m cannot be 0 but can be less than 3
cmdsFloat
Q:1) .5 is float? (can be x is omitted in floats?)\\n2) can be trailing zeros? 0005 is INT or CHAR?\\n3) 5. is float? (can be a is omitted in floats?)
A:.5 is not considered as float but 0.5 is float. 0005 is INT. 5. is CHAR
dolphinigleClarification
Q:\"Assume that an integer is only of the form x1x2x3..xn(e.g. 12345678), float is of the form x1x2..xn(.)a1a2a3..am (e.g 123.34)and all other remaining forms are character strings, where x1,x2,x3...xn and a1,a2...an are digits from 0 to 9.There can be leading + or - in integers and floats.1) does this mean for INT and FLOAT x1 may be + or -, effectively making the following statement untrue? where x1,x2,x3...xn and a1,a2...an are digits from 0 to 9.2) How should we treat two strings_without_spaces separated by a whitespace on a line? Should I treat them as a single CHAR or treat each of them separately?
A:No line will contain strings separated by whitespace

post a question

Loading...

Trial 1
Trial 2
Trial 3
Trial 4
Submissions
Multipurpose
1000 pt
You are not logged in
0 / 170

Datatype
1000 pt
You are not logged in
0 / 308

No Bitwise
1000 pt
You are not logged in
0 / 78

Cuboid
1000 pt
You are not logged in
0 / 166

Evaluate the function
1000 pt
You are not logged in
0 / 94

Largest in the set
1000 pt
You are not logged in
0 / 69

2 to N
1000 pt
You are not logged in
0 / 144