The above array is a declaration of an array of type integer

Assignment Help C/C++ Programming
Reference no: EM13748948

TypeofArray nameOfArray [theSizeOfArray];

For instance,

int studentMark [10];

The above array is a declaration of an array of type integer. The name of the array is studentMark, and the array is of size 10.

Arrays in C can be initialized by using a single statement that declares the array or by breaking it into two statements. In the first instance, the above array will appear as follows:

int studentMark [10] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 99};

Alternatively,

int studentMark [10];

studentMark [0] =10;

studentMark [1] =20;

An example illustrating all of the concepts above is as follows,

/* program that prints out five numbers */

#include <stdio.h>

int main ()

{

int numbers[5];

int m, n;

/*initializing array elements */

for (m =0; m<= 5; m++){

numbers[m] =m;

}

/*outputting the values in an array */

for (n =0; n <=5; n++)

{

printf ("Number [%d] =%dn", n, numbers[n]);

}

return 0;

}

}

The output from the code above appears below,

Number [0] =1;

Number [0] =2;

Number [0] =3;

Number [0] =4;

Number [0] =5;


Did you intend for your array to over write the values, it looks as though it wrote all of the numbers to the same element [0], or am I reading it wrong, which is highly possible. 

Reference no: EM13748948

Questions Cloud

Identify the extent of social media : Identify the extent of social media, if any, that is used to communicate with customers or prospects to include customer service interaction
Patient volume needed per month to cover fixed-variable cost : Monia Lee, administrative director of Digital Imaging Center, has been asked by the practice members to see if it is feasible to add more staff to support the practice;s mammography service, which currently has two digital units and two technologists..
Write a paper on fact meets fiction made-up cinematography : Write a paper on Fact meets Fiction: Made- up Cinematography & Real History? Based on the movie, Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb.
Presentation on challenges in global business environment : Challenges in the Global Business Environment PowerPoint Presentation
The above array is a declaration of an array of type integer : The above array is a declaration of an array of type integer. The name of the array is studentMark, and the array is of size 10. Arrays in C can be initialized by using a single statement that declares the array or by breaking it into two statements...
Philosophical essay : Philosophical Essay: You will write a two-part 5-6 page essay, According to Socrates, must one heed popular opinion about moral matters? Does Socrates accept the fairness of the laws under which he was tried and convicted? Would Socrates have bee..
Operating lease agreement : On January 1, 2013, Salvatore Company leased several machines from Nola Corporation under a three-year operating lease agreement. The lease calls for semiannual payments of $15,000 each, payable on June 30 and December 31 of each year. The machines w..
Using the effective interest method : On January 1, 2013, Mania Enterprises issued 12% bonds dated January 1, 2013, with a face amount of $20 million. The bonds mature in 2022 (10 years). For bonds of similar risk and maturity, the market yield is 10%. Interest is paid semiannually on Ju..
Identify key point of either jefferson or jackson presidency : Identify one of the key points of either Jefferson's or Jackson's presidency. How was it received by the general public? How did it strain relations with the Native Americans? Or other nations?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Powers of a user specified range of integer numbers

Write a C program to print a table of the powers of a user specified range of integer numbers. The program should also print the sum of the powers of the numbers.

  Write a complete c++ program

The main program will read in a parameter value n (read this in main). Then it will call a function read2arrays (details below) to read lists of grades into two arrays, which the main program will call test1 and test2 (or some other names of your ..

  Why are forward declarations needed in c

Why are forward declarations needed in C/C++? In what condition can they be omitted?  (Please describe.)

  Explain in a one to two 1-2 page narrative a use case

as an intern software developer for a retail bank you have been tasked with developing use cases to support the atm

  Design and implement a class called bus

Define the Bus constructor to accept and initialize all instance data. Include getter and setter methods for all instance data.

  Difference between classes and struct in c++

what's the difference between classes and struct in c++?

  Prepare a program that prints the multiplication table

Prepare a program that prints the multiplication table for numbers 1 to 9. The program should include two nested loops and compute the products and print them

  Compare run times using an array

Write a iterative and recursive versions of binary search and compare their run times using the array a[i]=i, i=0,...,n-1 and the subsequent test method:

  Accept positive and negative numbers in its input sequence

the program must accept positive and negative numbers in its input sequence, and ?nd the largest and smallestof the numbers entered whether they are all positive, all negative, or a combination of both positive and negative.

  The westfield carpet company has asked you to write an

the westfield carpet company has asked you to write an application that calculates the price of carpeting for

  Program to check compatibity for matrix multiplication

Write down program in C++ for matrix multiplication. Program must accept dimension of both matrices to be multiplied and check for compatibity.

  Program to compute the total volume

Write a program to compute the total volume for a number of cylinders. A cylinder may have different values for height and radius.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd