Question

The array declaration in the following C program: main() { int a[10]; } can be replaced...

The array declaration in the following C program:
main() { int a[10]; }

can be replaced by which of the following:

A

#include <stdlib.h>
main() { int* a = (int *)malloc(10*sizeof(int)); }

B

#include <stdlib.h>
main() { int[] a = new int[10]; }

C

#include <stdlib.h>
main() { int* a = new int[10]; }

D

#include <stdlib.h>
main() { int* a = (int *)malloc(20*sizeof(float)); }

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
The array declaration in the following C program: main() { int a[10]; } can be replaced...
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
  • Hi, I need to make a program in C that reads the type of currency and...

    Hi, I need to make a program in C that reads the type of currency and organizes them into stacks based on currency which can be read back. This is what I have so far, can I get help finishing it? #include <stdio.h> #include <stdlib.h> const float POUND = 1.31; const float YEN = 0.0091; const float RUPEE = 0.014; const float EURO = 1.11; char c; int currValue; float exchangeValue; float finValue; int printValue; struct node {    int...

  • 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,...

  • Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array...

    Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...

  • Assume you have the following declaration (in main) : int num[10] [7]; Assume that array num...

    Assume you have the following declaration (in main) : int num[10] [7]; Assume that array num is filled completely. Write functions to perform each of the following: a) A function that prints all elements in the array that are greater than 10 or less than 50. b) A function that finds the largest number in the array and returns its subscript. c) A function that finds and returns the average of all the numbers in the array. d) A function...

  • Arrays C++ #include <iostream> using namespace std; int main() {       int   tests[6]; // array declaration...

    Arrays C++ #include <iostream> using namespace std; int main() {       int   tests[6]; // array declaration       int   sum = 0;       float avg;       //input test scores       cout << " Enter " << 6 << " test scores: " << endl;       for (int i = 0; i < 6; i++)       {             cout << "Enter Test " << i + 1 << ": ";             cin >> tests[i];       }       return 0; }    Type...

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

  • C++ What is the result of the following program? #include <algorithm> int main() {int x =...

    C++ What is the result of the following program? #include <algorithm> int main() {int x = 10; int *y = &x; int *z = new int; z[0] = 20; std::swap (y, z); return x;} (A) Does not compile. (B) Runtime Error or Undefined Behavior (C) Returns 10 (D) Returns 20

  • #include <stdlib.h> int main() { struct fruit Z; food X = (struct fruit *)malloc(sizeof(struct fruit)); X->taste[4]...

    #include <stdlib.h> int main() { struct fruit Z; food X = (struct fruit *)malloc(sizeof(struct fruit)); X->taste[4] = (struct flavour *)malloc(sizeof(struct flavour)); X->taste[4]->score = 5; X->link = &Z; return 0; } Given the code above, reverse engineer the necessary data structure and other definitions not shown above. Give your answer as C code.

  • Please show all your work PROBLEM 5 (10 points) Consider the following code in syntax and...

    Please show all your work PROBLEM 5 (10 points) Consider the following code in syntax and assume stack memory allocation for nested scope is used. In the following questions, write None if none apply #include <stdlib.h> intess a; // memory a int main 0 { intes b; // memory B + inte c; // memory s c - (int) malloc(sizeof (int)); // memory 1 (int**) malloc(sizeof(int:)); // memory 2 b b - &c; a - (int***) malloc(sizeof (int**)); // memory...

  • Q.25. Given the following program, you are asked to discuss memory leaks caused in its execution....

    Q.25. Given the following program, you are asked to discuss memory leaks caused in its execution. Determine which memory locations get uncontrolled. (2 points) 4 6 7 8 9 10 11 12 B 13 14 15 16 17 18 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 5 void main() { char *aString = "Memory leaks?"; char **strList; int i, n = 5; strlist = (char**)malloc(n*sizeof(char*)); for (i=0; i<n; i++) { printf("\nstring %d ", i+1); strList[i] = (char*)malloc(50*sizeof (char));...

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