SlideShare a Scribd company logo
1 of 9
Download to read offline
1sequences and sampling. Suppose we went to sample the x-axis from Xmin to Xmax using a
step size of step
A)Draw a picture of what is going on.
B) Write a expression for n the total number of samples involved (in terms of Xmin, Xmax and
step)
C) Write out the sequence of x-samples
D) Write a direct and general expression for xi that captures the sequence
E) Write a recursive expression for the sequence
F) Write a program to compute and store the x-samples over the range -5x5 using a step size of
0.1 do everything in main ()
2 . We talked about the following string functions that are available in C (as long as you include
string.h):
int strlen(char str[])
void strcpy(char str1[], char str2[])
void strcat(char str1[], str2[])
Write your own versions of these functions; for example: int paul_strlen(int char str[]). Hint: for
your version of the strlen function, start at the first character in the array and keep counting until
you find the β€˜0’ character (use a while loop for this). Note: Use your version of the strlen
function in the strcpy and strcat functions.
9. We want to insert a number into an array.
(a) Formulate the problem mathematically with two sequences: x and y. (b) Write a function of
the form:
insertNumIntoArray(int n, int array[], int num, int index)
The function inserts num into the array at the specified index. The rest of the array then follows.
For example, if num = 9 and index = 3 and array = [7 2 8 8 3 1 2] then the function will produce:
array = [7 2 8 9 8 3 1 2]
Note: assume that array is properly dimensioned to have at least 1 extra space for storage.
10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a
specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20],
then the result will be
array: [50 70 10 60 20]
11. Repeat #2 by for an insert operation where we are inserting several values into the array. The
function should be of the form:
int insertArrayIntoArray(int n, int inArray[],
int nInsert, int insertArray[], int outArray[], int index)
The dimension of outArray is returned (explicitly). For example:
inArrayarray: [7 2 8 6 3 9]
insertArray: [50 60 70]
index: 2
outArray: [7 2 50 60 70 8 6 3 9]
Assume that outArray is large enough to hold all n + nInsert values.
Solution
#include
//Simulates strlen() library function
int paul_strlen(char str[])
{
int l;
for(l = 0; str[l] != '0'; l++) ;
return l;
}
//Simulates strcpy() library function
void paul_strcpy(char str1[], char str2[])
{
int c;
for(c = 0; str1[c] != '0'; c++)
str2[c] = str1[c];
str2[c] = '0';
printf(" Original String: %s", str1);
printf(" Copied String: %s", str2);
}
//Simulates strcat() library function
void paul_strcat(char str1[], char str2[])
{
int i, j;
for(i = 0; str1[i] != '0'; i++) ;
for (j = 0; str2[j] != '0'; i++, j++)
{
str1[i] = str2[j];
}
str1[i] = '0';
printf(" Concatenated String: %s", str1);
}
int main()
{
char data1[20], data2[20];
printf(" Enter a string: ");
gets(data1);
printf(" Length of the String: %d", paul_strlen(data1));
printf("  Enter a string: ");
gets(data1);
paul_strcpy(data1, data2);
printf("  Enter a string1: ");
gets(data1);
printf("  Enter a string2: ");
gets(data2);
paul_strcat(data1, data2);
}
Output:
Enter a string: pyari
Length of the String: 5
Enter a string: Pyari sahu
Original String: Pyari sahu
Copied String: Pyari sahu
Enter a string1: pyari
Enter a string2: mohan
Concatenated String: pyarimohan
9. We want to insert a number into an array.
Answer:
#include
//Insert a number at specified location
void insertNumIntoArray(int n, int array[], int num, int index)
{
int c;
//Creates a place for insert
for (c = n - 1; c >= index; c--)
array[c + 1] = array[c];
//Stores the number at specified location
array[index] = num;
printf("Resultant array is ");
for (c = 0; c <= n; c++)
printf("%d ", array[c]);
}
int main()
{
int array[20];
int n, c, num, index;
printf("Enter number of elements in array ");
scanf("%d", &n);
printf("Enter %d elements ", n);
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
printf("Enter the location where you wish to insert an element ");
scanf("%d", &index);
printf("Enter the value to insert ");
scanf("%d", &num);
insertNumIntoArray(n, array, num, index);
}
Output:
Enter number of elements in array
7
Enter 7 elements
7
2
8
8
3
1
2
Enter the location where you wish to insert an element
3
Enter the value to insert
9
Resultant array is
7
2
8
9
8
3
1
2
10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a
specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20],
then the result will be
Answer:
#include
//Delete an item from a specified position
void deleteNumFromArray(int n, int array[], int index)
{
int c;
//Validates for deletion
if ( index >= n+1 )
printf("Deletion not possible. ");
else
{
//Moves the elements
for ( c = index ; c < n - 1 ; c++ )
array[c] = array[c+1];
printf("Resultant array is ");
for( c = 0 ; c < n - 1 ; c++ )
printf("%d ", array[c]);
}
}
int main()
{
int array[100], index, c, n;
printf("Enter number of elements in array ");
scanf("%d", &n);
printf("Enter %d elements ", n);
for ( c = 0 ; c < n ; c++ )
scanf("%d", &array[c]);
printf("Enter the location where you wish to delete element ");
scanf("%d", &index);
deleteNumFromArray(n, array, index);
return 0;
}
Output:
Enter number of elements in array
6
Enter 6 elements
50
70
10
90
60
20
Enter the location where you wish to delete element
3
Resultant array is
50
70
10
60
20
11. Repeat #2 by for an insert operation where we are inserting several values into the array. The
function should be of the form:
int insertArrayIntoArray(int n, int inArray[],
int nInsert, int insertArray[], int outArray[], int index)
The dimension of outArray is returned (explicitly). For example:
inArrayarray: [7 2 8 6 3 9]
insertArray: [50 60 70]
index: 2
outArray: [7 2 50 60 70 8 6 3 9]
Assume that outArray is large enough to hold all n + nInsert values.
Answer:
#include
//Insert an array within another array at a specified index
int insertArrayIntoArray(int n, int inArray[], int nInsert, int insertArray[], int outArray[], int
index)
{
int c, d = 0;
for(d = 0; d < n; d++)
outArray[d] = inArray[d];
//Loops till end of the second array
for(d = 0; d < nInsert; d++)
{
//Searche for the index position and swaps the data to next position
for (c = n - 1; c >= index; c--)
{
outArray[c + 1] = outArray[c];
}
//Inserts the second array data to the output array at specified position
outArray[index] = insertArray[d];
index++; //Increase the index
n++; //Increse the length
}
n = n + nInsert;
}
//Accept array data
void acc(int arr[], int n)
{
for(int c = 0; c < n; c++)
{
printf(" Enter element %d ", c+1);
fflush(stdin);
scanf("%d",&arr[c]);
}
}
//Display array data
void disp(int arr[], int n)
{
for(int c = 0; c < n; c++)
{
printf("%4d", arr[c]);
}
}
int main()
{
int fsize, ssize, pos;
int first[50], second[50], third[100];
printf(" Enter first Array Size: ");
scanf("%d", &fsize);
printf(" Enter second Array Size: ");
scanf("%d", &ssize);
printf(" Enter data for First Array: ");
acc(first, fsize);
printf(" Enter data for Second Array: ");
acc(second, ssize);
printf(" Enter the Index position: ");
fflush(stdin);
scanf("%d", &pos);
printf(" Frist Array:  ");
disp(first, fsize);
printf(" Second Array:  ");
disp(second, ssize);
insertArrayIntoArray(fsize, first, ssize, second, third, pos);
printf(" Merged Array:  ");
disp(third, (fsize+ssize));
}
Output:
Enter first Array Size: 6
Enter second Array Size: 3
Enter data for First Array:
Enter element 1 7
Enter element 2 2
Enter element 3 8
Enter element 4 6
Enter element 5 3
Enter element 6 9
Enter data for Second Array:
Enter element 1 50
Enter element 2 60
Enter element 3 70
Enter the Index position: 2
Frist Array:
7 2 8 6 3 9
Second Array:
50 60 70
Merged Array:
7 2 50 60 70 8 6 3 9

More Related Content

Similar to 1sequences and sampling. Suppose we went to sample the x-axis from X.pdf

design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab filesNitesh Dubey
Β 
Arrays
ArraysArrays
ArraysAnaraAlam
Β 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notesGOKULKANNANMMECLECTC
Β 
programs on arrays.pdf
programs on arrays.pdfprograms on arrays.pdf
programs on arrays.pdfsowmya koneru
Β 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxhappycocoman
Β 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8Rumman Ansari
Β 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updatedvrgokila
Β 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
Β 
C lab manaual
C lab manaualC lab manaual
C lab manaualmanoj11manu
Β 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkarsandeep kumbhkar
Β 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to ArraysTareq Hasan
Β 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...AntareepMajumder
Β 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptxJawadTanvir
Β 

Similar to 1sequences and sampling. Suppose we went to sample the x-axis from X.pdf (20)

Array
ArrayArray
Array
Β 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
Β 
1D Array
1D Array1D Array
1D Array
Β 
array2d.ppt
array2d.pptarray2d.ppt
array2d.ppt
Β 
Arrays
ArraysArrays
Arrays
Β 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
Β 
programs on arrays.pdf
programs on arrays.pdfprograms on arrays.pdf
programs on arrays.pdf
Β 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
Β 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
Β 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Β 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
Β 
Arrays
ArraysArrays
Arrays
Β 
Unit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTUREUnit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTURE
Β 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Β 
C lab manaual
C lab manaualC lab manaual
C lab manaual
Β 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
Β 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
Β 
array
arrayarray
array
Β 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
Β 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Β 

More from rushabhshah600

Give an expression for the pattern inventory of 2-colorings of the ed.pdf
Give an expression for the pattern inventory of 2-colorings of the ed.pdfGive an expression for the pattern inventory of 2-colorings of the ed.pdf
Give an expression for the pattern inventory of 2-colorings of the ed.pdfrushabhshah600
Β 
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdf
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdfFor the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdf
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdfrushabhshah600
Β 
External respiration includes all of these processes EXCEPT _____. r.pdf
External respiration includes all of these processes EXCEPT _____.  r.pdfExternal respiration includes all of these processes EXCEPT _____.  r.pdf
External respiration includes all of these processes EXCEPT _____. r.pdfrushabhshah600
Β 
art F You decide to cross the reciprocal translocation strain to a pu.pdf
art F You decide to cross the reciprocal translocation strain to a pu.pdfart F You decide to cross the reciprocal translocation strain to a pu.pdf
art F You decide to cross the reciprocal translocation strain to a pu.pdfrushabhshah600
Β 
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdfEcosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdfrushabhshah600
Β 
b) Analyze your network IP packets headers and contents.Solu.pdf
b) Analyze your network IP packets headers and contents.Solu.pdfb) Analyze your network IP packets headers and contents.Solu.pdf
b) Analyze your network IP packets headers and contents.Solu.pdfrushabhshah600
Β 
A type A man is the son of a type O father and type A mother. If he .pdf
A type A man is the son of a type O father and type A mother. If he .pdfA type A man is the son of a type O father and type A mother. If he .pdf
A type A man is the son of a type O father and type A mother. If he .pdfrushabhshah600
Β 
A One-Way Analysis of Variance is a way to test the equality of thre.pdf
A One-Way Analysis of Variance is a way to test the equality of thre.pdfA One-Way Analysis of Variance is a way to test the equality of thre.pdf
A One-Way Analysis of Variance is a way to test the equality of thre.pdfrushabhshah600
Β 
5 000-0 SolutionEquity multiplier = Total Assets Equityor, .pdf
5 000-0 SolutionEquity multiplier = Total Assets  Equityor, .pdf5 000-0 SolutionEquity multiplier = Total Assets  Equityor, .pdf
5 000-0 SolutionEquity multiplier = Total Assets Equityor, .pdfrushabhshah600
Β 
4 (4 points). How would you describe the difference in cell structur.pdf
4 (4 points). How would you describe the difference in cell structur.pdf4 (4 points). How would you describe the difference in cell structur.pdf
4 (4 points). How would you describe the difference in cell structur.pdfrushabhshah600
Β 
Distinguish between cell fate and cell commitment. How can one assay.pdf
Distinguish between cell fate and cell commitment. How can one assay.pdfDistinguish between cell fate and cell commitment. How can one assay.pdf
Distinguish between cell fate and cell commitment. How can one assay.pdfrushabhshah600
Β 
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdfDifferentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdfrushabhshah600
Β 
Define induction and give an example of deductive reasoningSolu.pdf
Define induction and give an example of deductive reasoningSolu.pdfDefine induction and give an example of deductive reasoningSolu.pdf
Define induction and give an example of deductive reasoningSolu.pdfrushabhshah600
Β 
A report says that the between-subjects factor of participants sal.pdf
A report says that the between-subjects factor of participants sal.pdfA report says that the between-subjects factor of participants sal.pdf
A report says that the between-subjects factor of participants sal.pdfrushabhshah600
Β 
City GUIWrite a Java GUI program which reads data about US cities..pdf
City GUIWrite a Java GUI program which reads data about US cities..pdfCity GUIWrite a Java GUI program which reads data about US cities..pdf
City GUIWrite a Java GUI program which reads data about US cities..pdfrushabhshah600
Β 
What is the role of sulfur chemoautotrophs in the sulfur cycle Deco.pdf
What is the role of sulfur chemoautotrophs in the sulfur cycle  Deco.pdfWhat is the role of sulfur chemoautotrophs in the sulfur cycle  Deco.pdf
What is the role of sulfur chemoautotrophs in the sulfur cycle Deco.pdfrushabhshah600
Β 
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdf
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdfWhat is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdf
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdfrushabhshah600
Β 
Briefly describe the contributions to the quality movement made by e.pdf
Briefly describe the contributions to the quality movement made by e.pdfBriefly describe the contributions to the quality movement made by e.pdf
Briefly describe the contributions to the quality movement made by e.pdfrushabhshah600
Β 
Background Angiosperms (flowering plants) are the largest Phylum in .pdf
Background  Angiosperms (flowering plants) are the largest Phylum in .pdfBackground  Angiosperms (flowering plants) are the largest Phylum in .pdf
Background Angiosperms (flowering plants) are the largest Phylum in .pdfrushabhshah600
Β 
Write a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdfWrite a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdfrushabhshah600
Β 

More from rushabhshah600 (20)

Give an expression for the pattern inventory of 2-colorings of the ed.pdf
Give an expression for the pattern inventory of 2-colorings of the ed.pdfGive an expression for the pattern inventory of 2-colorings of the ed.pdf
Give an expression for the pattern inventory of 2-colorings of the ed.pdf
Β 
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdf
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdfFor the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdf
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdf
Β 
External respiration includes all of these processes EXCEPT _____. r.pdf
External respiration includes all of these processes EXCEPT _____.  r.pdfExternal respiration includes all of these processes EXCEPT _____.  r.pdf
External respiration includes all of these processes EXCEPT _____. r.pdf
Β 
art F You decide to cross the reciprocal translocation strain to a pu.pdf
art F You decide to cross the reciprocal translocation strain to a pu.pdfart F You decide to cross the reciprocal translocation strain to a pu.pdf
art F You decide to cross the reciprocal translocation strain to a pu.pdf
Β 
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdfEcosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Β 
b) Analyze your network IP packets headers and contents.Solu.pdf
b) Analyze your network IP packets headers and contents.Solu.pdfb) Analyze your network IP packets headers and contents.Solu.pdf
b) Analyze your network IP packets headers and contents.Solu.pdf
Β 
A type A man is the son of a type O father and type A mother. If he .pdf
A type A man is the son of a type O father and type A mother. If he .pdfA type A man is the son of a type O father and type A mother. If he .pdf
A type A man is the son of a type O father and type A mother. If he .pdf
Β 
A One-Way Analysis of Variance is a way to test the equality of thre.pdf
A One-Way Analysis of Variance is a way to test the equality of thre.pdfA One-Way Analysis of Variance is a way to test the equality of thre.pdf
A One-Way Analysis of Variance is a way to test the equality of thre.pdf
Β 
5 000-0 SolutionEquity multiplier = Total Assets Equityor, .pdf
5 000-0 SolutionEquity multiplier = Total Assets  Equityor, .pdf5 000-0 SolutionEquity multiplier = Total Assets  Equityor, .pdf
5 000-0 SolutionEquity multiplier = Total Assets Equityor, .pdf
Β 
4 (4 points). How would you describe the difference in cell structur.pdf
4 (4 points). How would you describe the difference in cell structur.pdf4 (4 points). How would you describe the difference in cell structur.pdf
4 (4 points). How would you describe the difference in cell structur.pdf
Β 
Distinguish between cell fate and cell commitment. How can one assay.pdf
Distinguish between cell fate and cell commitment. How can one assay.pdfDistinguish between cell fate and cell commitment. How can one assay.pdf
Distinguish between cell fate and cell commitment. How can one assay.pdf
Β 
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdfDifferentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Β 
Define induction and give an example of deductive reasoningSolu.pdf
Define induction and give an example of deductive reasoningSolu.pdfDefine induction and give an example of deductive reasoningSolu.pdf
Define induction and give an example of deductive reasoningSolu.pdf
Β 
A report says that the between-subjects factor of participants sal.pdf
A report says that the between-subjects factor of participants sal.pdfA report says that the between-subjects factor of participants sal.pdf
A report says that the between-subjects factor of participants sal.pdf
Β 
City GUIWrite a Java GUI program which reads data about US cities..pdf
City GUIWrite a Java GUI program which reads data about US cities..pdfCity GUIWrite a Java GUI program which reads data about US cities..pdf
City GUIWrite a Java GUI program which reads data about US cities..pdf
Β 
What is the role of sulfur chemoautotrophs in the sulfur cycle Deco.pdf
What is the role of sulfur chemoautotrophs in the sulfur cycle  Deco.pdfWhat is the role of sulfur chemoautotrophs in the sulfur cycle  Deco.pdf
What is the role of sulfur chemoautotrophs in the sulfur cycle Deco.pdf
Β 
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdf
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdfWhat is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdf
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdf
Β 
Briefly describe the contributions to the quality movement made by e.pdf
Briefly describe the contributions to the quality movement made by e.pdfBriefly describe the contributions to the quality movement made by e.pdf
Briefly describe the contributions to the quality movement made by e.pdf
Β 
Background Angiosperms (flowering plants) are the largest Phylum in .pdf
Background  Angiosperms (flowering plants) are the largest Phylum in .pdfBackground  Angiosperms (flowering plants) are the largest Phylum in .pdf
Background Angiosperms (flowering plants) are the largest Phylum in .pdf
Β 
Write a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdfWrite a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdf
Β 

Recently uploaded

Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
Β 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
Β 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
Β 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
Β 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
Β 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
Β 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
Β 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
Β 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
Β 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
Β 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
Β 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
Β 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
Β 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
Β 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
Β 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
Β 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
Β 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
Β 

Recently uploaded (20)

Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
Β 
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Model Call Girl in Tilak Nagar Delhi reach out to us at πŸ”9953056974πŸ”
Β 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
Β 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
Β 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
Β 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
Β 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Β 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
Β 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
Β 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
Β 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
Β 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Β 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
Β 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
Β 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
Β 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
Β 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
Β 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
Β 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
Β 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
Β 

1sequences and sampling. Suppose we went to sample the x-axis from X.pdf

  • 1. 1sequences and sampling. Suppose we went to sample the x-axis from Xmin to Xmax using a step size of step A)Draw a picture of what is going on. B) Write a expression for n the total number of samples involved (in terms of Xmin, Xmax and step) C) Write out the sequence of x-samples D) Write a direct and general expression for xi that captures the sequence E) Write a recursive expression for the sequence F) Write a program to compute and store the x-samples over the range -5x5 using a step size of 0.1 do everything in main () 2 . We talked about the following string functions that are available in C (as long as you include string.h): int strlen(char str[]) void strcpy(char str1[], char str2[]) void strcat(char str1[], str2[]) Write your own versions of these functions; for example: int paul_strlen(int char str[]). Hint: for your version of the strlen function, start at the first character in the array and keep counting until you find the β€˜0’ character (use a while loop for this). Note: Use your version of the strlen function in the strcpy and strcat functions. 9. We want to insert a number into an array. (a) Formulate the problem mathematically with two sequences: x and y. (b) Write a function of the form: insertNumIntoArray(int n, int array[], int num, int index) The function inserts num into the array at the specified index. The rest of the array then follows. For example, if num = 9 and index = 3 and array = [7 2 8 8 3 1 2] then the function will produce: array = [7 2 8 9 8 3 1 2] Note: assume that array is properly dimensioned to have at least 1 extra space for storage.
  • 2. 10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20], then the result will be array: [50 70 10 60 20] 11. Repeat #2 by for an insert operation where we are inserting several values into the array. The function should be of the form: int insertArrayIntoArray(int n, int inArray[], int nInsert, int insertArray[], int outArray[], int index) The dimension of outArray is returned (explicitly). For example: inArrayarray: [7 2 8 6 3 9] insertArray: [50 60 70] index: 2 outArray: [7 2 50 60 70 8 6 3 9] Assume that outArray is large enough to hold all n + nInsert values. Solution #include //Simulates strlen() library function int paul_strlen(char str[]) { int l; for(l = 0; str[l] != '0'; l++) ; return l; } //Simulates strcpy() library function void paul_strcpy(char str1[], char str2[])
  • 3. { int c; for(c = 0; str1[c] != '0'; c++) str2[c] = str1[c]; str2[c] = '0'; printf(" Original String: %s", str1); printf(" Copied String: %s", str2); } //Simulates strcat() library function void paul_strcat(char str1[], char str2[]) { int i, j; for(i = 0; str1[i] != '0'; i++) ; for (j = 0; str2[j] != '0'; i++, j++) { str1[i] = str2[j]; } str1[i] = '0'; printf(" Concatenated String: %s", str1); } int main() { char data1[20], data2[20]; printf(" Enter a string: "); gets(data1); printf(" Length of the String: %d", paul_strlen(data1)); printf(" Enter a string: "); gets(data1); paul_strcpy(data1, data2); printf(" Enter a string1: "); gets(data1); printf(" Enter a string2: "); gets(data2); paul_strcat(data1, data2); } Output:
  • 4. Enter a string: pyari Length of the String: 5 Enter a string: Pyari sahu Original String: Pyari sahu Copied String: Pyari sahu Enter a string1: pyari Enter a string2: mohan Concatenated String: pyarimohan 9. We want to insert a number into an array. Answer: #include //Insert a number at specified location void insertNumIntoArray(int n, int array[], int num, int index) { int c; //Creates a place for insert for (c = n - 1; c >= index; c--) array[c + 1] = array[c]; //Stores the number at specified location array[index] = num; printf("Resultant array is "); for (c = 0; c <= n; c++) printf("%d ", array[c]); } int main() { int array[20]; int n, c, num, index; printf("Enter number of elements in array "); scanf("%d", &n); printf("Enter %d elements ", n); for (c = 0; c < n; c++) scanf("%d", &array[c]); printf("Enter the location where you wish to insert an element "); scanf("%d", &index);
  • 5. printf("Enter the value to insert "); scanf("%d", &num); insertNumIntoArray(n, array, num, index); } Output: Enter number of elements in array 7 Enter 7 elements 7 2 8 8 3 1 2 Enter the location where you wish to insert an element 3 Enter the value to insert 9 Resultant array is 7 2 8 9 8 3 1 2 10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20], then the result will be Answer: #include //Delete an item from a specified position void deleteNumFromArray(int n, int array[], int index) {
  • 6. int c; //Validates for deletion if ( index >= n+1 ) printf("Deletion not possible. "); else { //Moves the elements for ( c = index ; c < n - 1 ; c++ ) array[c] = array[c+1]; printf("Resultant array is "); for( c = 0 ; c < n - 1 ; c++ ) printf("%d ", array[c]); } } int main() { int array[100], index, c, n; printf("Enter number of elements in array "); scanf("%d", &n); printf("Enter %d elements ", n); for ( c = 0 ; c < n ; c++ ) scanf("%d", &array[c]); printf("Enter the location where you wish to delete element "); scanf("%d", &index); deleteNumFromArray(n, array, index); return 0; } Output: Enter number of elements in array 6 Enter 6 elements 50 70 10 90 60
  • 7. 20 Enter the location where you wish to delete element 3 Resultant array is 50 70 10 60 20 11. Repeat #2 by for an insert operation where we are inserting several values into the array. The function should be of the form: int insertArrayIntoArray(int n, int inArray[], int nInsert, int insertArray[], int outArray[], int index) The dimension of outArray is returned (explicitly). For example: inArrayarray: [7 2 8 6 3 9] insertArray: [50 60 70] index: 2 outArray: [7 2 50 60 70 8 6 3 9] Assume that outArray is large enough to hold all n + nInsert values. Answer: #include //Insert an array within another array at a specified index int insertArrayIntoArray(int n, int inArray[], int nInsert, int insertArray[], int outArray[], int index) { int c, d = 0; for(d = 0; d < n; d++) outArray[d] = inArray[d]; //Loops till end of the second array for(d = 0; d < nInsert; d++) { //Searche for the index position and swaps the data to next position for (c = n - 1; c >= index; c--) { outArray[c + 1] = outArray[c]; }
  • 8. //Inserts the second array data to the output array at specified position outArray[index] = insertArray[d]; index++; //Increase the index n++; //Increse the length } n = n + nInsert; } //Accept array data void acc(int arr[], int n) { for(int c = 0; c < n; c++) { printf(" Enter element %d ", c+1); fflush(stdin); scanf("%d",&arr[c]); } } //Display array data void disp(int arr[], int n) { for(int c = 0; c < n; c++) { printf("%4d", arr[c]); } } int main() { int fsize, ssize, pos; int first[50], second[50], third[100]; printf(" Enter first Array Size: "); scanf("%d", &fsize); printf(" Enter second Array Size: "); scanf("%d", &ssize); printf(" Enter data for First Array: "); acc(first, fsize); printf(" Enter data for Second Array: ");
  • 9. acc(second, ssize); printf(" Enter the Index position: "); fflush(stdin); scanf("%d", &pos); printf(" Frist Array: "); disp(first, fsize); printf(" Second Array: "); disp(second, ssize); insertArrayIntoArray(fsize, first, ssize, second, third, pos); printf(" Merged Array: "); disp(third, (fsize+ssize)); } Output: Enter first Array Size: 6 Enter second Array Size: 3 Enter data for First Array: Enter element 1 7 Enter element 2 2 Enter element 3 8 Enter element 4 6 Enter element 5 3 Enter element 6 9 Enter data for Second Array: Enter element 1 50 Enter element 2 60 Enter element 3 70 Enter the Index position: 2 Frist Array: 7 2 8 6 3 9 Second Array: 50 60 70 Merged Array: 7 2 50 60 70 8 6 3 9