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

  Evaluate the circumference of a circle

Write a program that will call a function to calculate the area of a circle, and call another function to calculate the circumference of a circle.

  Basics of code development on linux and cryptographya

basics of code development on linux and cryptographya prepare a c program that gives simple mono-alphabetic

  Two dimensional int array to hold the prices of the seats

The Theater class shows a theater with an auditorium containing a fixed number of seats arranged in rows with each seat selling for a exacting price. The instance variables for the theater are:

  Reads numbers from input and prints them in reverse order

Write a C program that reads ten numbers from input and prints them in reverse order. We assume that the data consists of integers. The program should conform to the following format:

  Calculates the sum of the cube roots of two integers.

Wrtie a program that calculates the sum of the cube roots of two integers. The program should use the following functions as well as a main funcion. 1) enter one positive value 2) compute the cube root of one integer 3) report the value of two intege..

  The first will be a structure called point

Create two structures. The first will be a structure called Point and will have as its data members an x and y coordinate. The second will be called Line and will have two Point structures as its data members.

  Create a serial object s

The function call operator is overloaded and will generate a sequential integer each time the operator is used and the object can be created with the sequence start value specified.

  First display the smallest volume and then the largest volum

first display the smallest volume and then the largest volume.

  Function that returns the height of a binary tree

Write a function called getHeight() that returns the height of a given binary tree - CptS 122 Write a function called countSmallerThan() that returns the number of nodes whose values are smaller than the supplied input paramter

  Write a c function that converts a character to upper case.

Write a C function that converts a character to upper case. The function should have the prototype char to_upper(char ch); The characters given as input to the function are assumed to be in the sets {'a', ..., 'z'} and {'A', ... , 'Z' }. Do not use a..

  Credit card is mastercard or visa card

Write  a C++ program  that  reads  the  card  type  and  the  card  number  and  then determine  if  the  card number entered is a valid card number

  Write a pseudo code and perform algorithm analysis

Write a pseudo code and perform algorithm analysis to show the complexity is Log N - Suppose that you have an N-story building and plenty of eggs.

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