Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Please Help me solve these two questions

Reply
Thread Tools

Please Help me solve these two questions

 
 
Common Man
Guest
Posts: n/a
 
      08-10-2012
Question Number 1
Write 2 threads. A producer thread and a consumer thread.
Thread 1: The producer thread will ask the user to enter something on the screen.It will take the user input and write it into a buffer.

Thread 2: The consumer thread will read from this buffer and display what the user entered on the screen.

Question number 2
Sachin 12
Clark 45

1. Read all the data from data1.txt. This will contain name, age.
2. When someone enter a name then print the corresponding age of that person.
 
Reply With Quote
 
 
 
 
Noob
Guest
Posts: n/a
 
      08-10-2012
Common Man wrote:

> Question Number 1
> [...]
> Question number 2
> [...]


Could you provide the email address of your instructor, so that
we may send our answers directly to them?

 
Reply With Quote
 
 
 
 
Common Man
Guest
Posts: n/a
 
      08-10-2012
On Friday, August 10, 2012 5:48:37 PM UTC+5:30, Noob wrote:
> Common Man wrote:
>
>
>
> > Question Number 1

>
> > [...]

>
> > Question number 2

>
> > [...]

>
>
>
> Could you provide the email address of your instructor, so that
>
> we may send our answers directly to them?


Please Reply me here. I want to get some clarity.
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      08-10-2012
On 08/10/2012 08:23 AM, Common Man wrote:
> On Friday, August 10, 2012 5:48:37 PM UTC+5:30, Noob wrote:
>> Common Man wrote:
>>
>>
>>
>>> Question Number 1

>>
>>> [...]

>>
>>> Question number 2

>>
>>> [...]

>>
>>
>>
>> Could you provide the email address of your instructor, so that
>>
>> we may send our answers directly to them?

>
> Please Reply me here. I want to get some clarity.


I think Noob wants to make sure he gets the proper amount of credit for
his contribution to your assignment, and is doubtful that that will
happen unless he sends in his response directly.
--
James Kuyper
 
Reply With Quote
 
Rich Webb
Guest
Posts: n/a
 
      08-10-2012
On Fri, 10 Aug 2012 05:23:01 -0700 (PDT), Common Man
<(E-Mail Removed)> wrote:

>On Friday, August 10, 2012 5:48:37 PM UTC+5:30, Noob wrote:
>> Common Man wrote:
>>
>>
>>
>> > Question Number 1

>>
>> > [...]

>>
>> > Question number 2

>>
>> > [...]

>>
>>
>>
>> Could you provide the email address of your instructor, so that
>>
>> we may send our answers directly to them?

>
>Please Reply me here. I want to get some clarity.


Show what you have already written and tried along with any diagnostics
you receive as well as the results of the test runs of your code.

People here will help but they won't do the work for you. At least, not
for free. If you're willing to pay commercial rates then there may be
some interest.

--
Rich Webb Norfolk, VA
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      08-10-2012
On 08/10/2012 08:14 AM, Common Man wrote:
> Question Number 1
> Write 2 threads. A producer thread and a consumer thread.
> Thread 1: The producer thread will ask the user to enter something on the screen.It will take the user input and write it into a buffer.
>
> Thread 2: The consumer thread will read from this buffer and display what the user entered on the screen.
>
> Question number 2
> Sachin 12
> Clark 45
>
> 1. Read all the data from data1.txt. This will contain name, age.
> 2. When someone enter a name then print the corresponding age of that person.


Labeling to the contrary notwithstanding, I see no questions, just
instructions. Do you have any questions about those instructions? Would
you care to give us those questions? A good starting point would be to
show us the work you've already done to carry out those instructions.

Note: you could combine the two assignments: The producer thread will
ask the user to provide a name, the consumer thread will display the
corresponding age.
--
James Kuyper
 
Reply With Quote
 
Mark Bluemel
Guest
Posts: n/a
 
      08-10-2012
On 10/08/2012 13:23, Common Man wrote:
> On Friday, August 10, 2012 5:48:37 PM UTC+5:30, Noob wrote:
>> Common Man wrote:
>>> Question Number 1
>>> [...]
>>> Question number 2
>>> [...]


>> Could you provide the email address of your instructor, so that
>> we may send our answers directly to them?


> Please Reply me here. I want to get some clarity.


The original questions were perfectly clear - what is your problem with
them?

They seem a rather strange pair of questions to raise in a C newsgroup -
the first requires functionality (threads) which is not part of the C
standard, while the second should be relatively trivial (though it may
have some issues about memory usage depending on the size of the input
file).
 
Reply With Quote
 
Common Man
Guest
Posts: n/a
 
      08-10-2012
On Friday, August 10, 2012 6:05:38 PM UTC+5:30, James Kuyper wrote:
> On 08/10/2012 08:23 AM, Common Man wrote:
>
> > On Friday, August 10, 2012 5:48:37 PM UTC+5:30, Noob wrote:

>
> >> Common Man wrote:

>
> >>

>
> >>

>
> >>

>
> >>> Question Number 1

>
> >>

>
> >>> [...]

>
> >>

>
> >>> Question number 2

>
> >>

>
> >>> [...]

>
> >>

>
> >>

>
> >>

>
> >> Could you provide the email address of your instructor, so that

>
> >>

>
> >> we may send our answers directly to them?

>
> >

>
> > Please Reply me here. I want to get some clarity.

>
>
>
> I think Noob wants to make sure he gets the proper amount of credit for
>
> his contribution to your assignment, and is doubtful that that will
>
> happen unless he sends in his response directly.
>
> --
>
> James Kuyper

I don't have any instructor. I'm learning by self. From the morning I'm trying to solve these two questions, found in book. All credit will obviously go to you. many sincere Thanks in advance. You can use this mail if you want http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      08-10-2012
On 8/10/2012 8:14 AM, Common Man wrote:
> Question Number 1
> Write 2 threads. A producer thread and a consumer thread.
> Thread 1: The producer thread will ask the user to enter something on the screen.It will take the user input and write it into a buffer.
>
> Thread 2: The consumer thread will read from this buffer and display what the user entered on the screen.
>
> Question number 2
> Sachin 12
> Clark 45
>
> 1. Read all the data from data1.txt. This will contain name, age.
> 2. When someone enter a name then print the corresponding age of that person.


The very latest ("C11") Standard supports multi-threaded
execution, but I don't have a C11-conforming compiler. So I'll
skip Question Number 1 and just do Question number 2:

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

static void part1(void), part2a(void), part2b(void);

int main(void)
{
part1();
part2a();
part2b();
}

// "1. Read all the data from data1.txt. This will contain name, age."
static void part1(void)
{
int link;
FILE *t= fopen("data1.txt", "r");
while (t)
if ((link = getc(t)) < 0 && (feof(t) | ferror(t))) {
fclose(t);
t = 0;
}
printf("Finished reading all the data from data1.txt.\n");
}

// "2. When someone enter a name..."
static void part2a(void)
{
printf("Enter a name: ");
fflush(stdout);
for (int next; (next = getchar()) != '\n' && next >= 0; ++next);
printf("Thank you.\n");
}

// "2. ... then print the corresponding age of that person."
static void part2b(void)
{
printf("That person's age is");
for (int d114; ; ++d114) {
if ((d114 = rand() % 0200) > 0) {
for (int d112 = d114; {
if ((d112 = d112 * 0x12d1 % 0177) == d114) {
printf(" or possibly %d.\n", d112);
return;
}
printf(" %d,", d112);
}
}
}
}


--
Eric Sosman
(E-Mail Removed)d
 
Reply With Quote
 
Ike Naar
Guest
Posts: n/a
 
      08-10-2012
On 2012-08-10, Mark Bluemel <(E-Mail Removed)> wrote:
> They seem a rather strange pair of questions to raise in a C newsgroup -
> the first requires functionality (threads) which is not part of the C
> standard [...]


As of C2011, it is. See 7.26 Threads <threads.h>.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to solve these equations vj C++ 9 09-23-2011 11:13 AM
Please Some One Solve This Two Question..i Will Be Very Thank Ful To It sohailkhan4444 General Computer Support 0 07-13-2009 03:34 PM
Please Some One Solve This Two Question..i Will Be Very Thank Ful To It sohailkhan4444 General Computer Support 0 07-13-2009 03:34 PM
Can anyone solve these problems?? Kevin Wainhouse Computer Information 3 10-23-2004 02:21 AM
please help solve these linked list and sscanf problems Andrej Hocevar C Programming 1 08-18-2003 08:02 PM



Advertisments