1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
polet [3.4K]
3 years ago
11

Write a program that reads in characters from standard input and outputs the number of times it sees an 'a' followed by the lett

er 'b'.

Computers and Technology
1 answer:
Simora [160]3 years ago
6 0

Answer:

Following is attached the code that works accordingly as required. It reads in characters from standard input and outputs the number of times it sees an 'a' followed by the letter 'b'. All the description of program is given inside the code as comments.

I hope it will help you!

Explanation:

You might be interested in
When one loop appears inside another, the loop that contains the other loop is called the ____ loop. Group of answer choices ind
Sauron [17]

Answer:

outer

Explanation:

When one loop appears inside another, the loop that contains the other loop is called the outer loop.

5 0
2 years ago
In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program
solniwko [45]

Answer:

C code is given below

Explanation:

// Vigenere cipher

#include <ctype.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

/**

* Reading key file.

*/

char *readFile(char *fileName) {

   FILE *file = fopen(fileName, "r");

   char *code;

   size_t n = 0;

   int c;

   if (file == NULL) return NULL; //could not open file

   code = (char *)malloc(513);

   while ((c = fgetc(file)) != EOF) {

      if( !isalpha(c) )

          continue;

      if( isupper(c) )

          c = tolower(c);

      code[n++] = (char)c;

   }

   code[n] = '\0';

  fclose(file);

   return code;

}

int main(int argc, char ** argv){  

   // Check if correct # of arguments given

   if (argc != 3) {

       printf("Wrong number of arguments. Please try again.\n");

       return 1;

   }

 

  // try to read the key file

  char *key = readFile(argv[1]);

  if( !key ) {

      printf( "Invalid file %s\n", argv[1] );

      return 1;

  }

 

  char *data = readFile(argv[2]);

  if( !data ) {

      printf("Invalid file %s\n", argv[2] );

      return 1;

  }

 

   // Store key as string and get length

   int kLen = strlen(key);

  int dataLen = strlen( data );

 

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

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

 

  int paddingLength = dataLen % kLen;

  if( kLen > dataLen ) {

      paddingLength = kLen - dataLen;

  }

  for( int i = 0; i < paddingLength && dataLen + paddingLength <= 512; i++ ) {

      data[ dataLen + i ] = 'x';

  }

 

  dataLen += paddingLength;

 

   // Loop through text

   for (int i = 0, j = 0, n = dataLen; i < n; i++) {          

       // Get key for this letter

       int letterKey = tolower(key[j % kLen]) - 'a';

     

       // Keep case of letter

       if (isupper(data[i])) {

           // Get modulo number and add to appropriate case

           printf("%c", 'A' + (data[i] - 'A' + letterKey) % 26);

         

           // Only increment j when used

           j++;

       }

       else if (islower(data[i])) {

           printf("%c", 'a' + (data[i] - 'a' + letterKey) % 26);

           j++;

       }

       else {

           // return unchanged

           printf("%c", data[i]);

       }

      if( (i+1) % 80 == 0 ) {

          printf("\n");

      }

   }

 

   printf("\n");

 

   return 0;

}

4 0
3 years ago
Read 2 more answers
Information taken directly from an existing classified source and stated verbatim in a new or different document is an example o
kvv77 [185]

This is known as information extraction.

4 0
3 years ago
An ISP is considering adding additional redundant connections to its network. Which of the following best describes why the comp
ozzi

Answer:

Redundant networks are generally more reliable.

Explanation:

6 0
3 years ago
The java compiler is able to find all programmer errors.
Troyanec [42]
No compiler can do that. Maybe with AI, but that's beyond the scope of a compiler.
5 0
4 years ago
Other questions:
  • Which of the following is true of an enterprise search software? Select one:
    5·1 answer
  • What are strategies that you can use to yield web sites that are relevant to your research topic?
    13·1 answer
  • What file may contain data written to it in case of an unexpected error or program shut-down?
    12·2 answers
  • What is the advantage of using the clipboard task pane?
    7·1 answer
  • What is the total utilization of a circuit-switched network, accommodating five users with equal bandwidth share, and the follow
    5·1 answer
  • What is the result when you run the following program?<br> print("2 + 7')<br> print(3 + 1)
    6·2 answers
  • What made it possible to develop personal computers?
    10·2 answers
  • PowerPoint is a visual aid for many speakers. Discuss some points to remember when adding text to a PowerPoint presentation. How
    8·1 answer
  • PLEASE HELP I WILL GIVE BRAINLIEST!!
    8·1 answer
  • Which computer peripheral is used when you would like to use a DVD or CD?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!