Total members 11889 |It is currently Fri Mar 29, 2024 6:13 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





define an array size but with a dynamic and variable way.
cpp code
#include <stdio.h>

// Read in the indicated number of numbers, then print them backwards.
void rne(int arr[], int size)
{
for(int i = 0; i < size; ++i)
scanf("%d", &arr[i]);

printf("----------------------------------------------------\n");
int i;
for(i = size-1; i >= 0; --i)
printf("%d ", arr[i]);
printf("\n----------------------------------------------------\n");
}

main()
{
// Allocate with new C99 variable-sized arrays.
int size;
scanf("%d", &size);
int arr[size];
rne(arr, size);
}




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Variable Size Arrays
 different between Local variable and Global variable     -  
 Set image size as a percentage of the page size     -  
 PHP variable in javascript     -  
 Variable interpolation     -  
 transient variable     -  
 Unset variable     -  
 Testing the Type of a Variable     -  
 Delete session variable     -  
 how to call a global variable?     -  
 Passing a Reference Variable     -  



Topic Tags

C++ Arrays






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com