Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

array indexed 11-25

Posted on 2000-03-01
4
Medium Priority
?
228 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 100 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

650 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