I've finally come up with a working solution using loops! The idea behind my code is like a binary counter. Here it is:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void recurse( char str[], char caller, char *array[] );
int main ()
{
char *array[8] = { "ABC", "DEF", "GHI"...
Aha! No. When this problem was given, we were supposed to solve it using just normal loops. Problem is I can't seem to figure that out. When I started thinking on how to use loops, I first started with a while loop to run through all the cases of the alphabets associated with the last number...
I have run it on gdb and I received some kind of error telling me that program can't access memory and also some segmentation faults. But thanks for alerting me about modifying caller...I realized that there are some huge errors now in my code needed to be corrected. Thanks.
Homework Statement
On a phone keypad, many of the numbers have letters associated with them. For instance, the letters A, B, and C are associated with the number 2. Write a program that accepts a number as input and prints all of the possible letter combinations associated with that number. For...
I'm sorry, although I now understand the distinction, I still can't get the right answer
I'm not too sure if I know what the question asks, but it states that the final form needs to be simplified to 9 switching elements. And no, I don't have the answer.
Does a switching element correspond to...
Homework Statement
The problem is given in the picture attached. It is a network of switches.
Homework Equations
The Attempt at a Solution
I managed to simplify the expression to this:
## (S + x'(w+y) + xvz)(x'+y)(v+z') ##
but I just can't find a way to simplify it to 9 literals. I've...
Homework Statement
Write a program that opens a file of the users choice that contains a list of birthdays. Extract from this file two things: (1) the date with the most common birthday (all of them) and (2) the month with the most people born. We will not test for a tie in either of these...
So would it be something like %100s? And also, if I were to do this with fgets instead, I should put 99 to account for the null character, right?
Wow, I didn't know that there could be so many bytes in just a few letters! The double x and int i gets printed after the string. Is this something...
Sorry for the late reply! I have been busy, but I really appreciate yours and Mark44's help! It seems I've made the question to be more complicated than it needs to be. Here is my much improved (hopefully!) version of the code:
#include <stdio.h>
#include <string.h>
int main (void)
{
char...
I haven't yet learned dynamic memory management, but I'll get back to it later after fixing a bug in my program. I have managed to make it work somewhat, but not exactly right, and also using much more lines of code than you said was necessary. I'm not sure if the question meant just constantly...
Thanks so much for your help! However, I'm not sure if I could see any difference between both. Both reads from stdin, and stores it in the character array my_string.
I've modified my code again, and it still isn't working. I don't know why. Here is my edited code:
#include <stdio.h>
int main ()
{
char input_word [100] = {'\0'}, temp [100]= {'\0'}, command [10] = {'\0'}, stop [4] = {"STOP"};
int n = 0, match = 0;
printf("Enter a word: ")...
Ok, so I've modified the code with your suggestions. Now, I'm wondering when am I able to use strcmp and so functions? Are they only able to be used with char * ? If so, how do I compare an array of commands that the user entered with the word STOP?
My modified code ( which still does not work...
< Mentor Note -- thread moved to HH from the technical Computer forum, so no HH Template is shown >
I have a homework problem which requires me to convert a word a user entered to Pig Latin by moving the first letter of the word to the end and adding an ay to it. For example, Tuesday becomes...
That's precisely the problem I had with my idea, I could not store those expressions because while writing the program, I do not know beforehand how many unique numbers the user would enter, thus I can't create a variable to store it. Do I make sense? I hope I do.
So here is the question:
On a phone keypad, many of the numbers have letters associated with them. For instance, the letters A, B, and C are associated with the number 2. Write a program that accepts a number as input and prints all of the possible letter combinations associated with that...
Homework Statement
Sisyphus is pushing a boulder up a 100-ft tall spiral staircase surrounding a cylindrical castle tower.
a) Suppose Sisyphus's path is described parametrically as $$x(t)=(5\cos3t, 5\sin3t, 10t)$$, $$\space 0\leq t\leq10$$.
If he exerts a force with constant magnitude of 50 Ib...
Thanks for your advice. So now, I don't have any experience with programming, but I have a curiosity about how all the hardware in electronic gadgets work. Since I don't see myself as someone who can sit in front of a computer and code all day, I decided that electrical engineering would be the...
Hey everyone, so it's nearing the end of fall semester now, and it's time for me to register for classes next spring. The problem is that I still don't really know what to major in, and I have to decide soon. Both majors have different sets of prerequisites to take before being able to be...
I honestly do not know. In the ##xy## plane, the region is bounded by the line ##y=x##, the ##x## axis and the line ##x=3##. What does moving it in the ##r## direction mean? If I do so, for ##\theta=0##, I get ##0 \leq r \leq 3##, but for ##\theta=\frac{\pi}{4}##, I get ##0 \leq r \leq 3...
Are both upper and lower ones incorrect? I don't know any other way to find the limits for ##r##. Any hints?
Or since value of ##x## is constant, are the bounds in Cartesian coordinates something like ##3 \leq \sqrt{9+y^2} \leq 3\sqrt2##?
Homework Statement
Transform given integral in Cartesian coordinates to one in polar coordinates and evaluate polar integral.
##\int_{0}^3 \int_{0}^x \frac {dydx}{\sqrt(x^2+y^2)}##
Homework Equations
The Attempt at a Solution
I drew out the region in the ##xy## plane and I know that ##0...
Homework Statement
Consider the planar quadrilateral with vertices (0, 0), (2, 0), (1, 1) and (0, 1). Suppose that it has constant density. What is its center of mass?
Homework Equations
The Attempt at a Solution
Since it has constant density, could I assume that the center of mass would be...
Homework Statement
If ##D^*## is the parallelogram whose vertices are ##(0,0)##,##(-1,3)##, ##(1,2)##, and ##(0,5)## and D is the parallelogram whose vertices are ##(0,0)##, ##(3,2)##,##(1,-1)## and ##(4,1)##, find a transformation ##T## such that ##T(D^*)=D##.
Homework Equations
The Attempt...
Ok, thanks for providing the correct answer for me to check. However, I got a wrong answer. What I would like to know is if the process of calculating the integral in rectangular coordinates really long? Because mine certainly is. I'm just wondering if I'm doing it correctly.
But I think I'm supposed to be calculating it using rectangular coordinates, because this question is in the section before the change of variables topic.
Homework Statement
$$f(x,y,z)=y$$ ; W is the region bounded by the plane ##x+y+z=2##, the cylinder ##x^2 +z^2=1##, and ##y=0##.
Homework Equations
The Attempt at a Solution
Since there is a plane of ##y=0##, I decided that my inner integral will be ##y=0## and ##y=2-x-z##. But after this I...
Haha, what you said above was definitely mumbo-jumbo to me. But what do you mean by the tangent plane of the constraint? Is it taking the Hessian of the gradient of the equation of constraint?
So, in the case of this question, I do not need to show that the value I get is indeed largest, is it...
Now I have another problem. How do I show that the dimensions I get are those that are of largest capacity? So let me write out my steps again.
$$V(r,h)= \pi r^2h$$
$$A(r,h)= 2 \pi r^2 +2 \pi rh$$
$$\nabla V(r,h)=[2 \pi rh, \pi r^2]$$
$$\nabla A(r,h)=[4 \pi r + 2 \pi h, 2 \pi r]$$
$$2 \pi rh=c(4...
@fresh_42 @Let'sthink Ah, I see now. I didn't think that the can would have a bottom since there is a fixed sheet of metal. I figured that wrapping the sheet around to form a cylinder would leave the bases empty. Thanks so much!:smile:
Homework Statement
A cylindrical metal can is to be manufactured from a fixed amount of sheet metal. Use the method of Lagrange multipliers to determine the ratio between the dimensions of the can with the largest capacity.
Homework Equations
The Attempt at a Solution
$$V(r,h)=\pi r^2h$$
$$2...
Homework Statement
Igor, the inchworm, is crawling along graph paper in a magnetic field. The intensity of the field at the point ##(x,y)## is given by ##M(x,y)=3x^2+y^2+5000##. If Igor is at the point ##(8,6)##, describe the curve along which he should travel if he wishes to reduce the field...
Ah, I think I've got it. Here are my first steps:
Let ##g(x,y)=(4y \cos(xy)+3x^2, 4x\cos(xy)+3y^2)##. The 2 functions there are the partial derivatives ##F_x## and ##F_y## respectively. By taking derivative of the function, I can get an invertible 2x2 matrix. And from here I can proceed to use...
Yes I've read them but I still have no idea on how the links you gave me can be applied to this problem. Sorry.
But I will show you what I have tried so far. I made the partial derivatives of ##x## and ##y## as the new functions I need to evaluate using Newton's method. I reason that by getting...
But I just don't get it. Newton's method is used to get the root of an equation, whereas this is to get a critical point where the derivative is zero. Can the above form apply here?