473,789 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Homework help.

10 New Member
I was wondering if someone can help me with my homework. here's the assignment:
a. Write a C program that has a declaration in main() to store the string "What's for lunch?" into an array named message. There should be a function call to restaurant() that accepts the message as an argument named menu and then displays the message using the pointer notation *(menu + i).


b. Modify this restaurant() function to alter the address in message. Use the expression *menu rather than *(menu + i) to retrieve the correct element.

I don't understand how to do this assignment that's why i am askin for help. I don't understand what's in bold, unfortunately that's the majority of the 2nd half of the assignment. so far i have:

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     char *message = "What's for lunch?";
  6.  
  7.     printf("%s\n", message);
  8.  
  9.     system("pause");
  10.     return 0;
  11. }
  12.  
THANKS FOR YOUR TIME!!!!!!
May 28 '07 #1
5 2998
gpraghuram
1,275 Recognized Expert Top Contributor
HI,
You want to alter the address or the value, i am also not able to understand the info told in the requirement 2.
Can u add more inf then people over here can help u with idea.

Thanks
Raghuram
May 28 '07 #2
svlsr2000
181 Recognized Expert New Member
I was wondering if someone can help me with my homework. here's the assignment:
a. Write a C program that has a declaration in main() to store the string "What's for lunch?" into an array named message. There should be a function call to restaurant() that accepts the message as an argument named menu and then displays the message using the pointer notation *(menu + i).


b. Modify this restaurant() function to alter the address in message. Use the expression *menu rather than *(menu + i) to retrieve the correct element.

I don't understand how to do this assignment that's why i am askin for help. I don't understand what's in bold, unfortunately that's the majority of the 2nd half of the assignment. so far i have:

#include <stdio.h>

int main()
{
char *message = "What's for lunch?";

printf("%s\n", message);

system("pause") ;
return 0;
}


THANKS FOR YOUR TIME!!!!!!
I guess you have to have a function like this
restaurant(int menu)

then u should have some menus
menu[][] = "Menu1"
" Menu 2"
" Menu 3"
and so on. then once u give menu u have to print the corresponding menu
May 28 '07 #3
karafire2003
10 New Member
i just emailed my instructor to further clarify the question. The question was copied and pasted from my syllabus. THANKS for your time and help
May 28 '07 #4
kky2k
34 New Member
As far i understood about your requirements here is the solution for ur 1st problem

Code removed as per Posting Guidelines
May 29 '07 #5
svlsr2000
181 Recognized Expert New Member
As far i understood about your requirements here is the solution for ur 1st problem

Code removed as per Posting Guidelines
Your program may work fine, but giving him the source will prohibit his thinking and world would just loose one good programmer
May 29 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
1771
by: tjshadyluver | last post by:
ok i have gotten this damn project almost done but i am frustrated on this one step. getting 18-35 together and 36-50 and so on. here is my code how can i get them combined in one line instead of writing it out a million times. please help me. i have to write a program that you type in the age and it stores it in a text file then i have to catagorize them and when i hit the read button it shows how many times 18-35 was typed in, then how...
2
2281
by: N3TB1N | last post by:
Let me try again. I could use some help with this assignment, even though my teacher does not grade assignments.but because I need to know this stuff for a test very soon, but haven't been in class for awhile and don't know what I'm doing. I have included my (probably wrong) answers for the first few questions. It would be great if someone could tell me what is missing or what I need to work on at least just for the first few. I...
11
1713
by: spawn | last post by:
but I've been struggling with this for far too long and I'm about to start beating my head against the wall. My assignment seemed simple: create a program that will cacluate the running total of user inputs until it hits 100. At 100 it should stop. That's not the problem, in fact, that part works. It's the adding that isn't working. How can my program add 2 + 7 and come up with 14? I'm posting my code (so that you may all laugh). ...
1
1581
by: mastern200 | last post by:
I need some homework help with an assignment due wed. I need to make a program where in this program calculates the average of a set of test scores. The program will ask the user how many scores there will be. The user will be prompted to enter score 1, score 2, etc. After the scores are entered the computer will print the total number of points, the average score, and the number of scores. The program will ask the user if he/she wants...
1
1564
by: itgetsharder | last post by:
Hey, i was wondering if anyone could help me. i have two questions that i cannot complete for a homework assignment: This method should convert its parameter (a string like "3.1415") to the corresponding value of type double. If the string supplied is not a valid number, it should return 0.0 as its result. Note that you can use the method Double.parseDouble() to do the hard work for you. ...
8
29171
by: garyrowell | last post by:
I have been at this programme for hours trying to work out what is wrong. Any help would be very much appricated. Here is the breif I received. The program This week you are going to write three classes: Card.java, Deck.java and DeckTester.java. The specification for each class is given below. Card.Java This is a simple class that represents a playing card. Card has two attributes: • rank which is a String that represents the value...
3
4237
by: alireza6485 | last post by:
I need to write a C# program that asks for a pattern and for each pattern beeps one and goes silence for 1 second. This is my code: for (int i=0;i< pattern; i++) { Console.Beep(); ***************** //I have no idea what to put for 1 sec of silence }
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10412
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3703
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.