I rode into cprogramming.com on a thread with no name

This is a discussion on I rode into cprogramming.com on a thread with no name within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include <stdlib.h> int main() { int a; a=0 do { a++; printf("%d ",a); _sleep(100); }while(a!=101); system("pause"); return ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    7

    I rode into cprogramming.com on a thread with no name

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int a;
        a=0
        do
        {
              a++;
              printf("%d  ",a);
              _sleep(100);
              
        }while(a!=101);
        system("pause");
        return 0;
    }
    im supposed to let the user input a number(lets say b) and make the numbers from 0 to 100 that is divisible by 'b' to erase it and changed to "___".For example the user inputs 5,so i have to make 5 into '_*_' and the numbers from 0 to 100 that can be divided by 5 into "___".

    001 002 003 004 _*_ 006 007 008 009 ___ 011 012 013 014 ___ 016

    Or if the user inputs 4 that means i hav to make 4 as _*_ and the numbers from 0 to 100 that can be divided by 4 into "___".

    001 002 003 _*_ 005 006 007 ___ 009 010

    can anybody tell me how to do this?I juz started on basic C programming so pardon my low intelligence.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1

    Thumbs up

    Code:
    int main()
    {
    int i,b;
    printf("Enter the Value for b:");
    scanf("%d",&b);
    for(i=1;i<=100;i++)
           {
    
    if(i==b) printf("_*_ "); elseif(i%b==0) printf("___ "); else printf ("%d",i);
    } }
    % operator gives you the reminder after divinding i by b. So all the multiples can be identified using this... For all other numbers its simply a plain printf().

    Regards,
    Arun.

  3. #3
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399

    Thumbs down

    Wow.

    Seiten, try reading the Cboard homework policy. Most members of this board won't do your homework for you. Learn to ask questions instead of simply stating your problem. You should also read the Cboard Forum Guidelines. A meaningful subject will help you get better responses.

    arun_softengr, try reading the Cboard homework policy. Doing one person's homework just encourages more people to post their homework. Learn to answer questions instead of simply solving problems.
    Last edited by pianorain; 08-12-2005 at 09:49 AM.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    sorry about that but its my first time posting a help thread n im nt sure hw to phrase it so that im asking questions than asking someone to help me.

  5. #5
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    Quote Originally Posted by Seiten
    sorry about that but its my first time posting a help thread n im nt sure hw to phrase it so that im asking questions than asking someone to help me.
    A real thread title is a good start
    If you understand what you're doing, you're not learning anything.

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    sorry bout that..i was testin out the code tags n i i titled it as tt to save time.I was gonna change it to a suitable title..seemed that i forgot..

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    guys i had a syntax error "expected primary-expression before "else""
    can anyone plz explain this for me?thks.
    note im doing a if-elseif-else structure.

  8. #8
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    nvm..i figured it out..

  9. #9
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    guys i figured out hw to clear wif the _*_ but when it comes to the __ it will show the number that can b divisible.For example i input 8:
    001 002 003 004 005 006 007 _*_008 009 010 011 012 013 014 015 __016 017

    any hints or help will do..thks

  10. #10
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >but when it comes to the __ it will show the number that can b divisible.
    Amazing, some misguided soul posts a working solution to the assignment, and now someone can't even copy and paste it correctly.

  11. #11
    Registered User
    Join Date
    Aug 2005
    Posts
    7
    nonono..when i press 8 its supposes to change 008 into _*_ not 008_*_ and to blank 016 into "__" and not " ___016".
    i guess u didnt read properly..

  12. #12
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    i guess u didnt read properly..
    I guess you didn't read properly, or even bother compiling the code the first reply gave you. It does what you couldn't. It does exactly what you said you wanted.

    You can't tell people to read better when you haven't even read the first reply.


    Quzah.
    Hope is the first step on the road to disappointment.

  13. #13
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Code:
    a=0
    Well, the first thing you need is a semicolon at the end of this line.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-26-2009, 11:48 PM
  2. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 05:14 AM
  3. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 02:17 PM
  4. pointer to main thread from worker thread?
    By draegon in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 07:35 AM
  5. Critical Sections, destroying
    By Hunter2 in forum Windows Programming
    Replies: 4
    Last Post: 09-02-2003, 11:36 PM

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