Declaring variables. I r newb.

Posts 16–30 of 36 · Page 2 of 3
It's not wrong just different They probably didn't explain what they're showing you there which would've covered why they can (read: will ) be different.

Basically those two lines are printing the memory address a is pointing to in decimal and hex (%d = print decimal, %p = print pointer, which outputs in hex)

0x403000 is the same as 4206592 decimal - those two values will be different for everyone
Quote Originally Posted by B1ackAnge1 View Post
It's not wrong just different They probably didn't explain what they're showing you there which would've covered why they can (read: will ) be different.

Basically those two lines are printing the memory address a is pointer to in decimal and hex (%d = print decimal, %p = print pointer, which outputs in hex)

0x403000 is the same as 4206592 decimal - those two values will be different for everyone
Alrighty! Thank you very much for clearing that up, will add it to my notes. I can now start the final program for chapter 1. Thank you B1ackAnge1.
YAY! XD
Sorry mods for double posting but eh. LOL, this is an accomplishment for me I guess.
Chapter 1 done, I did a different final assignment for it. Using pretty much everything I learned from chapter one. If anyone has any constructive criticism then please feel free to list some, I'm new to C. Comments are welcome ofc.
Code:
#include <stdio.h>
#include <conio.h>
int main()
{
    //Declarations
    int a,b,c,f;    
    float g;
    char *k;
    //Assignments
    a=1993;
    b=30;
    c=10;
    g=4.5;
    k="I'm learning C, and I just finished chapter 1 using 1 printf statement!";    
    //Output
    printf("Hi, my name is AJ.\nI was born in %d,%d,%d.My fav. number is %.0f.\n%s", a,b,c,g,k );
    getch();
}
Chapter 1\10. XD
Quote Originally Posted by crushed View Post
YAY! XD
Sorry mods for double posting but eh. LOL, this is an accomplishment for me I guess.
Chapter 1 done, I did a different final assignment for it. Using pretty much everything I learned from chapter one. If anyone has any constructive criticism then please feel free to list some, I'm new to C. Comments are welcome ofc.
Code:
#include <stdio.h>
#include <conio.h>
int main()
{
    //Declarations
    int a,b,c,f;    
    float g;
    char *k;
    //Assignments
    a=1993;
    b=30;
    c=10;
    g=4.5;
    k="I'm learning C, and I just finished chapter 1 using 1 printf statement!";    
    //Output
    printf("Hi, my name is AJ.\nI was born in %d,%d,%d.My fav. number is %.0f.\n%s", a,b,c,g,k );
    getch();
}
Chapter 1\10. XD
Great job =D. What book are you reading?
Congratz crushed... I hope you keep it up.
Quote Originally Posted by why06jz View Post
Congratz crushed... I hope you keep it up.
Thank you very much, Sir. :P
Also thanks for helping out.

Quote Originally Posted by zeco View Post
Great job =D. What book are you reading?
Thank you! And thanks for the help as well!
I am reading, 'Learn C In Three Days' by Sam A. Abolorous. Pretty old book, but hey. It has what I need to know. :]
Quote Originally Posted by crushed View Post
Thank you very much! And I'm honored to be on your respect list.
I'm glad, considering even though I'm new, people are friendly and really helpful. :3
My pleasure :P The reason we are helpfull(for you) is because we get around 20-30 people that dont have a clue on what their talking about(making a dll with notepad eh dylan...), you're the first new person that did not fall in the catagory 'I C+p HAX FOAR BE LEEB', so we're gonna turn you into a full fledged haxxor

ill send you a PM with my email in case you want help with anything hack related

Quote Originally Posted by Hell_Demon View Post
My pleasure :P The reason we are helpfull(for you) is because we get around 20-30 people that dont have a clue on what their talking about(making a dll with notepad eh dylan...), you're the first new person that did not fall in the catagory 'I C+p HAX FOAR BE LEEB', so we're gonna turn you into a full fledged haxxor

ill send you a PM with my email in case you want help with anything hack related

I has added you on MSN. :P Whee, I'm starting chapter 2 as soon as I'm done the rest of my hw. xD
Harro Guys. I know I've been absent for a couple of weeks....but my computer was fried. :]
Don't ask how, but getting a new one soon.

Anyways, I'm back...and for anyone that cares. I've started chapter 2 in the book.
Just learned how to use address pointers.
Code:
#include <stdio.h>
#include <conio.h>
int main()
{
    //Declarations
    float x,y,z;
    scanf("%f", &x);    // & means address pointer. Required for scanf functions.
    scanf("%f", &y);
    //Assignments
    z=x+y;
    //Output.
    printf("The sum of the two numbers:%.2f\n", z);
    getch();
    }
REASON: For bumping this thread is cause I didn't wanna make a new one.. so yeah.
Yay =). You've been away for less than a week xD. And i told you, you shoulda gotten thermal paste >_>
Quote Originally Posted by zeco View Post
Yay =). You've been away for less than a week xD. And i told you, you shoulda gotten thermal paste >_>
Oh dude, it wasn't the paste. I woke up in the morning, THE NIGHT BEFORE, I forgot to plug the fan back in. Turned it on in the morning, forgot the fan wasn't plugged in, overheated, and BAM.
Haha still an amusing way to fry a puter
return 0;
and idk why they post such... GOD someone needs to redirect them to the FAQ or beginner guide section when they click on C++
Quote Originally Posted by crushed View Post
Hallopeople. :O

I'm new to C, and C++. Reading a pretty old book as well, written...no idea when. Anyways, the book is by Sam A. Abolorous. It's called 'Learn C In Three Days'. Possible, not possible, I don't know considering I wanna take my time with programming and not burn through it. Rushing it, learning it, then when you try to apply it to something else, your like what? No, I wanna learn it properly so I can apply it wherever needed.

Anyways, back to the question. o_o So the book has a code...and it gives an example of declaring variables. I tried inputting that code, TRIED modifying it and still no luck. I get errors. I'll post the code I tried. Keep in mind I used MICROSOFT VISUAL C++.

The code from the book.

Code:
*****#include <stdafx.h>
#include <stdio.h>
main()
{
	//Declarations.
	int a;
	float b;
	//Assignment.
	a=1024;
	b=512;
	//Display output.
	printf("%d\n",a);
	printf("%f\n",b);
}
Thanks to whoever helps me out. ^_^

EDIT: I dunno how to use the code thingy...so I apologize about that. ._.
EDIT: Thanks Zeco for teaching me how to put the code.

ALRIGHT, whee. I used DevC++, and it worked. I somewhat changed the script so it pauses for a while. Thanks Why06 for the tip. FINAL:
Code:
#include <stdio.h>
#include <conio.h>

int main()
{
	//Declarations.
	int a;
	float b;
	//Assignment.
	a=1024;
	b=512;
	//Display output.
	printf("%d\n",a);
	printf("%f\n",b);
    getch();
system("PAUSE");
return 0;
}
the red is what i changed wouldn't this work so you could see the results before it ends?
Quote Originally Posted by Matrix_NEO006 View Post
return 0;
and idk why they post such... GOD someone needs to redirect them to the FAQ or beginner guide section when they click on C++
Wasn't really asking for help. o_o Lol, you do realize I know that there's a FAQ section, and Idk if you've read the last few posts, but I just turned this thread into a progress section for myself. Thanks anyways though. As for the declaring variables, I've got the hang of that so yeah, thanks guys. :P


Quote Originally Posted by cnttuchme View Post
the red is what i changed wouldn't this work so you could see the results before it ends?
Ooh, btw. xD Yeah, I know system pause works, but I prefer to use getch();.
Thanks though. :]
Posts 16–30 of 36 · Page 2 of 3
This thread is closed for replies.

Similar Threads

Talk with us