Search:

Type: Posts; User: dakarn

Search: Search took 0.00 seconds.

  1. Replies
    2
    Views
    836

    Thanks for the quick response but what would be...

    Thanks for the quick response but what would be printed?
    I just need someone to confirm that I'm using the precedence rules correctly.

    printf("%d \n", 2 > !3 && 4 - 1 != 5 || 6);

    2 > 0 && 3 !=...
  2. Replies
    2
    Views
    836

    Precedence: Basic Question

    Really quick: Can someone explain in the order in which to read this?

    printf("%d \n", 2 > !3 && 4 - 1 != 5 || 6);

    Thanks!
  3. Replies
    11
    Views
    3,359

    Yay fixed using: for (k=0;k

    Yay fixed using:


    for (k=0;k<4;k++) {
    printf("a[&#37;d][] = %f %f %f %f\n",k+1,*A[k],*A[k]+1,*A[k]+2,*A[k]+3);
    }


    My problem now is that it prints values but it prints the wrong values:
  4. Replies
    11
    Views
    3,359

    Great catch Elysia! This may be a stupid...

    Great catch Elysia!

    This may be a stupid question but what kind of value is it if not a float?
  5. Replies
    11
    Views
    3,359

    I switched up my code a little bit but my...

    I switched up my code a little bit but my understanding may be faulty here:

    A = (double **)calloc(16, sizeof(double *));
    Allocates enough memory for 16 doubles?


    for(row=0;row<4;row++)
    {...
  6. Replies
    11
    Views
    3,359

    I'm trying to make my matrix a 4x4 matrix. What's...

    I'm trying to make my matrix a 4x4 matrix. What's the indication that it's a 16x16 matrix?
  7. Replies
    11
    Views
    3,359

    Memory allocation question

    I think my program is crapping out because of faulty memory allocation.

    I want my code to read matrix.dat and store the numbers in a 4x4 matrix using pointer ........... Then I would like to print...
  8. Not quite sure how this exactly works. Why am I...

    Not quite sure how this exactly works. Why am I not allocating anything at A[n] and why is there no memory to hold the sscanf data?
  9. This is my altered code: if ((Inf_1 ==...

    This is my altered code:



    if ((Inf_1 == NULL))
    {
    printf("Error opening the file\n");
    exit(1);
    }
  10. Storing # from .dat file in Matrix using Pointers

    I want my code to read matrix.dat and store the numbers in a 4x4 matrix using pointers. Then I would like to print the matrix line by line. Although my program compiles, I get a core dump error...
  11. Replies
    4
    Views
    7,530

    this is my modified code (declared prototypes,...

    this is my modified code (declared prototypes, tried to fix the factorial equation):


    #include <stdio.h>
    #include <math.h>

    double Intgr(double m, int n, double A, double a, double b);...
  12. Replies
    4
    Views
    7,530

    Calling functions, calculating integral

    I'm trying to call multiple functions to calculate an integral on the interval 0 < a < b.

    My code compiles and it seems to call up the functions correctly but I get a weird number for an answer....
  13. Replies
    7
    Views
    1,976

    Problem solved! I defined the variables in the...

    Problem solved! I defined the variables in the "ugly way" at first but I tried to find a more elegant solution. I tried putting sscanf in the k loop but I didn't know how to stop it from scanning the...
  14. Replies
    7
    Views
    1,976

    It seems the print only v[0] if I explicitly tell...

    It seems the print only v[0] if I explicitly tell it to print v[0], v[1], v[2] etc



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

    int main(){
    int k;
  15. Replies
    7
    Views
    1,976

    Those tips are great. Thank you very much. My...

    Those tips are great. Thank you very much.

    My code is compiling but my vectors aren't being stored correctly. This is my output:

    iacs5.ucsd.edu% a.out

    Original Vector = [2.000000 ]
    ...
  16. Replies
    7
    Views
    1,976

    Storing # from Data File in Arrays?

    Hi I was wondering if it was possible to store a data file in an array:

    The data file (vec_in.dat) would look like this :

    1.2 -2.3 0.53 2.01 -1.5

    I'm trying to store these 5 numbers in an...
  17. Replies
    4
    Views
    1,139

    ... damn.

    ... damn.
  18. Replies
    4
    Views
    1,139

    Pointers not opening file

    I'm trying to create a program that would first read a list from a data file containing names of people and their sales and then calculate the amount of commission each person makes. I'm trying to...
  19. Replies
    11
    Views
    2,931

    I changed the "case '1'" to a "case 1:" but the...

    I changed the "case '1'" to a "case 1:" but the output still only prints "unrecognized operator". Any way to circumvent this problem?

    Thanks for the indents Salem! I'm coding on putty so I gave up...
  20. Replies
    11
    Views
    2,931

    Thanks for the input so far guys. I modified...

    Thanks for the input so far guys.

    I modified the printfs to include a \n at the end of each one.

    Now the problem is that it won't recognize the operator. This is the output:

    Enter -1<x<1:...
  21. Replies
    11
    Views
    2,931

    switch loop not working

    My switch statement embedded in my do loop doesn't seem to execute correctly:



    #include <stdio.h>
    #include <math.h>
    int main()
    {
    double x, y, y2;
    int n_term;
  22. Thread: GCC vs CC

    by dakarn
    Replies
    4
    Views
    4,485

    GCC vs CC

    My program compiles fine in CC but incorrectly in GCC:




    #include <stdio.h>
    #include <math.h>
    int main()
    {
    double x, i, S;
  23. Replies
    6
    Views
    3,830

    Thanks for the tip arpsmack! Now I can...

    Thanks for the tip arpsmack!

    Now I can compile my code but my output is like this:

    Sphere ( 1) Radius = 0.0 Area = 0.000 Volume = 0.000
    Sphere ( 2) Radius = 0.0 Area = 0.000...
  24. Replies
    6
    Views
    3,830

    What is wrong with my code?

    Can anyone tell me why my C code can't compile:


    #include <stdio.h>
    #include <math.h>
    #define PI = 3.1415926

    int main()
    {
    int k;
Results 1 to 24 of 24