C programming Definition and 116 Threads

  1. D

    Simple C programming for gaussian

    Homework Statement make a gaussian elimination in C the one we used on matrix to find x1 x2 and x3 if the matrix is 3x3 Homework EquationsThe Attempt at a Solution #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int i,j,k,n; float...
  2. matineesuxxx

    Runtime of Seemingly Unpredictable Division Algorithm

    Last week on my computer science assignment I had to write a division algorithm using only addition and subtraction to tackle a problem. My first attempt was the simple and naive repeated subtraction, although I quickly discovered it was not nearly efficient enough for how I needed to use it, So...
  3. A

    C Programming: acos() not accepting variable

    The following function acos() does not accept any variables. I have included the math.h header. For example i = 1; acos(i/2); // This should be equal to 60
  4. Giant

    Enrollment in C programming course

    I've decided to learn programming in my holidays. And I've enrolled myself in a C programming class (Apparently they don't allow C++ unless you know C). The course requirement says familiarity with "programming techniques" I tried searching it but I din't get the meaning I just got various...
  5. N

    C programming: pointer assignment only in main()?

    Hello, I was assigning a pointer to an array and I noticed it will only this to takeplace within the main function: #include <stdio.h> float array_1[10] = { 1,1,2,3,4,5,6,7,8,9 }; float * p_array_1; int main( void ) { p_array_1 = &array_1; printf("array address using ampersand is %p...
  6. N

    C programming: array declared before main() and initialised in main()

    Hello! I am sure I am again missing something obvious: I tried to declare the array and assing value within main() as follows: #include <stdio.h> float array_1[10]; int main( void ) { array_1[10] = { 1,1,2,3,4,5,6,7,8,9 }; ...other stuff... return 0; } I can declare and...
  7. N

    Simple C programming problem, variable stuck at initialised value

    Simple C programming problem, variable "stuck" at initialised value Hello! This is most likely an error in my code but I just can't see what it is! I am new to C programming and maybe I have just been staring at it for so long that I can't see the obvious error. I was playing around with a...
  8. A

    Top C Programming Books for Beginners: Expert Recommendations

    Hi, could anyone recommend me a good book for learning C programming? I know that there are lots of good website but I would prefer a solid book, however without reading them before hand naturally I can't determine a good one! So any advice on this specifically would be good thank you. Or any...
  9. B

    A problem when calculating the average of an array (c programming )?

    hi , I need to do the following Write a program that asks the user to enter a number. Then create an array of this size. Fill the array with random numbers between 0 and 10. Calculate the average value. I did the program but there is a problem in calculating the average . can some one tell me...
  10. J

    Create Custom Shapes with User Input in C Programming

    I have to write a program that will take user input to make certain shapes. If the user inputs 's', its a solid square, 'b', its a hollow box, 't' its a triangle. They also choose how many rows it is and what the shape is made of. Example **** **** **** this would be a user input of...
  11. J

    Print Text After Scanf on Same Line in C Programming

    How do you print text after a scanf statement on the same line? This is what i need the output to look like: Enter a number here: _% The _ is the scanf waiting for input. Now when i write the code like this: printf("Enter a number here: "); scanf("%d", &x); printf("%\n"); It won't...
  12. J

    Output JBL in Block Letters with C Programming

    All i have to do is write a program that will output my initials (JBL) in block letters. This is what i have done: #include <stdio.h> void main() { printf(" JJJJJJ BBBBBBBB LLL"); printf(" JJ BB BB LLL"); printf(" JJ BBBBBBB LLL"); printf(" JJ BB...
  13. J

    A few questions about C programming language

    1. In what direction does a compiler read a program? Left to right, top to bottom? 2. What does it mean when a function is called by another. Like when main() is called by the operating system, what is going on within the computer? Does the OS send a code in binary or what? 3. When the...
  14. S

    Basic C Programming Help Cash Register

    Hello, I am working on a basic cash register c program and I've run into a few errors/logical errors I don't know where to begin to fix. I am limited to knowing only how to use, scant, printf, if/elseif/else, do/dowhile. The problem is if you compile it and test it, my validcode flag is not...
  15. F

    C Programming with Interrupts: How to Avoid Polling and Optimize Processor Usage

    Hi everyone~ I think that I have used polling here where I shouldn't have done. Does anyone have any ideas? #include "p18f8722.h" #include "timers.h" void configure_PB2_interrupt (void); void enable_global_interrupts(void); unsigned char PB2_pressed (void); void isr...
  16. F

    When to use ADCON1 in c programming on the pic18f8722

    Under what circumstances would you use ADCON1=0x0F? All I know at the moment is for using the pushbuttons and using the switches and then I saw a piece of code using the pushbuttons without this line in it and I was wondering whether I was wrong all of this time. I have tried googling and...
  17. A

    C Programming: Dynamic allocation of 2D arrays using an array of pointers.

    Homework Statement Ok, I'm learning C programming and I'm trying to create a dynamic 2D array. This is the code that seems to work in creating a dyamic array. I found it in a book. //rows and cols are values entered by the user when the program runs. int **(matA) =...
  18. C

    C Programming: Creating recursive quickSort function

    Homework Statement Function: void quickSort(struct student *array, int start, int end) { int i = start; int j = end; while(i < j) { // Move left counter, then right counter. while(i <= end && array[i].numDays <= array[start].numDays) i++; while(array[j].numDays >...
  19. C

    C Programming: freeing array of structs causes heap overflow

    Homework Statement Error: warning: HEAP[Happy Birthday.exe]: warning: Heap block at 006E15A8 modified at 006E1688 past requested size of d8 My Struct: struct student { // Defines a student. char firstName[NAMELENGTH], lastName[NAMELENGTH]; int day, month, year; }; My Code...
  20. S

    Python C Programming: Deepen Understanding & Learn Python in 1 Month

    Im a Computer Science Major, i just finish a programming Class.. it was a C class, i got an A on the class it was a bit to easy in my opinion, but I am not confident in C Im good with functions, variables, pointers, basic structs, etc Im lacking understanding on structs using pointers...
  21. D

    C programming compiling syntax errors

    Got some errors when compiling and not sure what is the problem and how to fix it # include<stdio.h> #define FLEETSIZE 10 typedef struct { int day, month, year; }Date_t; typedef struct { char make[15]; Date_t manufactureDate; Date_t...
  22. Y

    How to write a C programming proposal?

    I'm new at C programming. My course required me to write a proposal with the title "Word Processing'. It sounds: Create an interface that emulates basic word processing. Ask the user to input text and save it to "txt" format. The user should be able to modify, add and remove any of the...
  23. Who Am I

    Orbit program - three objects (C programming, but other programmers could help)

    Homework Statement I'm trying to write a program with three bodies, two in orbit around a large central object. The main object orbits fine, that was dealt with earlier. I'm having trouble making a smaller object that is the only object whose position is dependent on the position of both of...
  24. S

    Why Do CPUs Handle Signed and Unsigned Arithmetic Differently?

    I'm completely lost, I have an exam in C programming in a month & a half based off of this: http://www.maths.tcd.ie/~odunlain/1261/prog.pdf Basically I need some recommendations of books &/or online resources that follow the flow of those notes extremely closely but offer additional insight...
  25. C

    Executing more than one command in C programming at the same time, newbie in C.

    Hello all, I'm doing a project related to counting up the amount of production. I'm using Arduino board and C language. I am counting the amount of production in 3 line in the factory. So far I have design the program only for 1 line, how to make the 2nd and 3rd lines so at the end I can sum...
  26. J

    Late Dennis Ritchie: Creator of C Programming Language

    Dennis Ritchie died on the 8th, but I didn't find out until today. He created the C programming language. http://www.wired.com/wiredenterprise/2011/10/dennis-ritchie/"
  27. P

    Counting characters in C language

    Please explain what this C code will do : #include <stdio.h> /* count characters in input; 1st version */ main() { long nc; nc = 0; while (getchar() != EOF) ++nc; printf("%ld\n", nc); } 'The C Programming' Book says that this code counts characters but it doesn't do the same ...
  28. P

    What is EOF in C Programming Language?

    Can anyone please explain what is EOF in C programming language. Is it a value (numeric, character) or something else ?? While reading the book "The C programming language", by Ritchie I came across this term. The code was : #include <stdio.h> /* copy input to output; 1st version */...
  29. M

    C Programming: Simulate Program to Calculate xxx(17)

    Homework Statement Simulate the following program #include <stdio.h> int xxx (int n) { int count; count = 0; while ( n >=2) { n = n/2; ++count; } return count; } main() { printf( "xxx(17)=%d\n", xxx(17) ); } Homework Equations The Attempt at a...
  30. M

    C Programming: Simulate xxx(333) = 2

    Homework Statement Simulate the following program #include <stdio.h>int xxx ( int n ) { if ( n < 10 ) /* A */ return 0; else return 1 + xxx ( n/10 ); /* B */ } main() { printf ( "xxx(333)=%d\n", xxx(333) ); } Homework Equations The Attempt at a Solution I'm not sure if this is...
  31. M

    Evaluate C Programming Questions: 1-2/3+4-5, 1-2/3+4.0-5 etc.

    Homework Statement Evaluate the following expressions (i) 1 - 2/3 + 4 - 5 (ii) 1 - 2/3 + 4.0 - 5 (iii) 1 - 2/3.0 + 4 - 5 (iv) 1 + 4*3/2 (v) 1 + 3/2*4 (vi) 'h' - 'e' + 'l' - 'p' The Attempt at a Solution The answers for each question respectively are 0 0.0...
  32. A

    Variables suddenly disappering (C programming)

    Hi, I have an array that is partially disappearing from one line of code to the next and I don't have idea what could be causing this. The pseudocode of the relevant chunk of code goes like this: ... declare some 3d-dynamic arrays allocate memory for the arrays assign values to the...
  33. S

    Learn How to Use File and Argc in C Programming: Step-by-Step Guide

    Hello! I am learning how to use file and argc and I am stuck on this assignment : write a program that sequentially displays on screen the contents of all of the files listed in the command line. Use argc to control a loop. Here is my code, I'll try to enclose it in [ CODE ] [ /CODE ] tags if...
  34. M

    Java Comparing Java & C Programming: Questions & Answers

    So I have multiple questions regarding these two programming languages. 1. Which is better to learn first? 2. I recently emailed a possible future university asking what languages they teach. In the email he said "Java rafter than C" Now does that mean mostly Java but C included? Or no C at...
  35. J

    C programming Q: initializing an array of structures

    I am writing a program in C (vanilla, non-C++/C#) and I am having trouble figuring out why my initialization of my array of structures isn't working. I have tried a number of things without any luck. I still get a compiler error: "conflicting types for 'cardInfo' " I am writing a simple...
  36. U

    C Programming: Output of Float Calculation

    The question is What will be the output? #include<stdio.h> int main(void) {float y=6/4; printf("%.1f\n",y);} The answer is 1.0 I got that right by trusting my senses:biggrin:; but I want to understand why.
  37. S

    Understand the Output of 1000*1000 in C Programming

    Hello, I want to know the answer of following program and the reason behind it...as soon as possible void main() { float j; j=1000*1000; printf("%f",j); }
  38. C

    C Programming for Mechanical Engineers: Benefits & Applications

    Is C programming language necessary for Mechanical Engineers? Why? And where we use it?
  39. R

    Multiplying Columns of Numbers in C Programming

    Hello all, I wrote a C program to multiply a column of numbers (for eg., number will look like this 10.45618) with some constant... after multiplication i get the correct value (i tested using calculator). Now the output is 0.00005672 (i use %14.9lf) ..but i want them to display like this...
  40. H

    The Next Step in Learning C Programming: Suggestions & Resources

    Hello every body! I have read "The C Programming Language" and i want to know if i want to go further what is the next book you suggest?
  41. J

    C Programming: Printing Prime Numbers from 1 to 20

    Homework Statement Hello, i want to calculate and print prime numbers from 1 to 20. I've provided my code below, and the program compiles but its just printing all numbers from 1 to 20, why? also have i used the continue statement correctly, since if it is found that a number is not prime then...
  42. L

    What Can Function Prototypes Do Without Parameters and Return Values?

    Just some basic questions i have about function prototypes (functions) What's an example of a code which has no parameters? ie: double func(void) what is the purpose if the thing doesn't take in parameters? also, what if there is keyboard input and screen input what does that mean in the...
  43. K

    C Programming: give command a 5 sec interval to run

    Hi all, I am new to C and I need some help solving an issue with network programming. So in general, i have two programs running: Program A and Program B. Description of A: Send out packet with SN = i (SN is the label for the packet. i.e first pkt SN=1, 2nd pkt SN=2 etc) Set...
  44. I

    C Programming: Adding 16bit and 32bit Integers with Local and Global Variables

    Homework Statement Write a C program to use a function to add two 16bit and two 32bit integers together and return a long integer result. Call the function twice with different parameters and print the results. Declare your input variables to one of the function calls as local variables (on...
  45. C

    Help in C Programming: Fixing Errors with nr.h & nrutil.h Libraries

    What are the functions of the following C libraries? nr.h nrutil.h What I understood is that these are used when u are calling functions like 'qromb or polint or trapzd' for integration. Acutally when I compile the program I get these errors. nr.h: No such file or directory nrutil.h: No...
  46. V

    Tips for Reading and Splitting Data in C Programming Lab Homework

    Homework Statement Well the program has several functions but I just really need help with reading a text file and splitting the data in the file into a one-dimensional array and a two-dimensional array The text file is like this... 21 1110 1.5 5.4 6.0 9.8. 8.5 8.3 5.6...
  47. N

    What is the Correct Way to Initialize a Character in C Programming?

    the foolowing program is to read inputed data and display them all at once but when i run it it asks for the first information and then runs the total program without asking for the input of other information.after that it doesn't respond and closes immediatelly. can someone help me and tells...
  48. R

    C programming help nedded ?what is the wrong of this code?

    C programming help nedded ??what is the wrong of this code? #include<stdio.h> int matA[3][4],matB[4][3],matAB[3][3],i,j,k; void read(); void multiply(); void display(); int main() { read(); multiply(); display(); return 0; } void read() { printf("Enter your matrix A:\n"); for...
  49. L

    C Programming Compiler for Windows Vista

    Hi, At university we are using the Borland C++ 5.5 compiler, however, this does not work on Vista, which my home computer has. I was therefore wondering what C program compiler everyone would recommend which works on Windows Vista? Thanks, Luke.
  50. Q

    Converting Fahrenheit & Celsius: A C Programming Guide

    Okay. I need to write a C program to convert between fahrenheit and celsius degrees.
Back
Top