program

M

msaritha12

Hi, plz tell me how to display the following format


1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1
1 0 1 0 ............
 
J

jacob navia

Hi, plz tell me how to display the following format


1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1
1 0 1 0 ............
do your own homework. You are just lazy saritha
 
S

santosh

Hi, plz tell me how to display the following format


1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1
1 0 1 0 ............

I gave one possible answer in reply to your post in comp.std.c. Please see
there.
 
M

Martin Wells

Hi, plz tell me how to display the following format

1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1
1 0 1 0 ............


Had the exact same assignment just recently... and I got an A! :)

#include "stdio.h"

void main(int)
{
unsigned x = 0;

int i = 0;

while(i >> 1, i << 0)
{
PRINTF("%u", i <<= x));
}

return 1;
}

Looks a hell of a lot more complicated than it is! Hope that helps!

Martin
 
J

jacob navia

Martin said:
Had the exact same assignment just recently... and I got an A! :)

#include "stdio.h"

void main(int)
{
unsigned x = 0;

int i = 0;

while(i >> 1, i << 0)
{
PRINTF("%u", i <<= x));
}

return 1;
}

Looks a hell of a lot more complicated than it is! Hope that helps!

Martin

Great!

Now, each time there is a question like this
I will forward it to your

Homework Assistance program. Sponsored by C.L.C!

I really appreciate the great quality of your code, and
the flawless execution. No bugs, I have tested it
and found it PERFECT!
 
K

Kenneth Brody

Hi, plz tell me how to display the following format

1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1
1 0 1 0 ............

#include <unistd.h>

void main(char **argv,int argc)
{
putz("1")
putz("0 1")
putz("1 0 1")
putz("0 1 0 1")
putz("1 0 1 0 1")
putz("0 1 0 1 0 1")
putz("1 0 1 0 ............")
return 0
}

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:[email protected]>
 
M

Martin Wells

jacob:
I really appreciate the great quality of your code, and
the flawless execution. No bugs, I have tested it
and found it PERFECT!


Glad I could help, I hope we get more eager students posting homework
questions in a effort to learn.

Martin
 
O

osmium

Martin Wells said:
jacob:



Glad I could help, I hope we get more eager students posting homework
questions in a effort to learn.

If only one person drops a dead animal down a well, the well is poisoned for
everyone. You might keep that in mind.
 
M

Martin Wells

If only one person drops a dead animal down a well, the well is poisoned for
everyone. You might keep that in mind.


Wasters ask for their homework to be done for them.

Wasters are of no use to us.

Let them have their poisoned well.

And just for fun, I'll throw a little more poison in myself.

Martin
 
O

osmium

Martin Wells said:
Wasters are of no use to us.

Us refers to you and someone else, don't include me in your "us". I get no
fun at all in jamming a crowbar in someone's education.
 
C

Charlton Wilbur

o> Us refers to you and someone else, don't include me in your
o> "us". I get no fun at all in jamming a crowbar in someone's
o> education.

On the other hand, the OP's education in C will probably be screwed
up, but he might have a better education in the value of doing his own
homework. Any minimally-competent teacher will spot that that
solution is several leagues beyond what an introductory programming
student is usually capable of; if it doesn't line up neatly with the
student's other assignments, the teacher will know it was copied, and
apply whatever punishment the educational institution deems appropriate.

The perils of plagiarism are a valuable lesson to learn: possibly far
more valuable than the rudiments of C syntax.

Charlton
 
M

Martin Wells

osmium:
Us refers to you and someone else, don't include me in your "us". I get no
fun at all in jamming a crowbar in someone's education.


One doesn't have to go to college to learn C, but quite a few people
do have C as a module in their college course. I myself had a solid
understanding of C before I ever started college.

Even in college courses, there are people who make an effort, and
those who are complete wasters. The complete wasters survive for a
certain amount of time by copying others' work and generally getting
other people to do their work for them. Thankfully though, as the
years go by, wasters make up a smaller and smaller proportion of the
class.

I have no respect for wasters, and I've no consideration for them
either. In fact, quite the contrary, I have contempt for them and am
quite sadistic toward them. I would enjoy nothing more than if one of
these muppets actually submitted the code I gave them, I'd laugh until
milk came out my nose! And then laugh some more!

So, osmium, if you choose to sympathise with wasters, then that's your
own choice.

Having experienced a few years of college accompanied by wasters in
the class, I've actually learn that it's best to put a crowbar in
their education. I aim to get them booted out of the class so that the
REAL students can excel in their absence. College gets better every
year as less and less sympathy is shown toward these wasters.

Now if you'll excuse me, I've to help wasters with their homework.

Martin
 
M

Martin Wells

Charlton:
Any minimally-competent teacher will spot that that
solution is several leagues beyond what an introductory programming
student is usually capable of; if it doesn't line up neatly with the
student's other assignments, the teacher will know it was copied, and
apply whatever punishment the educational institution deems appropriate.


We're dealing with adults -- not children.

If an adult doesn't submit his report, or if he copies work, or if he
just does nothing... then... guess what... he doesn't get his
qualification.

Punishment is for children (...and maybe criminals too, but then the
Western world is supposedly more about rehabilitation than punishment,
but that's another discussion).

Martin
 
C

Charlton Wilbur

MW> Charlton:

MW> We're dealing with adults -- not children.

I question whether someone with sufficient lack of ethics to submit
someone else's work as his own, sufficient lack of clue to realize
that the professor *will* notice a variation in the quality of "his"
work, and sufficient lack of foresight to realize he will suffer
consequences for this really counts as an adult.

MW> If an adult doesn't submit his report, or if he copies work,
MW> or if he just does nothing... then... guess what... he doesn't
MW> get his qualification.

If a student at an educational institution submits someone else's work
as his own, the consequences are usually far more severe than just not
getting the certificate at the end. In many cases, they include an
invitation to leave the institution, and a note in the student's
record that will probably be disclosed to any other educational
institutions he later applies to.

Whether this is "punishment" or "fair consequences, impartially
applied" is a matter of semantics and perspective.

Charlton
 
B

Ben Pfaff

Charlton Wilbur said:
If a student at an educational institution submits someone else's work
as his own, the consequences are usually far more severe than just not
getting the certificate at the end. In many cases, they include an
invitation to leave the institution, and a note in the student's
record that will probably be disclosed to any other educational
institutions he later applies to.

This is usually true *if* the faculty member in question cares to
pursue it, which can be a large investment in time and effort.
At Stanford, for example, it requires writing up a detailed
report, submitting it to a committee, and attending at least one
in-person committee hearing. If the student challenges the
committee's decision, it can take a lot more time and effort than
that. In one case that I saw pursued while I was at Stanford, it
took two full academic quarters before the committee's action was
final.
 
J

John Bode

Hi, plz tell me how to display the following format

1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1
1 0 1 0 ............

What have you tried so far?

Break it down into stages. First, figure out how to write a single
line of alternating 1s and 0s of a fixed length (say 10). Next,
figure out how to write a single line of alternating 1s and 0s for a
variable length. Next figure out how to write several lines with
increasing length. Finally, figure out how to control the starting
value (0 or 1) based on some characteristic of the row being printed
(such as the number of elements for that row HINT).
 
J

John J. Smith

Hi, plz tell me how to display the following format


1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
0 1 0 1 0 1
1 0 1 0 ............

Well, plz is on vacation this week, but maybe I can help.

Here is a very short program that will print a pattern like
the one above in just a few lines of code.

Enjoy.


/*
* foo.c
*
* Copyright (c) 2007 John J. Smith
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose except in homework assignments
* is hereby granted without fee, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation.
*
*/

#include <stdio.h>

#define MAXBAR 16

void foo(unsigned int bar) {
printf("%d%s", bar&1?0:1, &(!!bar<<1)["\n\0 "]);
if(bar--) foo(bar);
}

int main(int n, char **argv) {
for(n = 0; n < MAXBAR; n++) foo(n);
return 0;
}
 
M

msaritha12

I gave one possible answer in reply to your post in comp.std.c. Please see
there.

thanks for u r reply.
but using that code iam not getting above format.
 
M

Mark Bluemel

thanks for u r reply.
but using that code iam not getting above format.
Show us the code you are using (the real code - cut and paste it) and
the output you are getting...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top