+ 8

How can I write a code to initialize an integer array with the following description

Integer array of 1000 elements to {1,2,3,4,5,......,1000} Integer array of 1000 elements to {1000,999,998,.....1} Pls will really appreciate your comment

4th Jan 2020, 9:57 AM
Princez Beauty
44 ответов
+ 8
The guy just gave you the much needed help you requested for. He even explained it from start on how you can initialize your array the way yoh wanted for your code to run... Hey do this, i would suggest that you start your course afresh and work with each and every example yoy have been given in the course (practise makes perfect) then you will be able to write your own code. Asking the guy ~ swim ~ to write you thr code is more like cheating, remember you said you have a pending exam and you need to pass it right? Well if so, then if the guy writes you the code, you will not get what to answer in your exam, i suggest watching youtube videos on your cpp course from beginner level and you will be where you want. Happy coding😉 Keep coding🙏🏾
4th Jan 2020, 11:03 AM
Alfred Juma
Alfred Juma - avatar
+ 4
Ipang "underages" ?!??😂😂😂
4th Jan 2020, 11:18 AM
Art456
Art456 - avatar
+ 3
Princez Beauty Please mind language buddy!
4th Jan 2020, 11:10 AM
Ipang
+ 3
Here is my solution in c# int arr = new int[1000]; for(int i = 0; i<len(arr); i++) arr[i] = i+1 //this will generate 1 to 1000 for(int i = 1000; i>0;i--) arr[i] = i //this will generate 1000 to 1 In python arr = [x for x in range(1,1001)] #This will generate 1 to 1000 arr = [x for x in range(1000,0,-1)] #This will generate 1000 to 1
5th Jan 2020, 4:52 PM
Vuyisile Lucas Ncipha
Vuyisile Lucas Ncipha - avatar
+ 3
In php ----------------------- $a = array(); For($i = 1; $i≤1000; $i++) {$a[] = $i;} ----------------------- $b = array(); For($i = 1000; $i≥1; $i--) {$b[] = $i;}
5th Jan 2020, 5:41 PM
ADEL MAHMOUD HUSSEIN
ADEL MAHMOUD HUSSEIN - avatar
+ 2
"I just need 2 pass my f* exam" Please understand we have underages here. Show good example?
4th Jan 2020, 11:13 AM
Ipang
+ 2
We all make mistakes buddy, But can you please censor that word? I'd be grateful if you would 👍
4th Jan 2020, 11:19 AM
Ipang
+ 2
Props to ~ swim ~ for taking his time to reply to this nonsense
5th Jan 2020, 11:00 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 1
Am not a computer student and I know nothing concerning it so will b grateful if u can answer me or check if am correct or not
4th Jan 2020, 10:21 AM
Princez Beauty
+ 1
Thanks
4th Jan 2020, 11:08 AM
Princez Beauty
+ 1
Ok am sorry 4 that my bad pls 4give me
4th Jan 2020, 11:16 AM
Princez Beauty
+ 1
😭😭😭😭😓
4th Jan 2020, 11:20 AM
Princez Beauty
+ 1
Run any loop to assign the number to respective array.
4th Jan 2020, 3:44 PM
Abhishek nirwan
Abhishek nirwan - avatar
+ 1
//as in c language int arr[1000]; I=1; while(I) { if(l==1001) {Break;} arr[I-1]=l; I++; } //basic idea
4th Jan 2020, 3:49 PM
Abhishek nirwan
Abhishek nirwan - avatar
+ 1
JAY AJ i like that array definition. Princez Beauty work with this, and add it in your code
5th Jan 2020, 10:45 AM
Alfred Juma
Alfred Juma - avatar
0
Don't know if am correct
4th Jan 2020, 10:15 AM
Princez Beauty
0
Sorry
4th Jan 2020, 10:20 AM
Princez Beauty
0
If am wrong then u correct me plssss am not asking 4 much I want 2 learn
4th Jan 2020, 10:23 AM
Princez Beauty
0
You must declare an int array of size 1000 ints int arr[1000]; run a for loop from 1 to 1000 to store the values into it int i; /*for count elements*/ for (i = 0; i < 1000; i++) arr[i] = i+1; Indexing from 0 to 999 not from 1 to 1000. This will initialize array values from 1 to 1000 Now you should be able to write a code if you want to store the values from 1 to 1000:
5th Jan 2020, 4:15 AM
JITENDRA KUMAR
JITENDRA KUMAR - avatar
0
Hi
5th Jan 2020, 10:34 AM
Rocky Coder
Rocky Coder - avatar