Solved

array indexed 11-25

Posted on 2000-03-01
4
219 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now