Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need full coding help. Modems transmit computer data across phone lines. To do s

ID: 3626189 • Letter: N

Question

Need full coding help.

Modems transmit computer data across phone lines. To do so they convert sequences of zeros and ones, the binary numbers that are used for data representation in a digital computer, to analog signals of two frequencies. A calling modem transmits each data bit 1 as a 1270-hertz tone lasting one time unit and each data bit 0 as a 1070-hertz tone Write function that displays messages indicating the tones that would be emitted for the data represented by the functions string argument, a siring of the characters zero and one. The messages should take the form Emit _____ -hz tone for _____ time unit(s). where the tone frequency changes in each message. For example, if the argument were t string "100001101011110001", your function would display Emit 1270-hz tone for 1 time unit(s). Emit 1070-hz cone for 4 time unit(s). Emit 1270-hz cone for 2 time unit(s). Emit 1070-hz tone for 1 time unit(s). Emit 1270-hz tone for 1 time unit (s). Emit 1070-hz tone for 1 time unit(s). Emit 1270-hz tone for 4 time unit(s). Emit 1070-hz tone for 3 time unit(s). Emit 1270-hz tone for 1 time unit(s).

Explanation / Answer

// ENJOY CHEERS..............

#include <stdio.h>
#include <conio.h>


const int LT = 1070; // calling modem low tone (hertz)
const int HT = 1270; // calling modem high tone (hertz)

int main(int argc, char *argv[])
{
    if(argc!=2)
    {
    printf("Usage: %s <string>",argv[0]); // to print error
    getch();
    return 0;
    }
    else
    printf("Given Argument : %s",argv[1]); // to print argument.
    int units; // duration of one emitted tone
    int tone; // frequency of current tone (hertz)
    char digit; // 0 or 1 scanned from file
    digit = argv[1][0];
    if (digit=='0')
    {
      tone = LT;
      units = 1;
    }
   else
   {
      tone = HT;
      units = 1;
   }
   // Convert digits remaining in String
   int i=1;
   while (argv[1][i]!='')
   {
     digit = argv[1][i];
     if (digit == '0')
     {
         if (tone == LT)
          { // tone continues
           units=units+1;
          }
          else
          { // tone changes
          printf(" Emit %d-hz tone for %d time unit(s)",tone,units);
          tone = LT;
          units = 1;
         }
     }
     else
     {
            if (tone == HT)
            {
               units=units+1;
            }
            else
            {
               printf(" Emit %d-hz tone for %d time unit(s)",tone,units);
               tone = HT;
               units = 1;
            }
     }
     i++;
   
   }
   printf(" Emit %d-hz tone for %d time unit(s)",tone,units);
getch();
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote