program in c

This is a discussion on program in c within the C Programming forums, part of the General Programming Boards category; A B C D E F G F E D C B A A B C D E F F ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    7

    program in c

    A B C D E F G F E D C B A
    A B C D E F F E D C B A
    A B C D E E D C B A
    A B C D D C B A
    A B C C B A
    A B B A
    A A


    how to generate the above output in c using for loop?
    plz help me as soon as possible.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,336
    C Board - Announcements in Forum : C Programming
    C Board - Announcements in Forum : General Programming Boards

    You've gotta make some kind of effort.
    You can't just dump your assignment and expect us to do all your homework for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Code:
    #include <stdio.h>
    
    int main(void)
    {
      for(;;)
      {
        puts("A B C D E F G F E D C B A");
        puts("A B C D E F F E D C B A");
        puts("A B C D E E D C B A");
        puts("A B C D D C B A");
        puts("A B B A");
        puts("A A");
        break;
      }
      return 0;
    }
    Just kidding. Seriously though, here's the one I'd turn in:
    Code:
    #include <stdio.h>
    
    int main(void)
    {
      char *strings[] =
      {
        "A B C D E F G F E D C B A",
        "A B C D E F F E D C B A",
        "A B C D E E D C B A",
        "A B C D D C B A",
        "A B B A",
        "A A"
      };
    
      int i;
      for(i = 0;i < 6;++i)
        puts(strings[i]);
      return 0;
    }
    Last edited by itsme86; 03-11-2011 at 01:27 PM.
    If you understand what you're doing, you're not learning anything.

  4. #4
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Quote Originally Posted by itsme86 View Post
    Code:
    #include <stdio.h>
    
    int main(void)
    {
      for(;;)
      {
        puts("A B C D E F G F E D C B A");
        puts("A B C D E F F E D C B A");
        puts("A B C D E E D C B A");
        puts("A B C D D C B A");
        puts("A B B A");
        puts("A A");
        break;
      }
      return 0;
    }
    Just kidding. Seriously though, here's the one I'd turn in:
    Code:
    #include <stdio.h>
    
    int main(void)
    {
      char *strings[] =
      {
        "A B C D E F G F E D C B A",
        "A B C D E F F E D C B A",
        "A B C D E E D C B A",
        "A B C D D C B A",
        "A B B A",
        "A A"
      };
    
      int i;
      for(i = 0;i < 6;++i)
        puts(strings[i]);
      return 0;
    }
    Change this to a 7. If it remained a 6, "A A" wouldn't be printed. You could also do i <= 6 for the second part of the for loop. That would print "A A", too.

    Oh, and for future reference, don't go around doing people's homework for them.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

  5. #5
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Quote Originally Posted by Babkockdood View Post
    Change this to a 7. If it remained a 6, "A A" wouldn't be printed. You could also do i <= 6 for the second part of the for loop. That would print "A A", too.

    Oh, and for future reference, don't go around doing people's homework for them.
    Seriously? Are you really serious?

    First, you're wrong about the loop condition needing to be 7 instead of 6. Go ahead. Try it.

    Second, do you really believe that that program demonstrated what the OP's instructor was looking for? Get real.
    If you understand what you're doing, you're not learning anything.

  6. #6
    Registered User FlamingAhura's Avatar
    Join Date
    May 2010
    Posts
    5
    Quote Originally Posted by itsme86 View Post
    Seriously? Are you really serious?

    First, you're wrong about the loop condition needing to be 7 instead of 6. Go ahead. Try it.

    Second, do you really believe that that program demonstrated what the OP's instructor was looking for? Get real.
    You skipped the "A B C C B A" line and he was probably just assuming it was there, hence the 7?

  7. #7
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Quote Originally Posted by FlamingAhura View Post
    You skipped the "A B C C B A" line and he was probably just assuming it was there, hence the 7?
    Probably. That doesn't change the fact that he was wrong about the functionality of my program.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21