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
True or False; If I was trying to find the Voltage of my computer, and I was given the Watts and Amps it uses, I would use Watt'
defon

Answer:

true

Explanation:

8 0
3 years ago
What flight patterns do groups of birds utilize and why?
lara31 [8.8K]
Birds mostly fly in a V because the lead bird cuts al of the wind and has the hardest work and then after a while the lead bird goes to the back and another bird takes his place cutting all the wind for the other birds
7 0
3 years ago
A thin metal disk of mass m=2.00 x 10^-3 kg and radius R=2.20cm is attached at its center to a long fiber. When the disk is turn
topjm [15]

Answer:

k = 1.91 × 10^-5 N m rad^-1

Workings and Solution to this question can be viewed in the screenshot below:

6 0
3 years ago
Which of the following is NOT part of a car's drive train?
FromTheMoon [43]

Answer:

B. rotor

Explanation:

The correct answer Is rotor because the others are part of a cars drivetrain

3 0
3 years ago
Read 2 more answers
A cyclone is operated in a closed circuit with a ball mill. The cyclone is feed from a rod mill with a slurry that has a density
pav-90 [236]
Here is the flow sheet. Hope this helps have a great day!!

3 0
3 years ago
Other questions:
  • Phil decided to rescue Bobo the Dancing Bear from a traveling circus that was closing its business. Although Bobo was a well-beh
    12·1 answer
  • For the following gear train, if the blue gear is moving at 50 rpm, what are the speeds of the other gears?
    14·1 answer
  • The head difference between the inlet and outlet of a 1km long pipe discharging 0.1 m^3/s of water is 0.53 m. If the diameter is
    11·1 answer
  • How an AK 47 gun was works​
    14·1 answer
  • PLZ HURRY IM ON A TIMER
    6·1 answer
  • A single lane highway has a horizontal curve. The curve has a super elevation of 4% and a design speed of 45 mph. The PC station
    8·1 answer
  • A closed, rigid tank is filled with a gas modeled as an ideal gas, initially at 27°C and gauge pressure of 300 kPa. The gas is h
    9·1 answer
  • Is there anyone who can help me with welding?
    7·1 answer
  • Calculate the percentage of recyclables in high socioeconomic localities.
    13·1 answer
  • The current at resonance in a series L-C-R circuit is 0.2mA. If the applied voltage is 250mV at a frequency of 100 kHz and the c
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!