I need help and I'm stuck on this program. I have to do it in the C language on my Linux system. Can someone help me with this please? I have included my instructions and sample output. Thank you
-Initialize 2 arrays within the main method, one with odd numbers and one with even numbers.
-In the main method swap the arrays.
-Print the arrays before and after the swap.
//output should look like the following
Before Swap
firstArray[0] = 0, secondArray[0] = 1
firstArray[1] = 2, secondArray[1] = 3
firstArray[2] = 4, secondArray[2] = 5
firstArray[3] = 6, secondArray[3] = 7
firstArray[4] = 8, secondArray[4] = 9
After Swap
firstArray[0] = 1, secondArray[0] = 0
firstArray[1] = 3, secondArray[1] = 2
firstArray[2] = 5, secondArray[2] = 4
firstArray[3] = 7, secondArray[3] = 6
firstArray[4] = 9, secondArray[4] = 8
If you have any doubts, please give me comment...
#include<stdio.h>
int main(){
const int n = 5;
int firstArray[n], secondArray[n];
int i, k=0, temp;
for(i=0, k=0; k<n; i+=2, k++){
firstArray[k] = i;
secondArray[k] = i+1;
}
printf("Before Swap\n");
for(i=0; i<n; i++){
printf("firstArray[%d] = %d, secondArray[%d] = %d\n", i, firstArray[i], i, secondArray[i]);
}
//swapping
for(i=0; i<n; i++){
temp = firstArray[i];
firstArray[i] = secondArray[i];
secondArray[i] = temp;
}
printf("After Swap\n");
for(i=0; i<n; i++){
printf("firstArray[%d] = %d, secondArray[%d] = %d\n", i, firstArray[i], i, secondArray[i]);
}
return 0;
}

I need help and I'm stuck on this program. I have to do it in the...
I need some help on Java. I'm stuck on trying to generate a new string by concatenating the reversed substrings of even indexes and odd indexes separately from a given string. I'm not sure how to figure this out. See example. Example: Input: abscacd Output: dasaccb Substrings: asad, bcc Reversed substrings: dasa, ccb.
I'm trying to code a C program so it sorts an array of integer numbers of size n in ascending order. My code is written below but its not working properly, its giving me errors, I think my sort and swap functions aren't done right maybe, please help and fix. It says "undefined reference to "SelectionSort" as an error. But the question asks to not change the PrintArray and Main function. #include <stdio.h> void PrintArray(int size, int array[]) { for...
Hey, need some help in Java. I'm stuck on one step that prevents me from doing the rest of the steps and need help on it. I also have a problem when I print databaseCourse and programmingCourse. instead of saying 5 and 7 respectively is shows 51 and 71. Step 8: in CourseGrades, create a method, add, that takes two parameters, studentNum and grade, and changes the grade of student studetNum to the given grade, grade. studentNum represents the student...
I need help with coding with c++. I need to make a lottery program where you enter in 5 numbers from 0-9 and the program will generate 5 random numbers 0-9 to represent the lottery numbers. I'm almost done, but the output isn't exactly what I want. It works fine, but the format should look like this: lottery array: 7 4 9 1 3 user array: 4 2 9 7 p.s. I also need to count how many matching numbers...
Hey, i'm super stuck on my lab in cs102. I have attempted it but never got close to what the end result should be. Please help, due in 2 days!! Assignment You will be writing a program to simulate a slot machine. The player will start with $1000 and you will repeatedly ask the user how much money they wish to insert into the machine before spinning, or allow the player to quit. If the player runs out of money,...
Write a complete Java program, including comments in both the main program and in each method, which will do the following: 0. The main program starts by calling a method named introduction which prints out a description of what the program will do. This method is called just once. This method is not sent any parameters, and it does not return a value. The method should print your name. Then it prints several lines of output explaining what the...
I'm stuck on this question and I have a hard time figuring
this out, this used as C++
Question 26 10 pts (SHORT ANSWER) Use a loop to calculate and print the sum of numbers from 1 to 10 (both numbers inclusive). Use additional variable(s) as necessary. For example your output should display as follows: Sum of numbers 1-10 = 55 BIVA-A-I EI 1 XX, EE 2.2 VX T 1 12pt - Paragraph O words
I'm quite stuck with this C++ question, I would greatly appreciate the help! Many companies use telephone number like 888- COM - CAST so the number is easier for their customer to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion. A, B, and C = 2 D, E, and F = 3 G, H, and I = 4 J , K , and L = 5 M, N, and O = 6...
I'm really stuck I need help. C++ Draw separate flowcharts to solve each of the following problems: Read in 20 numbers and write out how many of them were positive (write out the count, not the actual input numbers). Read in numbers until the user chooses to quit. Write out the smallest of the input values. (Make it so that the user has to enter at least one value) Read in numbers until 10 positive values have been found. Write...
WRITE A PROGRAM IN C++ THAT DECLARES AN INTEGER VECTOR V 1.)INITIALIZE THE VECTOR, V, WITH 10 INTEGERS WITH VALUES FROM 1 TO 10 2.)OUTPUT THE VECTOR IN DESCENDING ORDER, THEN ASCENDING ORDER 2.)ADD ALL THE EVEN NUMBERS 3.)ADD ALL THE ODD NUMBERS 4.)OUTPUT THE SUM OF EVEN INTEGERS 5.)OUTPUT THE SUM OF ODD INTEGERS 7.)OUTPUT THE PRODUCT OF EVEN INTEGERS 8.)OUTPUT THE PRODUCT OF ODD INTEGERS SAMPLE: Vector: 2 4 3 5 2 3 8 9 1 10 Ascending...