Solved

array indexed 11-25

Posted on 2000-03-01
4
224 Views
Last Modified: 2010-07-27
write a program that "creates" an array of int, that consist of 15 elements,indexed by numbers 11 to 25.
the array is to take 15 * sizeof(int)
bytes in memory.(answer has to be in "C" not "C++".
0
Comment
Question by:thesunboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:mprao
ID: 2582978
The following program will solve ur problem


#pragma warning (disable :4786)
#include <iostream>
#include <map>
using namespace std;

void main()
{
  map<int, int> m;  // This is a pair of Key & value . They are associated array.
  for (int i =11,j=100;i<=25 ;i++,j++)
        m[i]=j;
  for (i =11;i<=25 ;i++)
        cout <<"Key : " << i <<"  Value : " <<  m[i] <<endl;
 }
0
 

Author Comment

by:thesunboy
ID: 2610299
i need to solve it in
c and not c++
0
 

Author Comment

by:thesunboy
ID: 2610305
Edited text of question.
0
 

Accepted Solution

by:
042 earned 50 total points
ID: 2616049
int     main()
{
  int*  array;

  if (!(array = malloc(15*sizeof(int)))
    return (1);
  array -= 11;

/* do whatever you want */

  free(array + 11);
  return (0);
}

That's really awfull, i didn't write that, no I didn't!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question