Assume G1 is a 32-bit unsigned global variable. We wish to write code that increments G1 if G1 is less than 35. Draw a flowchart of the process. Write the code in both C
Assume G1 is a 32-bit unsigned global variable. We wish to write code that increments G1 if G1 is less than 35. Draw a flowchart of the process. Write the code in both C
// Type your code here, or load an example.
int incr(int num) {
int g1=8;
while(g1<32){
g1=g1+1;
}
return 0;
}
incr(int):
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-20], edi
mov DWORD PTR [rbp-4], 8
jmp .L2
.L3:
add DWORD PTR [rbp-4], 1
.L2:
cmp DWORD PTR [rbp-4], 31
jle .L3
mov eax, 0
pop rbp
ret
Answer 2)
#include <stdio.h>
int main()
{
int n, sum = 0, c, value;
printf("How many numbers you want to add?\n");
scanf("%d", &n);
printf("Enter %d integers\n", n);
for (c = 1; c <= n; c++)
{
scanf("%d", &value);
sum = sum + value;
}
printf("Sum of the integers = %d\n", sum);
return 0;
}
Step by step
Solved in 2 steps with 1 images