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 36 ft simply supported beam is loaded with concentrated loads 16 ft inwards from each support. On the left side, the dead load
lana66690 [7]

Answer:

1st part: Section W18X76  is adequate

2nd part: Section W21X62 is adequate

Explanation:

See the attached file for the calculation

8 0
3 years ago
Gummy gummy bears gummy gummy bears
ivanzaharov [21]
I love that song lol
8 0
3 years ago
Read 2 more answers
1. On a 2001 Honda Civic, while replacing fuel injectors, what do you coat the new O-rings with?
scoundrel [369]

Answer:

Coat new O-rings (D) with silicone oil or polyalkyleneglycol (PAG) oil, and pull them on the injectors.

3 0
3 years ago
A parallel plates capacitor is filled with a dielectric of relative permittivity ε = 12 and a conductivity σ = 10^-10 S/m. The c
monitta

Answer:

t = 1.06 sec

Explanation:

Once disconnected from the battery, the capacitor discharges through the internal resistance of the dielectric, which can be expressed as follows:

R = (1/σ)*d/A, where d is is the separation between plates, and A is the area of one of  the plates.

The capacitance C , for a parallel plates capacitor filled with a dielectric of a relative permittivity ε, can be expressed in this way:

C = ε₀*ε*A/d = 8.85*10⁻¹² *12*A/d

The voltage in the capacitor (which is proportional to the residual charge as it discharges through the resistance of the dielectric) follows an exponential decay, as follows:

V = V₀*e(-t/RC)

The product RC (which is called the time constant of the circuit) can be calculated as follows:

R*C = (1/10⁻¹⁰)*d/A*8.85*10⁻¹² *12*A/d

Simplifying common terms, we finally have:

R*C = 8.85*10⁻¹² *12 / (1/10⁻¹⁰) sec = 1.06 sec

If we want to know the time at which the voltage will decay to 3.67 V, we can write the following expression:

V= V₀*e(-t/RC) ⇒ e(-t/RC) = 3.67/10 ⇒ -t/RC = ln(3.67/10)= -1

⇒ t = RC = 1.06 sec.

3 0
3 years ago
If a lever operates at a mechanical disadvantage, it means that the ________.
alekssr [168]

Answer:

The correct answer is option 'B': Load is far from fulcrum and the effort is applied near the fulcrum

Explanation:

A lever works on the principle of balancing of torques. The torque about the fulcrum by the load should be equal to the torque by the applied effort. Since we know that the torque is proportional to both the force and the distance it is applied from the distance from the axis of rotation. A lever is used when we need to lift a heavy load by utilizing this effect of the lever arm.

A mechanical disadvantage occurs when we are not able to lift the weight easily due to the fact we apply effort near the fulcrum.

4 0
3 years ago
Read 2 more answers
Other questions:
  • PLEASE HELP 100 POINTS!!! WILL MARK BRAINLIEST
    9·2 answers
  • Estimate the quantity of soil to be excavated from the borrow pit​
    12·1 answer
  • Create a document that includes a constructor function named Company in the document head area. Include four properties in the C
    7·1 answer
  • Pls help! 39 points!!
    5·2 answers
  • dentify a semiconducting material and provide the value of its band gap) that could be used in: (a) (1 point) red LED (b) (1 poi
    10·1 answer
  • A closed system consisting of 4 lb of a gas undergoes a process during which the relation between pressure and volume is pVn 5 c
    7·1 answer
  • Steam in a heating system flows through tubes whose outer diameter is 5 cm and whose walls are maintained at a temperature of 19
    13·1 answer
  • The cost of hiring new employees outpaces the raises for established employees is
    5·1 answer
  • Please help me. I have no idea what I'm doing.​
    14·2 answers
  • The majority of adults now own smartphones or tablets, and most of them say they use them in part to get the news. From 2004 to
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!