Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > newbie...please help!

Reply
Thread Tools

newbie...please help!

 
 
cj
Guest
Posts: n/a
 
      01-11-2006
Hello! I need some major help! I took this computer programming class
to learn more about computers. Picked this class because it had a
section to learn web page design but now I have to complete the section
about the c language and I have no clue! I'm totally stressing out
because it is blowing my mind and if I don't complete all the lessons I
don't receive a certificate of completion. Please someone help me! Here
are a few questions:

What is the length returned by the "strlen()" function?
char dog[80]

strcpy (dog,"I am a dog");
strlen (dog);

Which animal will be replaced with "fly" in the following code
fragment?
char animals [ ] [3][6] = {
"cow","pig","dog","rat","bat","hen","eel","ant","c at","ox","owl","yak","ram","bee","doe"}
strcpy(animals [2] [1] , "fly");

What is the difference between the 7's in thse two statements?
long cat [7];
cat[7] = 5L


I will only ask 3 for now until I see the response I get from anyone
willing to help. I appreciate any help! Thanks

 
Reply With Quote
 
 
 
 
Sandeep
Guest
Posts: n/a
 
      01-11-2006
hmm ... I would be surprised if you get answers to these questions
here. My suggestion would be to fire up your friendly compiler and type
simple programs to see what answers you get for your queries.

This can get you started.
#include<iostream>

using namespace std;

int main()
{
char dog[80];

strcpy(dog,"someone is a dog");
cout<<"Length of dog is: "<<strlen(dog)<<endl;

return 0;
}


cj wrote:
> Hello! I need some major help! I took this computer programming class
> to learn more about computers. Picked this class because it had a
> section to learn web page design but now I have to complete the section
> about the c language and I have no clue! I'm totally stressing out
> because it is blowing my mind and if I don't complete all the lessons I
> don't receive a certificate of completion. Please someone help me! Here
> are a few questions:
>
> What is the length returned by the "strlen()" function?
> char dog[80]
>
> strcpy (dog,"I am a dog");
> strlen (dog);
>
> Which animal will be replaced with "fly" in the following code
> fragment?
> char animals [ ] [3][6] = {
> "cow","pig","dog","rat","bat","hen","eel","ant","c at","ox","owl","yak","ram","bee","doe"}
> strcpy(animals [2] [1] , "fly");
>
> What is the difference between the 7's in thse two statements?
> long cat [7];
> cat[7] = 5L
>
>
> I will only ask 3 for now until I see the response I get from anyone
> willing to help. I appreciate any help! Thanks


 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      01-11-2006
* cj:
> Hello! I need some major help! I took this computer programming class
> to learn more about computers. Picked this class because it had a
> section to learn web page design but now I have to complete the section
> about the c language


This group is concerned with C++, not C: you're off-topic, post in
[comp.lang.c].


>and I have no clue! I'm totally stressing out
> because it is blowing my mind and if I don't complete all the lessons I
> don't receive a certificate of completion. Please someone help me!


Homework is off-topic also in [comp.lang.c].

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      01-11-2006
"cj" wrote:

> Hello! I need some major help! I took this computer programming class
> to learn more about computers. Picked this class because it had a
> section to learn web page design but now I have to complete the section
> about the c language and I have no clue! I'm totally stressing out
> because it is blowing my mind and if I don't complete all the lessons I
> don't receive a certificate of completion. Please someone help me! Here
> are a few questions:

<snip>

> What is the difference between the 7's in thse two statements?
> long cat [7];
> cat[7] = 5L


The first one creates an array with space to store 7 long ints.

The second attempts to write the value 5, which is specified as being a long
int by the L, into an array named cat. Since the array elements of *this*
cat are numbered 0 to 6 inclusive, there is no legitimate place to put the
5. If you are lucky the program will bomb, if it doesn't fail now you may
be in for some nasty surprises at a later time. The C language is perfectly
willing to do what it's told, as here. That was part of its early quirky
charm contributing to its success..

Now that you are in the course, read the syllabus again. Is it an honest
description of what is happening in class? Sounds fishy to me. Or else your
reading of the syllabus when you signed up was kind of a skim instead of a
read.


 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      01-11-2006

"cj" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello! I need some major help! I took this computer programming class
> to learn more about computers. Picked this class because it had a
> section to learn web page design but now I have to complete the section
> about the c language and I have no clue! I'm totally stressing out
> because it is blowing my mind and if I don't complete all the lessons I
> don't receive a certificate of completion. Please someone help me! Here
> are a few questions:
>
> What is the length returned by the "strlen()" function?
> char dog[80]
>
> strcpy (dog,"I am a dog");
> strlen (dog);
>
> Which animal will be replaced with "fly" in the following code
> fragment?
> char animals [ ] [3][6] = {
> "cow","pig","dog","rat","bat","hen","eel","ant","c at","ox","owl","yak","ram","bee","doe"}
> strcpy(animals [2] [1] , "fly");
>
> What is the difference between the 7's in thse two statements?
> long cat [7];
> cat[7] = 5L
>
>
> I will only ask 3 for now until I see the response I get from anyone
> willing to help. I appreciate any help! Thanks


You'll find the answers in your textbook.

Note that this newsgroup is about C++, not C. However,
all the constructs above are common to both C and C++.

Yes, we're very willing to *help*, but *help* means
that *you* are doing something too. So review your
book, come back (or visit comp.lang.c or alt.comp.lang.learn.c-c++)
and post your attempts at answers, and we'll tell you if they're
correct, and if they're not, we'll help you make them correct.

-Mike



 
Reply With Quote
 
cj
Guest
Posts: n/a
 
      01-11-2006
Sorry to bother you! I did post in the comp.lang.c group but thought it
wouldn't hurt to post here also...excuse me ...it won't happen again

 
Reply With Quote
 
cj
Guest
Posts: n/a
 
      01-11-2006
The textbook is confusing me compared to my workbook. And I am trying,
that's why I am so stressed. But hey Mike thanks for taking time to
reply! I think I can get help from others that aren't so rude and fyi:
I did post in the comp.lang.c group so I'm not all that stupid. Just
didn't think it would hurt to post here too but I guess I was wrong.

 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      01-11-2006
cj wrote:

> The textbook is confusing me compared to my workbook. And I am trying,
> that's why I am so stressed. But hey Mike thanks for taking time to
> reply! I think I can get help from others that aren't so rude and fyi:
> I did post in the comp.lang.c group so I'm not all that stupid. Just
> didn't think it would hurt to post here too but I guess I was wrong.


I suspect that the C group will be much more grumpy than this one.

What I did for my first C class was simple: I sat down one weekend and read
the friggin textbook, from near the beginning until after the middle,
straight through.

Only after this fun did I try to write programs, and hence try to use the
tutorial as a reference for quick lookups. And I got to use a lot of
features, such as strlen(), right away without looking them up.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
Alan Johnson
Guest
Posts: n/a
 
      01-11-2006
osmium wrote:
> "cj" wrote:
>>What is the difference between the 7's in thse two statements?
>>long cat [7];
>>cat[7] = 5L

>
>
> The first one creates an array with space to store 7 long ints.
>
> The second attempts to write the value 5, which is specified as being a long
> int by the L, into an array named cat.


I prefer a more literal interpretation of the question.

7 - 7 = 0

Therefore, the answer is 0.
 
Reply With Quote
 
JustBoo
Guest
Posts: n/a
 
      01-11-2006
On Wed, 11 Jan 2006 03:14:12 GMT, "Mike Wahler"
<(E-Mail Removed)> wrote:

"Soca, his eyes open!" "Mirab, with sails unfurled."

>Yes, we're very willing to *help*, but *help* means
>that *you* are doing something too. So review your
>book, come back (or visit comp.lang.c or alt.comp.lang.learn.c-c++)
>and post your attempts at answers, and we'll tell you if they're
>correct, and if they're not, we'll help you make them correct.
>-Mike


This should be in the FAQ. (Okay, it probably already is...
somewhere... worded differently... under a nebulous title...
somewhere... in the FAQ.)

You da' man! Um, sorry Mike, I'm a plonked outcast so I apologize for
the trouble my compliment might cause you.

[In a quiet humble voice]
'Flatter me, and I may not believe you. Criticize me, and I may not
like you. Ignore me, and I may not forgive you. Encourage me, and I
will not forget you.' -- William Arthur Ward
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments