1. ## hello. basic questions

hey guys and girls.... if any.

i have some basic questions ....... study guide our teacher gave us.

1. in this line what part is directly related to declaring the variable....
and also what part is related directly to initializing the variable.....

double age = 0;

2. i have to declare and initialize a variable to suit this data. ill show you what i put...
correct me if you know better

shoe size ------------------- int size = 0;
price airline ticket ----------- double price_ticket = 0;
grade on a homework ------------------ char = ' ' = A is best, B is good , C is average
number of letters in a word ------------------ dont know
a letter of the alphabet -------------------- dont know

3. i have to give preprocessor directives that show

- PI - #include ---------------------------------------<math.h> --- i know that one
- number minutes in an hour ------------------------- dont know

4. what are the advantages to using a constant as opposed to a variables in a code

5. what are the results of these when done in c

456.5/59 =
25/45 =
(double)65/59
62/45.6
(int)((int)10.4/(double)4)

2. So tell us what you know first. We can't solve your homework for you.
I'll tell you something, however. There are 3 basic groups of variables available. They are:

Integer - numbers. For example, 10.
Char - characters or strings. Used to hold letters like 'a' or "hello world".
Floating point - numbers with decimals, like 10.50.

Knowing these types should make you able to answer the question 2 questions.

3. hahahahaa its not homework.

i did what i could, the rest is like wierd to me.

i know theres three types of variables.... did i do the first three right?? for question two...

for the last section i dont know if shes looking for the answer as int or double form

or if she just wants us to put int, double, whatever...

4. You said it yourself:
study guide our teacher gave us.
The first three of q2 are fine.
As for the last, these numbers will give an answer in either double or int depending on what type of numbers are used to divide with each other.
If you divide a double with int, the answer is double, for example.

5. its a study guide... meaning if we want to learn more, practice with this worksheet.

we dont turn it in an dits not homework. i just need the extra practice.

for part 2 what are the last ones

for part three what are the last 2 ?

6. I won't give direct answers but here are some pointers:

1. in this line what part is directly related to declaring the variable....
and also what part is related directly to initializing the variable.....
double age = 0;

As you can see here, two things are happening. The variable age is being created as a double, and secondly, 0 is being assigned to it. Once part of this is the declaration, the second is the initialization.

2. i have to declare and initialize a variable to suit this data. ill show you what i put...
correct me if you know better

shoe size ------------------- int size = 0; // I dont know if a shoe size of 0 exists, also there may be half sizes.
price airline ticket ----------- double price_ticket = 0; // I agree
grade on a homework ------------------ char = ' ' = A is best, B is good , C is average // I agree
number of letters in a word ------------------ dont know // *Number* of letters...
a letter of the alphabet -------------------- dont know // *A letter* of the alphabet

3. i have to give preprocessor directives that show

- PI - #include ---------------------------------------<math.h> --- i know that one // Correct in a way, however not what the teacher is looking for. I believe she wants #define (Note that #define is not complete by itself).
- number minutes in an hour ------------------------- dont know

4. what are the advantages to using a constant as opposed to a variables in a code
Google it or check the tutorials on this site.

5. what are the results of these when done in c
456.5/59 =
25/45 =
(double)65/59
62/45.6
(int)((int)10.4/(double)4)

Why not try them?

7. Alright, some pointers...

Originally Posted by johnnyboy
1. in this line what part is directly related to declaring the variable....
and also what part is related directly to initializing the variable.....

double age = 0;
You should know how to define a variable right? That means it's a variable definition plus some extra. It should be a cinch.

number of letters in a word ------------------ dont know
a letter of the alphabet -------------------- dont know
As you were already given a hint. The first one is a count. And what do you use for count? Integers, floating or characters?

3. i have to give preprocessor directives that show

- PI - #include ---------------------------------------<math.h> --- i know that one
- number minutes in an hour ------------------------- dont know
I'm not sure what it's after.

4. what are the advantages to using a constant as opposed to a variables in a code
A constant is a variable whose value cannot change. IF you try to change it, you get a compile error. So what are they good for?

5. what are the results of these when done in c

456.5/59 =
25/45 =
(double)65/59
62/45.6
(int)((int)10.4/(double)4
456.5 = double
25 = int
When dividing with a floating point, the result is always floating point (you should include the decimals).

8. so is "double age" - declaring

= 0; = initalizing

------------- or is it something simple like double = declaring , 0; = initlaizing

i still dont know the last 2 for part 2....... it ........es me off hahaha

............... as far as part three..... preprocessor directives

im pretty sure number one is #include <math.h>

the second two i dont know.... i dont think shes looking for #define PI 3.14159

but you may know better

Ill look up number 4

part 5......

tell me if these look right

1 ---- 7.74 or double
2 ------ 0 or int
3------- 1.10 or double
4 -------- 1.36 or double
5------- 2.5 or double

ok as far as that goes, should i add the default six characters at the end...

and...... is it int/double = int
or double/int = int

9. Originally Posted by johnnyboy
so is "double age" - declaring
Yes!
double age
is defining the variable and
= 0;
is initializing it.

i still dont know the last 2 for part 2....... it ........es me off hahaha
Then you'll have to think. The answer is right before your nose.
How would you could the number of numbers in the alphabet, for example?

but you may know better
I don't know what it means.

5------- 2.5 or double
This is not right.
The answer would typically be a double because one of the numbers is a double.
HOWEVER, the (int) at the beginning also tells the compiler to cast the result to an int. So no decimals.

ok as far as that goes, should i add the default six characters at the end...
Don't know what you mean?

and...... is it int/double = int
or double/int = int
double/int = double
int/double = double
int/int = int
double/double = double

10. hey thanks i guess. still not understanding it all....

its not homework, i just want to know.... pleaseeeeee. im not asking you to code me a program or anything! haha

so for part 5 it would be just 2, not 2.5

oh and.... the default chracters meaning like if i put %.2lf , any given number would be like 50.56, as opposed to default six places after decimal like

50.564323

so what im saying is should i add the rest of the decimals on the end.....

for part three, i need those preprocessor directives for the last two out of the three. i dont know them ... is avogadros in the math library....
i have no clue about the third one

11. Originally Posted by johnnyboy
hey thanks i guess. still not understanding it all....

its not homework, i just want to know.... pleaseeeeee. im not asking you to code me a program or anything! haha
I'm sure you have one!

This word:
"Word"
How many characters or letters are in there?

And

This:
a
Is a letter, right? So what format would you use to represent it inside a program?

so for part 5 it would be just 2, not 2.5
That's right.

oh and.... the default chracters meaning like if i put %.2lf , any given number would be like 50.56, as opposed to default six places after decimal like

50.564323

so what im saying is should i add the rest of the decimals on the end.....
Since there's no information saying how many decimals you should keep... well, you could run them inside a program to test and save the result. Be sure to tell what type of number the answer is too.

for part three, i need those preprocessor directives for the last two out of the three. i dont know them ... is avogadros in the math library....
i have no clue about the third one
I don't know what the original question meant.
Never heard of avogadros number either.
And what does "number minutes in an hour" have to do with preprocessor?

12. Originally Posted by johnnyboy
3. i have to give preprocessor directives that show

- PI - #include ---------------------------------------<math.h> --- i know that one
- number minutes in an hour ------------------------- dont know
take these
Code:
```#define PI 3.1415926535897
#define MINUTES_IN_HOUR 60```
Originally Posted by johnnyboy
hey guys and girls.... if any.
are there any girls

13. Yea i got everything now minus declaring initializing a variable for

number of letters in a word -------------- int letters_word = 0;

a letter of the alphabet --------------- char = ' '; any letter

Tell me if I did those right......

And whoever was right about the prep dir. for defining those variables was right, I found out..... Sorry

14. Yes, that's right. An integer is used for counting and a char is used for storing a character.