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
Alborosie
3 years ago
6

The following C program asks the user for two input null-terminated strings, each stored in uninitialized 100-byte buffer, and c

ompares them. The program then shows the alphabetical order of both strings, by reporting whether the first is less than the second, the second is less than the first, or both are equal.#include «stdio·h> int main() // Two strings, 100 bytes allocated for each char si [100; char s2 [100]; // Read string 1 printf("Enter string scanf("%s", s1); 1: "); // Read string 2 printf("Enter string scanf("%s", s2); 2: "); // Compare them int index = 0; while (1) / Load characters from s1 and s2 char c1 = s1[index]; char c2 = s2[index]; // Current character is greater for s1 if (c1 > c2) printf("s1 > s2\n") break; // Current character is greater for s2 if (c1 < c2) printf("s1
Engineering
1 answer:
marissa [1.9K]3 years ago
3 0

Answer:

Code is given below:

Explanation:

.data  

str1: .space 20  

str2: .space 20  

msg1:.asciiz "Please enter string (max 20 characters): "  

msg2: .asciiz "\n Please enter string (max 20 chars): "  

msg3:.asciiz "\nSAME"  

msg4:.asciiz "\nNOT SAME"  

.text

.globl main

main:  

   li $v0,4        #loads msg1  

   la $a0,msg1  

   syscall

   li $v0,8

   la $a0,str1

   addi $a1,$zero,20

   syscall          #got string to manipulate

   li $v0,4        #loads msg2

   la $a0,msg2

   syscall

   li $v0,8

   la $a0,str2

   addi $a1,$zero,20

   syscall         #got string  

       la $a0,str1             #pass address of str1  

   la $a1,str2         #pass address of str2  

   jal methodComp      #call methodComp  

   beq $v0,$zero,ok    #check result  

   li $v0,4

   la $a0,msg4

   syscall

   j exit

ok:  

   li $v0,4  

   la $a0,msg3  

   syscall  

exit:  

   li $v0,10  

   syscall  

methodComp:  

   add $t0,$zero,$zero  

   add $t1,$zero,$a0  

   add $t2,$zero,$a1  

loop:  

   lb $t3($t1)         #load a byte from each string  

   lb $t4($t2)  

   beqz $t3,checkt2    #str1 end  

   beqz $t4,missmatch  

   slt $t5,$t3,$t4     #compare two bytes  

   bnez $t5,missmatch  

   addi $t1,$t1,1      #t1 points to the next byte of str1  

   addi $t2,$t2,1  

   j loop  

missmatch:    

   addi $v0,$zero,1  

   j endfunction  

checkt2:  

   bnez $t4,missmatch  

   add $v0,$zero,$zero  

endfunction:  

   jr $ra

You might be interested in
Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If user
Thepotemich [5.8K]

Answer:

import java.util.Scanner;

public class FindMatchValue {

  public static void main (String [] args) {

     Scanner scnr = new Scanner(System.in);

     final int NUM_VALS = 4;

     int[] userValues = new int[NUM_VALS];

     int i;

     int matchValue;

     int numMatches = -99; // Assign numMatches with 0 before your for loop

     matchValue = scnr.nextInt();

     for (i = 0; i < userValues.length; ++i) {

        userValues[i] = scnr.nextInt();

     }

     /* Your solution goes here */

         numMatches = 0;

     for (i = 0; i < userValues.length; ++i) {

        if(userValues[i] == matchValue) {

                       numMatches++;

                }

     }

     System.out.println("matchValue: " + matchValue + ", numMatches: " + numMatches);

  }

}

8 0
3 years ago
Aaron needs to create a building design for a restaurant with colors that depict excitement and vibrancy. Which color can Aaron
zloy xaker [14]

Answer:

I'm no engineer, but blue and purple are cool colors and white is every color so I'd go with orange

7 0
2 years ago
Read 2 more answers
Describe the energy transformation that occurs when a television is used
Morgarella [4.7K]

A television transforms electric energy into sound energy and radiant energy.

<h3>What is energy transformation?</h3>

Energy transformations are processes that convert energy from one type into another. Any type of energy use must involve some sort of energy transformation.

Some examples of energy transformations are, A television converts electric energy into sound and light energy. Lightbulbs convert electric energy into light energy. A hair dryer converts electrical energy into thermal and sound energy.

Learn more about Energy transformations here,

brainly.com/question/8822715

#SPJ4

6 0
2 years ago
Determine the magnitude of force P needed to start towing the 40kg crate.Also determine the location of the resultant normal for
erastova [34]

The distance from Point A=500 mm

Explanation:

M := 40kg c := 200mm

μs := 0.3 d := 3

a := 400mm e := 4

b := 800mm

Initial guesses: N_{c} := 200 N P := 50N

Plz refer to the image below

5 0
3 years ago
After Hurricane Katrina there was considerable public outrage that many of the properties were not insured against flooding alth
Mashcka [7]
I would say B is the answer
8 0
3 years ago
Read 2 more answers
Other questions:
  • an adiabatic compressor receives 1.5 meter cube per second of air at 30 degrees celsius and 101 kpa. The discharge pressure is 5
    11·1 answer
  • Transcription machinery assembles at _______________.
    6·1 answer
  • A tank has two rooms separated by a membrane. Room A has 1 kg of air and a volume of 0.5 m3; room B has 0.75 m3 of air with dens
    15·1 answer
  • 2.31 LAB: Simple statistics Part 1 Given 4 integers, output their product and their average, using integer arithmetic. Ex: If th
    5·2 answers
  • 1. True/False The Pressure Relief valve maintains the minimum pressure in the hydraulic circuit​
    13·1 answer
  • 3. How can statistical analysis of a dataset inform a design process?<br> PLEASE I NEED THIS ANSWER
    8·1 answer
  • Does anyone know obamas last name???? please help its for a friend I swear!!!111!!11!
    8·1 answer
  • Random question, does anyone here use Lego, do not answer unless that is a yes
    15·2 answers
  • For each of the resistors shown below, use Ohm's law to calculate the unknown quantity, Be sure to put your answer in proper eng
    8·1 answer
  • When a company in the United States employs people in India to answer their customer service calls this is an example of
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!