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
A manufacturer makes two types of drinking straws: one with a square cross-sectional shape, and the other type the typical round
Harlamova29_29 [7]

Answer:

\frac{Q_{square}}{Q_{circle}} =  0.785  

Explanation:

given data

types of drinking straws

  1. square cross-sectional shape
  2. round shape

solution

we know that both perimeter of the cross section are equal

so we can say that

perimeter of square  = perimeter of circle  

4 × S = π × D

here S is length and D is diameter

S = \frac{\pi D}{4}        ....................1

and

ratio of  flow rate through the square and circle is here

\frac{Q_{square}}{Q_{circle}} = \frac{AV^2}{AV^2}  

\frac{Q_{square}}{Q_{circle}} = \frac{S^2}{\frac{\pi D^2}{4}}  

\frac{Q_{square}}{Q_{circle}} = \frac{(\frac{\pi D}{4})^2}{\frac{\pi D^2}{4}}  

\frac{Q_{square}}{Q_{circle}} = \frac{\pi }{4}  

\frac{Q_{square}}{Q_{circle}} =  0.785  

4 0
4 years ago
Plot the function for . Notice that the function has two vertical asymptotes. Plot the function by dividing the domain of x into
elena-s [515]
This is a very very difficult one for me, let me get back to you with the proper answer.
8 0
3 years ago
BOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
sergejj [24]

Answer:

BOO

Explanation:

8 0
2 years ago
An unknown immiscible liquid seeps into the bottom of an open oil tank. Some measurements indicate that the depth of the unknown
barxatty [35]

Answer:

The specific weight of unknown liquid is found to be 15 KN/m³

Explanation:

The total pressure in tank is measured to be 65 KPa in the tank. But, the total pressure will be equal to the sum of pressures due to both oil and unknown liquid.

Total Pressure = Pressure of oil + Pressure of unknown liquid

65 KPa = (Specific Weight of oil)(depth of oil) + (Specific Weight of unknown liquid)(depth of unknown liquid)

65 KN/m² = (8.5 KN/m³)(5 m) + (Specific Weight of Unknown Liquid)(1.5 m)

(Specific Weight of Unknown Liquid)(1.5 m) = 65 KN/m² - 42.5 KN/m²

(Specific Weight of Unknown Liquid) = (22.5 KN/m²)/1.5 m

<u>Specific Weight of Unknown Liquid = 15 KN/m³</u>  

4 0
3 years ago
HELP PLS Leaders usually start as
Kazeer [188]
Team members and the work from ther
8 0
3 years ago
Other questions:
  • A PMOS device with VT P = −1.2 V has a drain current iD = 0.5 mA when vSG = 3 V and vSD = 5 V. Calculate the drain current when:
    12·1 answer
  • If the value of the feedback resistor in the filter is changed but the value of the resistor in the forward path is unchanged, w
    14·1 answer
  • A completely mixed activated-sludge process is being designed for a wastewater flow of 10,000 m3/d (2.64 mgd) using the kinetics
    6·1 answer
  • Which are the most common location for a collision between a bike and a car?
    8·1 answer
  • 5 lb of propane is contained in a closed, rigid tank initially at 80 lbf/in^2, 110 degrees Fahrenheit. Heat transfer occurs unti
    5·1 answer
  • Ayuda con este problema de empuje y principio de arquimedes.
    6·1 answer
  • On July 23, 1983, Air Canada Flight 143 required 22,300 kg of jet fuel to fly from Montreal to Edmonton. The density of jet fuel
    8·1 answer
  • Which type of Bridge is considered the strongest in both compression and tension?
    11·2 answers
  • Which option identifies the step skipped in the following scenario?
    9·2 answers
  • An ideal vapor-compression refrigeration cycle using refrigerant-134a as the working fluid is used to cool a brine solution to −
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!