SlideShare a Scribd company logo
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 files
Nitesh Dubey
 
1D Array
1D Array1D Array
1D Array
A. S. M. Shafi
 
Arrays
ArraysArrays
Arrays
AnaraAlam
 
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
GOKULKANNANMMECLECTC
 
programs on arrays.pdf
programs on arrays.pdfprograms on arrays.pdf
programs on arrays.pdf
sowmya koneru
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
happycocoman
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
Nithin Kumar,VVCE, Mysuru
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
vrgokila
 
Unit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTUREUnit 2 dsa LINEAR DATA STRUCTURE
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
sandeep kumbhkar
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
Tareq Hasan
 
array
arrayarray
array
teach4uin
 
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.pptx
JawadTanvir
 

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.pdf
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 
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
rushabhshah600
 

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

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 

Recently uploaded (20)

The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 

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