473,762 Members | 7,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help in this program plz.

8 New Member
Can some1 tell me whats wrong in my code or plz provide your own solution so that i can learn from it.I got this question in a text whos result shows 0.0% accuracy in this code althought getting same output.Question is below:-


Hey i am solving this question :-

Time-Division Multiplexing (TDM) is a type of multiplexing in which two or more signals or bit streams are transferred simultaneously as sub-channels in one communication channel, but physically are taking turns on the channel. The time domain is divided into several recurrent time slots of fixed length, one for each sub-channel. A data block of sub-channel 1 is transmitted during timeslot 1, sub-channel 2 during timeslot 2, etc. After the last sub-channel the cycle starts all over again with a new frame, starting with the second sample, byte or data block from sub-channel 1, etc.

One TDM frame consists of one timeslot per sub-channel. In this problem, you have to determine the data that would be transmitted in the first frame using TDM. You would be given the data for each channel, the no of channels, the number of time slots available in the frame and the timeslot length as input to the function. In case a time slot could not filled completely with the data from a channel (i.e. the data in channel is finished), you should put byte 0xff to complete the time slot and NOT use the next channel's data.

The prototype of the function is:
struct BinaryData* transmitFirstFr ame(struct BinaryData input[], int count, int slotsize, int timeslots) where data of the each channel is given as struct BinaryData. Count represents the number of channels and slotsize represents the size of each time slot in bytes. timeslots represents the number of time slots available in a frame. You have to return the combined data as pointer to struct BinaryData. Return NULL in case of error in processing, or invalid input.

Constraints are:
1. The data given to you for each channel would be as array of bytes (represented as unsigned char in c/c++)

2. The inputs count, slotsize, timeslots should all be positive integers greater than zero. If not return NULL.

Example 1:Inputs:
--------------------------------------------------------------------------------
count = 3
bitrate = 8
timeslots = 4
input[1].value = "ABCDEFGHIJKLMN OPQR"
input[1].size = 18
input[2].value = "1234567890 "
input[2].size = 10
input[3].value = "abcdefghij kl"
input[3].size = 12

Output:
--------------------------------------------------------------------------------
Function transmitFirstFr ame() returns size = 32 and value = "ABCDEFGH123456 78abcdefghIJKLM NOP"
Explanation:
Here total number of timeslots are 4 and transfer bitrate is 8,
Timeslot 1 - 8 byte from channel 1 is selected ABCDEFGH
Timeslot 2 - 8 byte from channel 2 is selected 12345678
Timeslot 3 - 8 byte from channel 3 is selected abcdefgh
Tileslot 4 - 8 byte from channel 1 is selected IJKLMNOP
Hence the output is "ABCDEFGH123456 78abcdefghIJKLM NOP"

Example 2:Inputs:
--------------------------------------------------------------------------------
count = 5
bitrate = 10
timeslots = 7
input[1].value = "ABCD"
input[1].size = 4
input[2].value = "123456"
input[2].size = 6
input[3].value = "abcdefghi"
input[3].size = 9
input[4].value = "PQRSTUV"
input[4].size = 7
input[5].value = "mnopq"
input[5].size = 5

Output:
--------------------------------------------------------------------------------
Function transmitFirstFr ame() returns size = 70 and value = "ABCD0xff0xff0x ff0xff0xff0xff1 234560xff0xff0x ff0xffabcdefghi 0xffPQRSTUV0xff 0xff0xffmnopq0x ff0xff0xff0xff0 xff0xff0xff0xff 0xff0xff0xff0xf f0xff0xff0xff0x ff0xff0xff0xff0 xff0xff0xff0xff 0xff0xff"
Explanation:
Here total number of timeslots are 7 and transfer bitrate is 10,
Timeslot 1 - 10 byte from channel 1 is selected ABCD0xff0xff0xf f0xff0xff0xff - put last 6 bytes 0xff to complete the time slot
Timeslot 2 - 10 byte from channel 2 is selected 1234560xff0xff0 xff0xff - put last 4 bytes 0xff to complete the time slot
Timeslot 3 - 10 byte from channel 3 is selected abcdefghi0xff - put last 1 byte 0xff to complete the time slot
Tileslot 4 - 10 byte from channel 4 is selected PQRSTUV0xff0xff 0xff - put last 3 bytes 0xff to complete the time slot
Timeslot 5 - 10 byte from channel 5 is selected mnopq0xff0xff0x ff0xff0xff - put last 5 bytes 0xff to complete the time slot
Timeslot 6 - 10 byte are filled with 0xff as 0xff0xff0xff0xf f0xff0xff0xff0x ff0xff0xff
Timeslot 7 - 10 byte are filled with 0xff as 0xff0xff0xff0xf f0xff0xff0xff0x ff0xff0xff


::Code removed per Posting Guidelines::
Mar 22 '08 #1
6 3513
Chetanhl
8 New Member
u can provide solutions either in vc++ devc++ or turboc++ i mean on any compiler u want
but plzz provide me solution this is my first experience of asking a question so forgiveif my way of asking is not so clear.

But plz tell me solution i had been working since 3 days afte test but cant figur eout how my code gone wrong and whats the optimum solution :(
Mar 22 '08 #2
sicarie
4,677 Recognized Expert Moderator Specialist
Chetanhl-

Please read the Posting Guidelines of this site. We ask that you not do things like bold multiple huge chunks of text, that you do use code tags, that you do use full English words (some1 is not English), and more.

I have removed the full code because you did not post whatever errors you were getting, and didn't say if they were logical or syntactical.

I will say you are using depricated types - <iostream> no longer needs the .h, you need to specify a namespace, you shouldn't be using conio.h, etc... but that's not directly addressing your issue.

Please read through the Guidelines and post a clear and specific question about your code. This could be about an error you are having - in which case we ask you to copy and paste the error as well.

Thanks

sicarie
Mar 22 '08 #3
Chetanhl
8 New Member
Chetanhl-

Please read the Posting Guidelines of this site. We ask that you not do things like bold multiple huge chunks of text, that you do use code tags, that you do use full English words (some1 is not English), and more.

I have removed the full code because you did not post whatever errors you were getting, and didn't say if they were logical or syntactical.

I will say you are using depricated types - <iostream> no longer needs the .h, you need to specify a namespace, you shouldn't be using conio.h, etc... but that's not directly addressing your issue.

Please read through the Guidelines and post a clear and specific question about your code. This could be about an error you are having - in which case we ask you to copy and paste the error as well.

Thanks

sicarie
i said i am new so didnt new how to post.

Actually i had logical errors in the program .

I have writen also that my program result shows 0.0% accuracy.

And this was typed in turboc++ in whioch we have to use iostream.h and coni.h etc

i have uploaded vc++ version of my program but getting logical errors as well as 1 syntax error.

Plz any1 provide me ur own solution of this question or correct my program.

download it from this link (3 kb size)- link removed
Mar 23 '08 #4
sicarie
4,677 Recognized Expert Moderator Specialist
Please post your compiler error as well as the few lines of code around the line number given in that error.

As for your logical errors, I would recommend putting cout statements through your code and printing out all your variables each time (or have a debug function that does this). Then you can see what values you have in there, and where they differ from your expected values.

If you have a debugger, this is the best place to use it.
Mar 23 '08 #5
Chetanhl
8 New Member
i tried and geting messed up i think whole program have to be made again.

So i Can any1 plzz provide me whole program for above question??
Mar 23 '08 #6
Laharl
849 Recognized Expert Contributor
Did you read the Posting Guidelines sicarie linked you to? We don't provide solutions here, we help with specific issues dealing with already-written code.
Mar 23 '08 #7

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

Similar topics

10
2115
by: atlanta | last post by:
this is a simple C++ program to write. "Write a complete and functioning structured program that successfully compiles on Visual C++ 6, that uses two-dimensional array (5x5) that stores numbers. Read in the numbers, print them forward and backward." i dont know How to write C++.
6
4347
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing result in any way. Who can help me, I thank you very very much. list.cpp(main program) //-------------------------------------------------------------------------- - #pragma hdrstop #pragma argsused
2
1405
by: sunfox | last post by:
Please help!! I have a difficulty in writing an assignment which is related to Visual C++ V6.0. Can anybody here assist me to write a program which is able to run under DOS? The program will be used in Car Park Management, Library Management and Yellow Page Management. For the purpose of fully understanding explanatory notes should be added for each Source Code. Many thanks in advance!!!!
2
2551
by: John Baker | last post by:
I find it highly annoying that MS Access tries to go online when I want to look at the help files. Is there a way to configure it so it just looks at my local helpfiles when I hit F1?
2
3174
by: prash | last post by:
Hi everybody, I would like to request all the members to help me find the source code for the following : 1.C program for error detecting code: CRC-CCITT and CRC -32. 2.c Program for frame sorting technique used in buffer. 3.C program to implement MLMA Collision free protocol.
2
2123
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before my other includes then I get lots of errors like C2011: 'fd_set' : 'struct' type redefinition warning C4005: 'FD_CLR' : macro redefinition which I understand are due to the fact that windows.h is being included in another header file as well as...
2
2145
by: Bsnpr8 | last post by:
I need help guys, i have to many stuff to do, because i am in my last 2 weeks of the university, my last assignment is to do a spell checker in C++, i have an idea but nothing is coming out. I really need help, could someone do, anything to help me i don't have much time, here are the instructions: Instructions: In this project, you are asked to develop your own spell-checker utility. We make suggestions to help get you started. You should...
6
1642
by: HelpME | last post by:
I wrote a program in Vb.Net that was running fine. However I am unable to install it on a couple of machines. When i run it I get a windows error message that says My Project.exe has encountered a problem and needs to close. We are sorry for the inconvience. If you were in the middle of something, the information you were working on might be lost
1
1931
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at http://oldmill.uchicago.edu/~wilder/Code/random/. Firstly, I got the notorious "fatal error C1010: unexpected end of file while looking for precompiled header directive" error when I tried to compile 'randtest.c' provided by wilder.
1
1929
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at http://oldmill.uchicago.edu/~wilder/Code/random/. Firstly, I got the notorious "fatal error C1010: unexpected end of file while looking for precompiled header directive" error when I tried to compile 'randtest.c' provided by wilder.
0
9554
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
9378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
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
7360
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
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3914
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
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
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.