Thread: unable to print

  1. #1
    nehal
    Guest

    unable to print

    hi everyone. im new here.
    this my code:

    Code:
     #include <math.h>
    
    
    double main()
    {
    
        double num1;
        double num2;
    
    
        printf ("enter number 1: \n");
        scanf("%e" , &num1);
        printf("enter number 2 \n");
        scanf("%e", &num2);
    
         double arithmetic_mean = (( num1 + num2)/2);
            printf ("Arithmetic Mean is :  \n", arithmetic_mean);;
    
         double geometric_mean =  sqrt (num1 * num2);
            printf ("Geometric Mean is  : \n" , geometric_mean);
    
    
         double harmonic_mean = 2 / ( 1 / num1)+ (1 / num2);
            printf (" Harmonic Mean is : \n", harmonic_mean);
    
    
    return (0);
    }
    when i run the program i am unable to print anythin on the last 3 prinf's it just comes up as blank.
    how can i correct this?

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    First you need to include stdio.h for the standard input/output functions. Second main must be defined to return an int, not a double and should return an int. Third in your scanfs you are using the format specifier "%e" which works for a float but you are using a double so the specifier should be "%le" or "%lf". The printfs you have a variable you want to print but you don't have the specifier in the format string:
    Code:
    printf (" Harmonic Mean is : %e\n", harmonic_mean);
    You should look at these links for scanf and printf.

    Jim

  3. #3
    nehal
    Guest
    thanks alot

    i jus started c in uni.
    make many mistakes

    nehal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Towr of Hanoi move the disc
    By WatchTower in forum C Programming
    Replies: 9
    Last Post: 07-17-2009, 03:48 AM
  2. Queues
    By ramayana in forum C Programming
    Replies: 22
    Last Post: 01-01-2006, 02:08 AM
  3. Bypassing Print Dialog Box
    By leojose in forum Windows Programming
    Replies: 0
    Last Post: 10-13-2005, 06:44 AM
  4. Replies: 1
    Last Post: 07-31-2002, 11:35 AM
  5. How to print out the data throw printer.Attn Salem
    By Jason in forum C Programming
    Replies: 2
    Last Post: 09-23-2001, 05:58 AM