Thread: help programing in c

  1. #1
    Registered User
    Join Date
    May 2019
    Posts
    10

    Post help programing in c

    // I have to do that in code from the numbers of txt me of the result of the calculation of the formulas of the mean and median
    Code:
     
    #include <stdio.h> 
    #include <conio.h> 
    #include <string.h> 
    
    
    
    
    int main (void) 
    
    
    FILE * fp1; 
    int i, j; 
    flotador A [4] [4], B [4] [4], C [4] [4]; 
    
    
    
    
    
    
    
    
    fp1 = fopen ("data.txt", "r"); // Abra el archivo 
    
    
    para (i = 0; i <4; i ++) // Escribimos i, j para almacenar los valores. 
        para (j = 0; j <4; j ++) 
        { 
            fscanf (fp1, "% f", & A [i] [j]); // Leemos un flotador y lo almacenamos en A en la posición i, j 
            fscanf (fp1, "% f", & B [i] [j]); // Leemos un flotador y lo almacenamos en B en la posición i, j 
            printf ("Media [% d] [% d]:% .2f \ n", i, j, A [i] [j]);
            printf ("Medio [% d] [% d]:% .2f \ n", i, j, B [i] [j]); 
        } 
    
    
    { 
    printf ("ingrese el número y luego ingrese"); 
    int x [100], n, i; 
    media flotante (int, int []); 
    flotador medio (int, int []); 
    
    
    scanf ("% d", & n); 
    para (i = 0; i <n; i ++) 
        scanf ("% d", y x [i]); 
    printf ("media =% f \ n", media (n, x)); 
    printf ("mediana =% f \ n", mediana (n, x)); 
    getch (); 
    
    
    } 
    
    
    
    
    
    
    media flotante (int m, int a []) { 
        int sum = 0, i; 
        para (i = 0; i <m; i ++) 
            suma + = a [i]; 
        retorno ((flotar) suma / m); 
    } 
    
    
    
    
    medio flotante (int n, 
        int x []) { temperatura flotante; 
        int i, j;
        para (i = 0; i <n-1; i ++) { 
            para (j = i + 1; j <n; j ++) { 
                si (x [j] <x [i]) { 
                    temp = x [yo]; 
                    x [i] = x [j]; 
                    x [j] = temp; 
                } 
            } 
        } 
    
    
        if (n% 2 == 0) { 
            return ((x [n / 2] + x [n / 2-1]) / 2.0); 
        } 
        else 
         { 
    
    
            return x [n / 2]; 
        } 
        fclose (fp1); 
    } [ADJUNTAR] 15768 [/ ADJUNTAR]
    Attached Files Attached Files
    Last edited by Salem; 05-29-2019 at 10:59 PM. Reason: Move question out of code

  2. #2
    Registered User
    Join Date
    May 2019
    Posts
    214
    Sooooo....what's the question?

  3. #3
    Registered User
    Join Date
    May 2019
    Posts
    10
    Quote Originally Posted by Niccolo View Post
    Sooooo....what's the question?
    I want to know how to open txt numbers and give me a result when using code I do not know how to do please help me.
    I want to get half and half and I have everything but I just like how to do it txt

  4. #4
    Registered User
    Join Date
    May 2019
    Posts
    10
    I have to do that in code from the numbers of txt me of the result of the calculation of the formulas of the average and median

  5. #5
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,876
    This is not standard C
    Code:
    para (i = 0; i <n-1; i ++)
    I think that you have done something like this, right?
    Code:
    #define para for
    Fact - Beethoven wrote his first symphony in C

  6. #6
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,876
    Code:
    media flotante (int, int []); 
    flotador medio (int, int []);
    Your function declarations should be before your main, not in it.
    Fact - Beethoven wrote his first symphony in C

  7. #7
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,876
    Missing braces for main
    Code:
    int main(void)
    {
    
    }
    Fact - Beethoven wrote his first symphony in C

  8. #8
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,876
    The extra spaces after the "%" and before "[" are causing the errors
    Code:
    printf ("Media [% d] [% d]:% .2f \ n", i, j, A [i] [j]);
    Fact - Beethoven wrote his first symphony in C

  9. #9
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,876
    This looks like, well...
    Code:
    scanf ("% d", y x [i]);
    Fact - Beethoven wrote his first symphony in C

  10. #10
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,876
    There seems to be confusion between media and medio -
    Fact - Beethoven wrote his first symphony in C

  11. #11
    Registered User
    Join Date
    May 2019
    Posts
    10

    please help me

    [QUOTE = Click_here; 1286878] Parece que hay confusión entre los medios y el medio - [/ QUOTE]
    I can pass the code correcting all the errorsmedia mediana.cmedia mediana.c

  12. #12
    Registered User
    Join Date
    May 2019
    Posts
    10
    Quote Originally Posted by Click_here View Post
    There seems to be confusion between media and medio -
    I can pass the code to you, it does not work for me yet

  13. #13
    Registered User
    Join Date
    May 2019
    Posts
    214
    @Jairofr, no offense but are you HIRING someone, or asking for help to understand what you're writing?

  14. #14
    Registered User
    Join Date
    May 2019
    Posts
    10
    Quote Originally Posted by Jairofr View Post
    I can pass the code to you, it does not work for me yet
    if you can send it 3 hours or when you can, I need to know how to use txt.
    my personal email <<<snipped>>>
    Last edited by Salem; 05-29-2019 at 10:57 PM. Reason: Privacy and robot miners

  15. #15
    Registered User
    Join Date
    May 2019
    Posts
    10
    Quote Originally Posted by Niccolo View Post
    @Jairofr, no offense but are you HIRING someone, or asking for help to understand what you're writing?
    asking for help to understand what you're writing?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. new to C programing, need a little help
    By mgrenier25 in forum C Programming
    Replies: 10
    Last Post: 01-22-2014, 07:25 PM
  2. DNA C programing
    By S16 in forum C Programming
    Replies: 2
    Last Post: 04-29-2009, 09:54 AM
  3. new to programing need help!!
    By newguy3121 in forum C++ Programming
    Replies: 18
    Last Post: 09-21-2006, 01:59 PM
  4. programing in DOS?
    By k1ll3r in forum C++ Programming
    Replies: 41
    Last Post: 05-31-2006, 04:17 AM
  5. programing
    By NiVaG in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-03-2004, 09:19 AM

Tags for this Thread