Menu

simple calculation program...

2007-08-13
2012-09-26
  • Nobody/Anonymous

    In this copied program, I had to add the last line... scanf("%d",&c); in order for the program to stop so i could see the answer. Without this line, as soon as i hit enter after entering a second number, it cleared the program. Obviously, this is my first attempt at programming and any help would be appreciated. I know that I don't need this last line, but I feel something is missing...

    include <stdio.h>

    main()
    {
    int a,b,c;
    printf("\nThe first number is ");
    scanf("%d",&a);
    printf("The second number is ");
    scanf("%d",&b);
    c=a*b;
    printf("The answer is %d \n",c);
    scanf("%d",&c);

     
    • Nobody/Anonymous

      Amazing how blind (and/or stupid or ?) we can be at times ... eh?

       
      • Wayne Keen

        Wayne Keen - 2007-08-15

        Naw - I wouldn't know.

        Lightening strikes

        ;)

        Wayne

         
    • Wayne Keen

      Wayne Keen - 2007-08-14

      Have you looked at the thread titled "Please Read Before Posting a Question"?

      :)

      Wayne

       
    • Nobody/Anonymous

      Since this seems to be the most frequent newbie question, it might be appropriate to have a special link to specifically address it?

       
      • Wayne Keen

        Wayne Keen - 2007-08-15

        There already is one in the Please Read thread. Next time I modify it,
        I might move it right after the discussion of the Basic 3. And it is
        covered in the offical FAQ and Adrian's FAQ

        There are of course a certain fraction of users who will not look for
        things like an FAQ before posting a question.

        We have gone through issues where there will be a certain error, call it
        XYZ that is occuring commonly, where we have a thread titled:

        "IF YOU HAVE ERROR XYZ, READ THIS FOR DIRECTIONS"

        Where people will post directly over it a thread titled "Getting
        Error XYZ! Help!"

        Wayne

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.