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
An ideal gas mixture has a volume base composition of 40% Ar and 60% Ne (monatomic gases). The mixture is now heated at constant
baherus [9]

[Find the attachment]

6 0
2 years ago
ANSWER QUICK<br>Why did Winston Churchill take over for Neville Chamberlain shortly after ww2? ​
kenny6666 [7]

Answer:neville chamberlain died

Explanation:

4 0
3 years ago
Refrigerant-134a at 400 psia has a specific volume of 0.1144 ft3/lbm. Determine the temperature of the refrigerant based on (a)
vekshin1

Answer:

a) Using Ideal gas Equation, T = 434.98°R = 435°R

b) Using Van Der Waal's Equation, T = 637.32°R = 637°R

c) T obtained from the refrigerant tables at P = 400 psia and v = 0.1144 ft³/lbm is T = 559.67°R = 560°R

Explanation:

a) Ideal gas Equation

PV = mRT

T = PV/mR

P = pressure = 400 psia

V/m = specific volume = 0.1144 ft³/lbm

R = gas constant = 0.1052 psia.ft³/lbm.°R

T = 400 × 0.1144/0.1052 = 434.98 °R

b) Van Der Waal's Equation

T = (1/R) (P + (a/v²)) (v - b)

a = Van Der Waal's constant = (27R²(T꜀ᵣ)²)/(64P꜀ᵣ)

R = 0.1052 psia.ft³/lbm.°R

T꜀ᵣ = critical temperature for refrigerant-134a (from the refrigerant tables) = 673.6°R

P꜀ᵣ = critical pressure for refrigerant-134a (from the refrigerant tables) = 588.7 psia

a = (27 × 0.1052² × 673.6²)/(64 × 588.7)

a = 3.596 ft⁶.psia/lbm²

b = (RT꜀ᵣ)/8P꜀ᵣ

b = (0.1052 × 673.6)/(8 × 588.7) = 0.01504 ft³/lbm

T = (1/0.1052) (400 + (3.596/0.1144²) (0.1144 - 0.01504) = 637.32°R

c) The temperature for the refrigerant-134a as obtained from the refrigerant tables at P = 400 psia and v = 0.1144 ft³/lbm is

T = 100°F = 559.67°R

7 0
3 years ago
Consider a dip-coating process where a very long (assume infinitely long) wire(solid) with radius, ri, is being pulled verticall
Gekata [30.6K]

Answer:

See explaination and attachment.

Explanation:

Navier-Stokes equation is to momentum what the continuity equation is to conservation of mass. It simply enforces F=ma in an Eulerian frame.

The starting point of the Navier-Stokes equations is the equilibrium equation.

The first key step is to partition the stress in the equations into hydrostatic (pressure) and deviatoric constituents.

The second step is to relate the deviatoric stress to viscosity in the fluid.

The final step is to impose any special cases of interest, usually incompressibility.

Please kindly check attachment for step by step solution.

6 0
3 years ago
A rigid tank contains 2 kg of N2 and 4 kg of Co2 at temperature of 25 C and 1 MPa. Find the partial pressure of each gas respect
lions [1.4K]

Answer: Partial pressures are 0.6 MPa for nitrogen gas and 0.4 MPa for carbon dioxide.

Explanation: <u>Dalton's</u> <u>Law</u> <u>of</u> <u>Partial</u> <u>Pressure</u> states when there is a mixture of gases the total pressure is the sum of the pressure of each individual gas:

P_{total} = P_{1}+P_{2}+...

The proportion of each individual gas in the total pressure is expressed in terms of <u>mole</u> <u>fraction</u>:

X_{i} = moles of a gas / total number moles of gas

The rigid tank has total pressure of 1MPa.

  • Nitrogen gas:

molar mass = 14g/mol

mass in the tank = 2000g

number of moles in the tank: n=\frac{2000}{14} = 142.85mols

  • Carbon Dioxide:

molar mass = 44g/mol

mass in the tank = 4000g

number of moles in the tank: n=\frac{4000}{44} = 90.91mols

Total number of moles: 142.85 + 90.91 = 233.76 mols

To calculate partial pressure:

P_{i}=P_{total}.X_{i}

For Nitrogen gas:

P_{N_{2}}=1.\frac{142.85}{233.76}

P_{N_{2}} = 0.6

For Carbon Dioxide:

P_{total}=P_{N_{2}}+P_{CO_{2}}

P_{CO_{2}} = P_{total}-P_{N_{2}}

P_{CO_{2}}=1-0.6

P_{CO_{2}}= 0.4

Partial pressures for N₂ and CO₂ in a rigid tank are 0.6MPa and 0.4MPa, respectively.

4 0
2 years ago
Other questions:
  • Anyone have 11th grade engineering on odyssey ware?
    8·1 answer
  • In normal operation, a paper mill generates excess steam at 20 bar and 400◦C. It is planned to use this steam as the feed to a t
    14·1 answer
  • **Please Help, ASAP**
    6·1 answer
  • Why why why why why why why
    7·2 answers
  • Can you screen record on WOW Presents Plus on iPhone?
    12·1 answer
  • A column carries 5400 pounds of load and is supported on a spread footing. The footing rests on coarse sand. Design the smallest
    10·1 answer
  • List the parts of a manual transmission <br><br> List the parts of a typical clutch assembly?
    14·1 answer
  • Rotating magnetic field inside a set of conducting wires is a simple description of a what
    14·1 answer
  • How to clean a snowblower carburetor without removing it.
    11·1 answer
  • Flip-flops are normally used for all of the following applications, except ________. logic gates data storage frequency division
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!