problem in c

This is a discussion on problem in c within the C Programming forums, part of the General Programming Boards category; just can't seem to get this to work please help #include <iostream.h> #include <stdlib.h> #include <stdio.h> int main() { /**/ ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    13

    Question problem in c

    just can't seem to get this to work
    please help



    #include <iostream.h>
    #include <stdlib.h>
    #include <stdio.h>

    int main()

    {
    /**/ unsigned int value = 3000000000;
    short num = 30000;
    double pi = 3.14159141;
    char inital = 'G';
    short hour = 0, minute = 0, second = 0;
    int numsys = 0;
    /**/
    printf("\n%-15u%c", value, &initial);
    printf("\nEnter a number please\n");
    scanf("%d", &numsys);
    fflush(stdin);
    printf("Hexadecimal equivalent = %x\n", numsys);
    printf("octal = %00\n", num);
    printf("\n%9.4f", pi);
    printf("\nEnter the time in hh:mm:ss\n");
    scanf("\n%hd %hd %hd", &hour, &minute, &second);
    fflush(stdin);
    printf("\n%hd:%hd:%hd:", hour, minute, second);
    printf("\n\"I Deserve 100%%!\"\n");


    system("PAUSE");
    return 0;
    }

  2. #2
    Unregistered
    Guest
    Code:
    #include <stdlib.h>
    #include <stdio.h> 
    
    int main() 
    
    { 
    /**/
    unsigned int value = 3000000000;
    double pi = 3.14159141; 
    char initial = 'G'; 
    short hour = 0, minute = 0, second = 0; 
    int numsys = 0; 
    /**/ 
    printf("%-15u%d\n", value, &initial); 
    printf("Enter a number please: "); 
    scanf("%d", &numsys);
    printf("Hexadecimal equivalent = %x\n", numsys); 
    printf("octal = 0%o\n", numsys); 
    printf("PI = %lf\n", pi); 
    printf("Enter the time in hh:mm:ss: "); 
    scanf("%d:%d:%d", &hour, &minute, &second);
    printf("%hd:%hd:%hd\n", hour, minute, second); 
    printf("\"I Deserve 100\%!\"\n"); 
    
    int ch;
    ch = getchar(); 
    return 0; 
    }
    That's the working code, compare the two programs and see what I changed.

  3. #3
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284

    Re: problem in c

    #include <iostream.h>
    you can do the above in a C++ program only
    fflush(stdin);
    fflush'ing a input stream is not permitted in ANSI C , read K & R on this .

    Originally posted by OPENCCT
    just can't seem to get this to work
    please help



    #include <iostream.h>
    #include <stdlib.h>
    #include <stdio.h>

    int main()

    {
    /**/ unsigned int value = 3000000000;
    short num = 30000;
    double pi = 3.14159141;
    char inital = 'G';
    short hour = 0, minute = 0, second = 0;
    int numsys = 0;
    /**/
    printf("\n%-15u%c", value, &initial);
    printf("\nEnter a number please\n");
    scanf("%d", &numsys);
    fflush(stdin);
    printf("Hexadecimal equivalent = %x\n", numsys);
    printf("octal = %00\n", num);
    printf("\n%9.4f", pi);
    printf("\nEnter the time in hh:mm:ss\n");
    scanf("\n%hd %hd %hd", &hour, &minute, &second);
    fflush(stdin);
    printf("\n%hd:%hd:%hd:", hour, minute, second);
    printf("\n\"I Deserve 100%%!\"\n");


    system("PAUSE");
    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 05:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM

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