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
Ultimate tensile strength is: (a) The stress at 0.2% strain (b) The stress at the onset of plastic deformation (c) The stress at
MissTica

Answer:

By definition the ultimate tensile strength is the maximum stress in the stress-strain deformation. The stress at 0.2% strain, the stress at the onset of plastic deformation, the stress at the end of the elastic deformation and the stress at the fracture correspond, by definition, to other points of the stress-strain curve.

Explanation:

4 0
3 years ago
Indicate the correct statement about the effect of Reynolds number on the character of the flow over an object.
sergeinik [125]

Answer:

If Reynolds number increases the extent of the region around the object that is affected by viscosity decreases.

Explanation:

Reynolds number is an important dimensionless parameter in fluid mechanics.

It is calculated as;

R_e__N} = \frac{\rho vd}{\mu}

where;

ρ is density

v is velocity

d is diameter

μ is viscosity

All these parameters are important in calculating Reynolds number and understanding of fluid flow over an object.

In aerodynamics, the higher the Reynolds number, the lesser the viscosity plays a role in the flow around the airfoil. As Reynolds number increases, the boundary layer gets thinner, which results in a lower drag. Or simply put, if Reynolds number increases the extent of the region around the object that is affected by viscosity decreases.

5 0
3 years ago
If a 9V battery produces a current of 3 A through a load, what is the resistance of the load
Elden [556K]

3 ohms hope this helps :D ❤

7 0
3 years ago
Read 2 more answers
Can some help me with this !!! Is 26 points!!
Aleonysh [2.5K]
Third one
15,000,000 ohms because M=10^6
8 0
3 years ago
Your program will be a line editor. A line editor is an editor where all operations are performed by entering commands at the co
soldier1979 [14.2K]

Answer:

Java program given below

Explanation:

import java.util.*;

import java.io.*;

public class Lineeditor

{

private static Node head;

 

class Node

{

 int data;

 Node next;

 public Node()

 {data = 0; next = null;}

 public Node(int x, Node n)

 {data = x; next =n;}

}

 

public void Displaylist(Node q)

 {if (q != null)

       {  

        System.out.println(q.data);

         Displaylist(q.next);

       }

 }

 

public void Buildlist()

  {Node q = new Node(0,null);

       head = q;

       String oneLine;

       try{BufferedReader indata = new

                 BufferedReader(new InputStreamReader(System.in)); // read data from terminals

                       System.out.println("Please enter a command or a line of text: ");  

          oneLine = indata.readLine();   // always need the following two lines to read data

         head.data = Integer.parseInt(oneLine);

         for (int i=1; i<=head.data; i++)

         {System.out.println("Please enter another command or a new line of text:");

               oneLine = indata.readLine();

               int num = Integer.parseInt(oneLine);

               Node p = new Node(num,null);

               q.next = p;

               q = p;}

       }catch(Exception e)

       { System.out.println("Error --" + e.toString());}

 }

public static void main(String[] args)

{Lineeditor mylist = new Lineeditor();

 mylist.Buildlist();

 mylist.Displaylist(head);

}

}

7 0
3 years ago
Other questions:
  • A forklift raises a 90.5 kg crate 1.80 m. (a) Showing all your work and using unity conversion ratios, calculate the work done b
    14·2 answers
  • A power plant operates on a regenerative vapor power cycle with one open feedwater heater. Steam enters the first turbine stage
    15·1 answer
  • 5) Two concentric spheres of diameter D1= 70 cm and D2= 120 cm are separated by an air space and have surface temperatures of T1
    13·1 answer
  • What might cause a shotgun to explode?
    6·2 answers
  • a vertical cylindrical container is being cooled in ambient air at 25 °C with no air circulation. if the initial temperature of
    12·2 answers
  • What is the best way to submit your assignments?
    11·2 answers
  • According to the video, what are some tasks that Construction Managers perform? Check all that apply.
    9·2 answers
  • 5. Liam is working on a circuit and notices it's quite hot to the touch. What's causing the heat Liam Is noticing
    6·1 answer
  • What material are the rocker/valve cover gaskets made out of?
    5·1 answer
  • This test should be performed on all cord sets, receptacles that aren't part of a building or structure's permanent wiring, and
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!