Like Tree2Likes
  • 1 Post By DeadPlanet
  • 1 Post By Babkockdood

Qestion.. (:

This is a discussion on Qestion.. (: within the C Programming forums, part of the General Programming Boards category; My question is: if I need to ask from the user to input 30 numbers what is the easy way ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    5

    Qestion.. (:

    My question is: if I need to ask from the user to input 30 numbers what is the easy way to write it in C as a loop?

  2. #2
    Registered User joybanerjee39's Avatar
    Join Date
    Oct 2011
    Location
    kolkata
    Posts
    107
    Quote Originally Posted by Oranitt View Post
    My question is: if I need to ask from the user to input 30 numbers what is the easy way to write it in C as a loop?
    my answer is:don't worry abut easy or hard way , just try it yourself ,then post your code.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    stahta01 likes this.

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    23
    You should probably do it with a for loop since for loops are usually used when you know how many iterations will be done.

  5. #5
    Registered User
    Join Date
    Jan 2012
    Posts
    1

    For loop

    Using for loop would be easier for you. You can do it with while or do_while also all the loops will take same time. Or you can use recursion also.
    You can write foor loop as :-
    Code:
    int i;
    for(i=0; i<30; i++)
    {
       // your code goes here. 
    }

  6. #6
    Registered User
    Join Date
    Jan 2012
    Posts
    5

    thank you

    all for helping (:

  7. #7
    Registered User
    Join Date
    Jan 2012
    Posts
    5

    this is the qestion

    For some reason I cant think about a solution
    suggestion will be accepted (:




    Write a program receiving 30 three-digit integers. The program to calculate the sum of digits of unity, of the dozens and hundreds of all 30 numbers recorded on the plan at the end print the three amounts together with a suitable

  8. #8
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    This sounds suspiciously like a homework assignment, especially because it's devoid of typos and other errors in your post.

    Also, don't use scanf() like the guy above suggested, it teaches terrible coding habits unlike fgets() or fread().

  9. #9
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    The C Board is not a homework machine.

    Announcements - General Programming Boards

    Try writing the code yourself, and we'll tell you what's wrong with it.
    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.

  10. #10
    Registered User
    Join Date
    Jan 2012
    Posts
    5
    I understand you completely, believe me if I would not try before I probably Probably would not have assisted you , I've been a whole day trying to find a solution for the exercise and everything went wrong , just degrading things (: hah I tried to check all the study material given to us, classes are recorded and nothing! Anyone who wants to help, no one has to ... (:

  11. #11
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    Quote Originally Posted by memcpy View Post
    Also, don't use scanf() like the guy above suggested, it teaches terrible coding habits unlike fgets() or fread().
    Sorry, what? Please link me to somewhere that says taking input with scanf, specifically numerical input, teaches terrible coding habits.

  12. #12
    Registered User
    Join Date
    Jan 2012
    Posts
    5
    BTW sorry for the bad English

  13. #13
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Quote Originally Posted by Oranitt View Post
    I understand you completely, believe me if I would not try before I probably Probably would not have assisted you , I've been a whole day trying to find a solution for the exercise and everything went wrong , just degrading things (: hah I tried to check all the study material given to us, classes are recorded and nothing! Anyone who wants to help, no one has to ... (:
    Post the code or quit asking for help.
    rags_to_riches likes this.
    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.

  14. #14
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Oranitt View Post
    I understand you completely, believe me if I would not try before I probably Probably would not have assisted you , I've been a whole day trying to find a solution for the exercise and everything went wrong
    So you must have something written, post that. Honestly -- no one is going to bother if you yourself do not make an effort.

    Quote Originally Posted by memcpy View Post
    Also, don't use scanf() like the guy above suggested, it teaches terrible coding habits unlike fgets() or fread().
    Scanf() is a little more complicated to use than fgets() or fread(), but it is very handy when used properly.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  15. #15
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,288
    Sitting here waiting for the OP's code to show up...

    Even if it's just an empty main(), just give us something!
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. qestion/ example of sweep line
    By Reemj in forum C++ Programming
    Replies: 3
    Last Post: 01-03-2011, 01:43 PM
  2. a qestion about modern editors
    By Masterx in forum C++ Programming
    Replies: 5
    Last Post: 02-01-2009, 12:04 AM
  3. Warning! Newbie Qestion : fscanf!
    By Karmachrome in forum C Programming
    Replies: 4
    Last Post: 11-13-2005, 09:59 AM

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