473,461 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PLEASE HELP ME ! PLEASE

I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C
Q1:
Write a program using malloc function. In which you take input from
user and allocate memory equal to square of this number. Which
multiply numbers and draw a table in the following format?

Hint: User enters 3 then program allocates equal to 9 integer
memories.

Output:1

Enter a single digit number:
2
The multiplication table of 2 is:
1 2
----------------
1| 1 2
2| 2 4

Output:2

Enter a single digit number:
4
The multiplication table of 4 is:
1 2 3 4
--------------------------------
1| 1 2 3 4
2| 2 4 6 8
3| 3 6 9 12
4| 4 8 12 16
Q:2
Write a macros in which swap two number without using 3rd variable and
then call
Macro in main function.

Hint: a=4, b=2 after swapping a=2, b=4.
KINDLY HELP ME TO MADE THIS PRGRAM GUIDE ME OR GIVE ME CODE OF THE
ABOVE PROBLEM

Jun 5 '07
62 2647
It is your own homework.Please do it yourself,or you will never make
progress.Trust yourself,please.

Jun 6 '07 #51
Richard wrote:
"Joachim Schmitz" <no*********@schmitz-digital.dewrites:
>"vubaboota" <vu*******@gmail.comschrieb im Newsbeitrag
news:11*********************@n4g2000hsb.googlegro ups.com...
>>I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C
Please don't shout at us. (hint: a sentence in all capitals is considered
shouteing in usenet)
Seems you had a serious problem in the classroom, paying attention to your
teacher.

Is this a new record?

14 posts.

9 of them are discourteous warnings about posting style, homework and
things being off topic.
And at least one is a complaint about the rest. Your point?

People have been schooling newbies on USENET etiquette since the dawn of
time, and I find the examples here pretty tame.

Do My Homework For Me queries get what they deserve, however.
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 6 '07 #52
Richard wrote:
Chris Hills <ch***@phaedsys.orgwrites:
>In article <87************@gmail.com>, Richard <rg****@gmail.comwrites
>>"Joachim Schmitz" <no*********@schmitz-digital.dewrites:

"vubaboota" <vu*******@gmail.comschrieb im Newsbeitrag
news:11*********************@n4g2000hsb.googleg roups.com...
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C
Please don't shout at us. (hint: a sentence in all capitals is considered
shouteing in usenet)
Seems you had a serious problem in the classroom, paying attention to your
teacher.
Is this a new record?
No
>>14 posts.
9 of them are discourteous warnings about posting style, homework and
things being off topic.
What has happened is we are getting far more posts of the "PLS DO MY
HOMEWORK URGENT" type.

The why dont "we" agree that only ONE reply is enough. Why is there the
constant feeding frenzy. Leave it alone to see if someone else replies
or ignore it.
Ok, we nominate you the person to reply to homework questions! Oh, wait.

Dude, USENET is a public forum that collects aggregate messages with no
quality of service or promise of timely delivery. "Just one reply"
doesn't work here.
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 6 '07 #53
vubaboota wrote:
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C
Q1:
Write a program using malloc function. In which you take input from
user and allocate memory equal to square of this number. Which
multiply numbers and draw a table in the following format?
Naive attempt:

Start with a large, fixed array. Service allocation requests out of
that large array, keeping track of the location and size of the
allocations. You will get points if you implement a "mark and sweep"
(or similar) algorithm that allows you to compact deallocations.

The rest seem pretty straight-forward, but the devil is in the details.
Sounds like your instructor wants you to use the basic skills you have
been taught, without getting bogged down in details like malloc() [which
can be confusing at first].

There is value in understanding that most any complex data structure can
be built off of an array.

--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 6 '07 #54
On Jun 5, 5:21 am, Richard Heathfield <r...@see.sig.invalidwrote:
Martin Ambuhl said:
Guru Jois wrote:
a^=b^=a; // could be still better than 3 statements.
No, it is horrid. The OP poster asked about swapping two number
[sic].
The '^' operator requires operands of an integer type. And that's
not
all that's wrong with it. This question has been beaten to death
before. If you really are committed to the silly XOR trick, check the
FAQ and the newsgroup archives to find out why you shouldn't be. You
might also find out why, even when the silly XOR trick works, writing
it as a single statement is a bad idea.

And if he must do this really stupid thing, he ought at least to do this
really stupid thing properly. The above is broken in more than the
usual number of ways.

Martin, I note from your reply and from another in this thread that both
Umesh and Guru Jois have started dispensing idiotic C advice. I guess
it's time for them to come *out* of my killfile. Things have come to a
pretty pass when one actually feels obliged to unplonk people for being
even more stupid than normal.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk
email: rjh at the above domain, - www.
Ya..do it. But it doesn't stop me from posting reply not I mind it.
If I'm wrong, I welcome the comment/objection from experts, b'cause I
always think - " learn from seniors ".

Bye

Guru Jois

Jun 7 '07 #55
Guru Jois said:

<snip>
Guru Jois wrote:
> a^=b^=a; // could be still better than 3 statements.
<snip>
If I'm wrong, I welcome the comment/objection from experts, b'cause I
always think - " learn from seniors ".
Okay, let's see if that's true.

1) Even if the expression which you gave did not exhibit undefined
behaviour (see below), it would not swap two values. Try it! Let's
first break up the expression so that it doesn't break C rules:

b ^= a;
a ^= b;

Let's use nybbles, since they're quicker to type, and see if it works:

a: 0011
b: 0101
b ^= a, so b becomes: 0110

a: 0011
new b: 0110
a ^= b, so a becomes: 0101

This works for a, but not for b.

To fix it, you need another XOR:

b ^= a (giving a new b of 0011).

2) the exchange doesn't work at all on anything other than integer
types, because C doesn't allow bitwise ops on other stuff.

3) consider the special case where a and b are the same object. For
example:

int foo = 6;
int *pa = &foo;
int *pb = &foo;
*pb ^= *pa; /* foo is now 0 */
*pa ^= *pb; /* foo remains 0 */
*pb ^= *pb; /* foo is still 0 */

4) the expression you gave is undefined because it violates a "shall"
that is not a constraint: "Between the previous and next sequence point
an object shall have its stored value modified at most once by the
evaluation of an expression. Furthermore, the prior value shall be
accessed only to determine the value to be stored."

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 7 '07 #56
Richard Heathfield <rj*@see.sig.invalidwrites:
Guru Jois said:

<snip>
>Guru Jois wrote:

a^=b^=a; // could be still better than 3 statements.
<snip>
>If I'm wrong, I welcome the comment/objection from experts, b'cause I
always think - " learn from seniors ".

Okay, let's see if that's true.
<snip>
4) the expression you gave is undefined because it violates a "shall"
that is not a constraint: "Between the previous and next sequence point
an object shall have its stored value modified at most once by the
evaluation of an expression. Furthermore, the prior value shall be
accessed only to determine the value to be stored."
I don't follow this last one. I am quite prepared to believe that I
am misunderstanding the phrase, but I am simply not seeing it.

a and b have their stored value modified only once (assuming a sequence
point just prior to this, of course) and to me reading of the prior
value of both a and b are used only to determine the value stored.
What have I missed?

--
Ben.
Jun 7 '07 #57
Martin Ambuhl wrote:
No, it is horrid. The OP poster asked about swapping two number [sic].
The '^' operator requires operands of an integer type. And that's not
all that's wrong with it. This question has been beaten to death
before. If you really are committed to the silly XOR trick, check the
FAQ and the newsgroup archives to find out why you shouldn't be. You
might also find out why, even when the silly XOR trick works, writing it
as a single statement is a bad idea.
Not that I think either of those solutions is any good but the original
problem contained questions of the type "enter a single digit number". I
personally think integer types is a very good variable type for that.
However the original post also states that it needed to be done with a
macro.
No I am not going to post a solution here either since it so obviously
is homework, and frankly I don't understand why it wouldn't be allowed
to use a third variable. Those suggested solutions so far are much worse
than using a third variable anyway. (What I mean by this is that the
original question is stupid, not the replies)
..
Jun 7 '07 #58
On Jun 5, 6:21 am, Chris Hills <c...@phaedsys.orgwrote:
The problem is it has got a LOT worse over the last 2-3 years. It is
getting like spam.
So, how do your treat your e-mail spam? Any normal person knows to
ignore the message and move on. Responding only puts you on their
*hot* list.

Jun 7 '07 #59
Ben Bacarisse <be********@bsb.me.ukwrites:
Richard Heathfield <rj*@see.sig.invalidwrites:
>Guru Jois said:

<snip>
>>Guru Jois wrote:

a^=b^=a; // could be still better than 3 statements.
<snip>
>>If I'm wrong, I welcome the comment/objection from experts, b'cause I
always think - " learn from seniors ".

Okay, let's see if that's true.
<snip>
>4) the expression you gave is undefined because it violates a "shall"
that is not a constraint: "Between the previous and next sequence point
an object shall have its stored value modified at most once by the
evaluation of an expression. Furthermore, the prior value shall be
accessed only to determine the value to be stored."

I don't follow this last one. I am quite prepared to believe that I
am misunderstanding the phrase, but I am simply not seeing it.

a and b have their stored value modified only once (assuming a sequence
point just prior to this, of course) and to me reading of the prior
value of both a and b are used only to determine the value stored.
What have I missed?
I *think* you're right. Perhaps Richard was thinking of the "correct"
form of the xor swap kludge:

a^=b^=a^=b;

which still has a number of problems.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 7 '07 #60
Keith Thompson said:
Ben Bacarisse <be********@bsb.me.ukwrites:
<snip>
>a and b have their stored value modified only once (assuming a
sequence point just prior to this, of course) and to me reading of
the prior value of both a and b are used only to determine the value
stored. What have I missed?

I *think* you're right. Perhaps Richard was thinking of the "correct"
form of the xor swap kludge:

a^=b^=a^=b;
I think *you're* right.
which still has a number of problems.
Ah, but now I *know* you're right.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 7 '07 #61
>>>>"GJ" == Guru Jois <gu*******@gmail.comwrites:

GJBut anyway Mr Umesh don't spoon feed askers. Don't think that
GJwe don't know the answer, all are denying the answer to make
GJthese lazy asker self-dependents.

Anyone who turns in Umesh's code as his own will get only slightly
better than he deserves as a grade.

Charlton


--
Charlton Wilbur
cw*****@chromatico.net
Jun 7 '07 #62
Johan Bengtsson wrote:
Martin Ambuhl wrote:
>No, it is horrid. The OP poster asked about swapping two number
[sic]. The '^' operator requires operands of an integer type. And
that's not all that's wrong with it. This question has been beaten to
death before. If you really are committed to the silly XOR trick,
check the FAQ and the newsgroup archives to find out why you shouldn't
be. You might also find out why, even when the silly XOR trick works,
writing it as a single statement is a bad idea.

Not that I think either of those solutions is any good but the original
problem contained questions of the type "enter a single digit number".
The reference to single digit number does not occur in this question,
which was
Write a macros in which swap two number without using 3rd variable and
then call
Macro in main function.
I understand that intertextuality is all the rage, but it is a severe
error to think that the specification of one problem carries over to a
different, unrelated one.
I
personally think integer types is a very good variable type for that.
And that opinion is completely irrelevant to the problam.
However the original post also states that it needed to be done with a
macro.
As I pointed out in my initial response
<5c*************@mid.individual.netdated Tue, 05 Jun 2007 05:09:22
-0400 in response to "Umesh"'s supposed solution using addition and
subtraction, where I wrote (among other things):
This is very, very bad.
1) Suppose a+b INT_MAX. What do you think your code will do?
2) The OP wrote "Write a macros in which swap two number without using
3rd variable". What makes you think all numbers are ints?
3) This is not a macro.
There is no normally no need to repeat what has been written before, but
this time I'll make an exception.
No I am not going to post a solution here either since it so obviously
is homework, and frankly I don't understand why it wouldn't be allowed
to use a third variable.
There is no reason, except the (extremely silly) initial problem stated
that as a condition, to which the only correct answer is "Don't do it".

Jun 7 '07 #63

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Numberwhun | last post by:
Hello everyone! I am trying to learn java and have run into kind of a snag. Here is the code that I have so far: ------ <begin_code> ---------- import javax.swing.*; import...
1
by: HolaGoogle | last post by:
Hi all, Please help me with the following..it's realy urgent and i tried everything i could and i can't get it work properly!! Thanks in advance. Here's what i'm trying to accomplish: in my...
0
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
4
by: fatboySudsy | last post by:
Hi, I have constructed a client program that has given me some error codes that i just cannot see. I was wondering if a different set of eyes with much more experience than me could help me out. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.