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...
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...
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
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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) =...
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 >...
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...
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...
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...
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...
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...
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...
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...
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/"
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 ...
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 */...
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...
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...
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...
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...
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...
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...
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.
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);
}
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...
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...
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...
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...
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...
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...
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...
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...
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...
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.