+2

what are the variables type for the following:

Variable types for the following: Roll Name Email Add Contact no Address Gender Age Section Course I am planning to make an Directory

c

2/13/2020 7:51:59 AM

Alby

28 Answers

New Answer

+9

I am not telling you directly because this is something that should be absolutely clear to you. Think logically. What a roll number should be? a char, a double, float, int, string. How do you use it. How do you manipulate it. Think about these things about all the fields you want to use.

+6

Alby https://en.m.wikipedia.org/wiki/C_data_types

+5

Since you are learning, i think it's best if you can tell us what variables types you would be using for different fields and why. You will be corrected if you are wrong. But this is something you must be clear before creating any dictionary or something.

+3

Are you asking what/which data type is suitable for those fields? (Edited)

+3

What do you mean best variables? Do you mean variable types? Kindly explain it clearly.

+3

Alby Is there a code you can share with us here? I agree with ~ swim ~, I'd like to see how the code looks like also ... Basic hints: * Anything string like, go with char[]. * Age shouldn't accept negative, so unsigned integer. Not sure about other fields, that's why I prefer to see your code first ...

+3

Alby I have read the code. This far, I see that the problem is use of inappropriate format specifier and variable types. If you can, please add some sample data in the code so I can test further on.

+2

https://code.sololearn.com/cGpPIl5WvfCu/?ref=app Ipang WhyFry

+2

~ swim ~ thanks

+2

Ipang i aleeady sent you some sample

+2

int ROLL; char NAME[20]; char EMAIL[25]; int CONTACT_NO; char ADDRESS[50]; char GENDER; int AGE; char SECTION[2]; char COURSE[20]; for string input, in scanf, no need to put &. Is this may be you are searching..,. ? (if it not solved) ?

+2

Jayakrishna for CONTACT_NO, I would have used a string, I.e. char CONTACT_NO[15] or something similar as you can't really do numeric operations on contact numbers.

+2

Also for gender, would it be better to use an enum as there are only a finite number of genders (whatever that number is this day and age)? The downside of using an enum is that if you read this data as user input, you will need an additional function to convert it from a char perhaps to the enum.

+1

the 3 best variables in this case will be: humanity (range from 0 to 10) sense of humor (range from 0 to 10) credibility(boolean True or False)

+1

WhyFry I see that you're advanced in this field. If you don't have a good thing to say just leave this thread alone I am just a beginner. Ipang ~ swim ~ variable types

+1

~ swim ~ I am using csv for the saved inputs but i am still confused about variable types i tried using trial and error boolean double float etc for the different fields but it the output was differrent so i tried asking here for the proper variable types for each of the following written above

+1

I think all data should have string type.If you need to work with there values which can be integer you can transform them.

+1

WhyFry Can i combine all the char and all the integers Like Int Contact Age Char Roll Name

+1

~ swim ~ I got your point can you senf me a file or link so that i can study variable types

+1

Use structure