Question

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 populat...

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 folder called "exam" and navigate into that folder with the command:

cd exam

3. From inside your exam folder, copy the data.txt file from your root folder into the exam folder.

Now answer this question in the answer space:
What is the command that you typed at the Linux prompt to copy the file?

Question 3

What programming language was the immediate predecessor of the C language?

1

A

2

B

3

C++

4

C#

5

C-

6

Java

7

Python

8

Fortran

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Q1)

Location of max element:

max=0;
int maxLoc;
for(int i=0;i<n;i++){
if(array[i]>max)
{max=arr[i]
maxLoc=i;
}
printf("Location is max element is %d",macLox);
}

Q2)Linux Codes:

1)create a file in root folder:
touch /data.txt
2)mkdir exam
3)cp data.txt exam

Q3)

immediate predecessor of C language is B, which was created by Ken Thompson as part of the early development of the Unix operating system

if you like the answer please provide a thumbs up.

Add a comment
Know the answer?
Add Answer to:
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 populat...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • sort.c #include <stdlib.h> #include <stdio.h> #include "libsort.h" int main() {     int* array;     int size,...

    sort.c #include <stdlib.h> #include <stdio.h> #include "libsort.h" int main() {     int* array;     int size, c;     float median;     printf("Enter the array size:\n");     scanf("%d", &size);     array = (int*) malloc(size * sizeof(int));     printf("Enter %d integers:\n", size);     for (c = 0; c < size; c++)         scanf("%d", &array[c]);     sort(array, size);     printf("Array sorted in ascending order:\n");     for (c = 0; c < size; c++)         printf("%d ", array[c]);     printf("\n");     median = find_median(array,...

  • #include<stdio.h> #include<stdio.h> int main(){ int i; //initialize array char array[10] = {“Smith”, “Owen”, “Kowalczyk”, “Glass”, “Bierling”,...

    #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...

  • #include<stdio.h> voidmain() { int i = 0; while (i < 10) { printf("i is currently %d\n",...

    #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.

  • Hello, I need a c program called int* create_random_array(int n) that returns a random array of...

    Hello, I need a c program called int* create_random_array(int n) that returns a random array of size an. Alternatively, you can initialize a pointer to an array (called Rand) and write a function called void(create_array(int * Rand, int n) which assigns an array of size n to Rand. Note: Plese utilize rand(fi) and srand() from stdlib.h for this code

  • #include <stdio.h> // Define other functions here to process the filled array: average, max, min, sort,...

    #include <stdio.h> // Define other functions here to process the filled array: average, max, min, sort, search // Define computeAvg here // Define findMax here // Define findMin here // Define selectionSort here ( copy from zyBooks 11.6.1 ) // Define binarySearch here int main(void) { // Declare variables FILE* inFile = NULL; // File pointer int singleNum; // Data value read from file int valuesRead; // Number of data values read in by fscanf int counter=0; // Counter of...

  • #include<stdio.h> #include<stdlib.h> #include <time.h> int main() { /* first you have to let the computer generate...

    #include<stdio.h> #include<stdlib.h> #include <time.h> int main() { /* first you have to let the computer generate a random number. Then it has to declare how many tries the user has for the game loop. we then need the player to enter their guess. After every guess we have to give an output of how many numbers they have in the right location and how many they have the right number. The player will keep guessing until their 10 tries are...

  • How would I change the following C code to implement the following functions: CODE: #include <stdio.h>...

    How would I change the following C code to implement the following functions: CODE: #include <stdio.h> #include <stdlib.h> int main(int argc, char * argv[]) { if (argc != 2) printf("Invalid input!\n"); else { FILE * f = fopen (argv[1], "r"); if (f != NULL) { printf("File opened successfully.\n"); char line[256]; while (fgets(line, sizeof(line), f)) { printf("%s", line); } fclose(f); } else { printf("File cannot be opened!"); } } return 0; } QUESTION: Add a function that uses fscanf like this:...

  • Use the C programming language to complete #include <stdio.h> #include <stdlib.h> #include <float.h> // Declare Global...

    Use the C programming language to complete #include <stdio.h> #include <stdlib.h> #include <float.h> // Declare Global variables here. void array_stats() { // Insert your solution here. } #include <stdlib.h> #include <time.h> int main() { // Simulate the test setup process. srand( time( NULL ) ); for ( int i = 0; i < 32; i++ ) { val[i] = rand(); } val_count = rand(); val_mean = rand(); val_min = rand(); val_max = rand(); // Call submitted code. array_stats(); // Display...

  • Question 3 Predict the output of the following C program: #include <stdio.h> void main() { int...

    Question 3 Predict the output of the following C program: #include <stdio.h> void main() { int i = 0; for(; 1; i++){ printf("%d",i); if(i==7) break; } 12pt Paragraph 1 Β Ι Ο Αν και Ta

  • #include "stdio.h" int main() { float array[5][3],rowsum=0.0,colsum=0.0; int i,j; for(i=0;i<5;i++){ printf("Enter the %d elements of array:\n",i);...

    #include "stdio.h" int main() { float array[5][3],rowsum=0.0,colsum=0.0; int i,j; for(i=0;i<5;i++){ printf("Enter the %d elements of array:\n",i); for(j=0;j<3;j++){ scanf("%f",&array[i][j]); } } printf("Given table data:\n"); for(i=0;i<5;i++){ for(j=0;j<3;j++){ printf(" %0.1f",array[i][j]); } printf("\n"); } for(i=0;i<5;i++){ for(j=0;j<3;j++){ rowsum=rowsum+array[i][j]; } printf("sum of the %d row is %0.1f\n",i,rowsum); rowsum=0; } for(j=0;j<3;j++){ colsum+=array[j][i]; printf("Sum of %d coloumn is %0.1f\n",j,colsum); colsum=0; } return(0); } can someone help me to get the correct row sum and column sum in c program

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT