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
bonufazy [111]
3 years ago
14

I need help to find out what is wrong with this program and my variable, "exponent" comes out as 0 in the output instead of the

number i typed, "3".

Computers and Technology
1 answer:
sweet-ann [11.9K]3 years ago
3 0

You're substracting one from the variable "exponent" with every iteration of the loop, and you told it to break out of the loop once "exponent" is 0, therefore, it's always going to end up as 0 at the end.


If you want to keep the input from the user, then declare another variable like "counter" and assign the value of "exponent" to it and use it for the loop


Or even better, do this for the loop:

for(int i = 0; i < exponent; i++)

{

//Code here

}

You might be interested in
If you're searching for a date and a product at the same time, you're running a _______ query. A. Complex B. Select C. Parameter
Andrews [41]

If you're searching for a date and a product at the same time, you're running a _______ query. A. Complex B. Select C. Parameter D. Range                                                                                                                                                                                                                                                         A. Complex

6 0
3 years ago
Write a procedure named Str_find that searches for the first matching occurrence of a source string inside a target string and r
kirill115 [55]

Answer: Provided in the explanation section

Explanation:

Str_find PROTO, pTarget:PTR BYTE, pSource:PTR BYTE

.data

target BYTE "01ABAAAAAABABCC45ABC9012",0

source BYTE "AAABA",0

str1 BYTE "Source string found at position ",0

str2 BYTE " in Target string (counting from zero).",0Ah,0Ah,0Dh,0

str3 BYTE "Unable to find Source string in Target string.",0Ah,0Ah,0Dh,0

stop DWORD ?

lenTarget DWORD ?

lenSource DWORD ?

position DWORD ?

.code

main PROC

  INVOKE Str_find,ADDR target, ADDR source

  mov position,eax

  jz wasfound           ; ZF=1 indicates string found

  mov edx,OFFSET str3   ; string not found

  call WriteString

  jmp   quit

wasfound:                   ; display message

  mov edx,OFFSET str1

  call WriteString

  mov eax,position       ; write position value

  call WriteDec

  mov edx,OFFSET str2

  call WriteString

quit:

  exit

main ENDP

;--------------------------------------------------------

Str_find PROC, pTarget:PTR BYTE, ;PTR to Target string

pSource:PTR BYTE ;PTR to Source string

;

; Searches for the first matching occurrence of a source

; string inside a target string.

; Receives: pointer to the source string and a pointer

;    to the target string.

; Returns: If a match is found, ZF=1 and EAX points to

; the offset of the match in the target string.

; IF ZF=0, no match was found.

;--------------------------------------------------------

  INVOKE Str_length,pTarget   ; get length of target

  mov lenTarget,eax

  INVOKE Str_length,pSource   ; get length of source

  mov lenSource,eax

  mov edi,OFFSET target       ; point to target

  mov esi,OFFSET source       ; point to source

; Compute place in target to stop search

  mov eax,edi    ; stop = (offset target)

  add eax,lenTarget    ; + (length of target)

  sub eax,lenSource    ; - (length of source)

  inc eax    ; + 1

  mov stop,eax           ; save the stopping position

; Compare source string to current target

  cld

  mov ecx,lenSource    ; length of source string

L1:

  pushad

  repe cmpsb           ; compare all bytes

  popad

  je found           ; if found, exit now

  inc edi               ; move to next target position

  cmp edi,stop           ; has EDI reached stop position?

  jae notfound           ; yes: exit

  jmp L1               ; not: continue loop

notfound:                   ; string not found

  or eax,1           ; ZF=0 indicates failure

  jmp done

found:                   ; string found

  mov eax,edi           ; compute position in target of find

  sub eax,pTarget

  cmp eax,eax    ; ZF=1 indicates success

done:

  ret

Str_find ENDP

END main

cheers i hoped this helped !!

6 0
3 years ago
PLEASEE HELPP.... QUESTION... how does coding impact your life​
nataly862011 [7]

Answer: It allows us to do everyday tasks on the internet

Explanation: We wouldn’t be able to email, research, etc without coding!

6 0
2 years ago
Read 2 more answers
What are the letter that go under each note?
gladu [14]

Answer:

A, B, C, D, E, F, G pls mark me brainliest see explanation below

Explanation:

those are the letters if you search up letters for music you can find them way easier than me explaining and you will also learn faster. please mark me brainliest

5 0
2 years ago
Read 2 more answers
Where can I find answer key for electrician systems based on NEC 2017
lisov135 [29]

google or search through pvps

6 0
3 years ago
Other questions:
  • Consider a file system that uses inodes to represent files. Disk blocks are 2KB in size and a pointer to a disk block requires 4
    13·1 answer
  • What are the two components that make up the chipset?
    15·1 answer
  • What is the use of ROM chip in computer system?​
    13·1 answer
  • Is technology a legal discipline or law is a technological artifact.
    6·1 answer
  • Favorite color should it be stored why?or why not?<br>​
    6·1 answer
  • Queues can be represented using linear arrays and have the variable REAR that point to the position from where insertions can be
    12·1 answer
  • Does a 21.6v battery work with a 24 volt controller
    6·1 answer
  • Cloud architects have been largely replaced by ScrumMasters.<br><br> True<br><br> False
    15·2 answers
  • The ratio of sparrows to bluejays at the bird sanctuary was 5 to 3 If there were 15 bluejays in the sanctuary, how many sparrows
    12·1 answer
  • If html is used to specify the content of the webpage, then what do you use css for?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!