#include<stdio.h>
voidmain() {
int i = 0;
while (i < 10) {
printf("i is currently %d\n", i);
++i;
}
}
Compile the code file using the command line. Copy the assembly code for just the _main sub-routineand paste it as your answer to this question and highlight the lines which corrospond to the ++i; statement from the source code.
answer:-i am saving this file as ex1.c then execute the command gcc -S ex1.c..then we will get a file named as ex1.s which contains the assembly code for the above code..so the assembly code for the main function of the above program is:-
main:
.LFB0:
.cfi_startproc
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
movl %esp, %ebp
.cfi_def_cfa_register 5
andl $-16, %esp
subl $32, %esp
movl $0, 28(%esp)
jmp .L2
.L3:
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl $.LC0, (%esp)
call printf
addl $1, 28(%esp) // this line corresponds to the ++i statement
.L2:
cmpl $9, 28(%esp)
jle .L3
leave
.cfi_restore 5
.cfi_def_cfa 4, 4
ret
.cfi_endproc
note:-i have commented the line. which corresponds to ++i ststement
#include<stdio.h> voidmain() { int i = 0; while (i < 10) { printf("i is currently %d\n",...
#include<stdio.h> int main() { int data[10], i, j, temp; printf("Enter 10 random number to sort in ascending order:\n"); for(i = 0; i < 10; i++) scanf("%d", &data[i]); /* Sorting process start */ ****** INSERT YOUR CODE TO COMPLETE THE PROGRAM ****** printf("After sort\n"); for(i = 0; i < 10; i++) printf("%d\n",data[i]); return 0; } Looking for alternative solutions for the program code.
i need flowchart for the following c code #include <stdio.h> int main() { int n, i, sum = 0; printf("Enter an integer: "); scanf("%d",&n); i = 1; while ( i <=n ) { sum += i; ++i; } printf("Sum = %d",sum); return 0; }
#include<stdio.h> eint main() { int i = 0, j = 0; while (i < 10|| j < 7) { i++; j++; } printf("%d, %d\n", i, j); getchar(); return 0; } 01,01 10,10 7.7 10,7
task1 code:
#include <stdio.h>
#include <sys/time.h>
int main()
{
struct timeval start,end; //to store time of starting and ending
of program
gettimeofday(&start,0);
printf("Time in microsecond for every second: \n"); //output
for(int i=0;i<100;i++) //outer loop to run 100 times
{
struct timeval loopstart,loopend; //to store time of starting
and ending of loop
gettimeofday(&loopstart,0); //measuring time at start of
loop
for(int j=0;j<1000000;j++); //outer loop to run 1000000
times
gettimeofday(&loopend,0); //measuring time at end of
loop
//calculating time for one iteration
long ms=(loopend.tv_sec-loopstart.tv_sec)*1000000...
#include<stdio.h> #include<stdio.h> int main(){ int i; //initialize array char array[10] = {“Smith”, “Owen”, “Kowalczyk”, “Glass”, “Bierling”, “Hanenburg”, “Rhoderick”, “Pearce”, “Raymond”, “Kamphuis”}; for(int i=0; i<8;i++){ for(int j=0; j<9; j++){ if(strcmp(array[j],array[j+1])>0){ char temp[20]; strcpy(temp,array[j]); strcpy(array[j],array[j+1]); strcpy(array[j+1],temp); } } } printf(“---------File Names---------\n”); for(inti=0; i<9; i++){ printf(“\t%s\n”,array[i]); } printf(-------5 Largest Files according to sorting----\n”); for(int i=0;i>=5;i--) { printf(“\t%s\n”,array[i]); } return0; } Consider the "sort" program (using with void* parameters in the bubblesort function) from the week 10 "sort void" lecture. Modify it as follows...
Question 1 In the following incomplete C program: #include stdlib.h> #include <stdio.h> int main () { int i, n, max; int array[100]; ... } return 0; } an array of random int values is populated with n random values. Write only the code to find the location of the maximum value in the array. Question 2 Follow these instructions in your Linux account: 1. Create a file called data.txt in the root folder in your account. 2. Create a new...
6. Consider the following program: #include <stdio.h> main() { int a,b,c,d ; a=0; while (1) { printf("%d\n", a); printf("Input? "); scanf("%d",&c); if (c == 0) break; d=0; for (b=1; b<=c; b++) if (c%b == 0) d++; if (d == 2 11 C == 1) a=a+c; } } What does this program do? Rewrite the code, organizing it using sound principles. Include comments and redo variable names and indentation. Use multiple functions, blocks, and/or preprocessing if you deem it necessary.
#include <stdio.h> int main(int argc, char *argv[]) { int i; for (i = argc - 1; i > 0; i--) printf("%s ", argv[i]); printf("\n"); return 0; } can you explain this code in c and why use this function
#include<stdio.h> int main() { int i; printf("Type an integer value: "); scanf("%d",&i); evaluate(i); return(0); } void evaluate(int x) { if(x > 10) printf("Value entered by you is greater than 10"); else if(x < 10) printf("Value entered by you is less than 10"); else printf("Value entered by you is equal 10"); } _______________________________________ report for this in hr ?
What is the functionality of the following code? #include #include mainO <stdio.h> <unistd.h> int i,j; j-0: printf ("Ready to fork.n) i-fork; if 0) this code.\n"); printf "The child executes for (i-0; i?5; i++) printf("Child j-dn".j); else j-vaito printf("The parent executes this code. Ln" printf ("Parent j-dn",j);