You are on page 1of 3

# Assignment-1

Topic – Single Dimensional Array
Q1. Q2. What do you mean by array ? Explain with some suitable Example? Name the valid and invalid declaration of array i) v) ix) Q3. int a[+10] int a[-10] int x[n]; ii) int a[1..10] vi) int a[ ] x) int x[i] iii) int x[1-10] vii) int[10] x iv) int [10] a viii) int x[10] ; float x[10]

Find out the output of the following program segment #include<iostream.h> int main( ) { int x[10],i,sum =0; for(i=0;i<10;i++) if(i%2= =0 ) sum = sum+x[i]; else sum = sum – x[i]; cout<<”\n Sum of element :”<< sum return 0; }

Q4.

Find out the error(s) in the following program listing (assuming all the necessary files are included) #include<iostream.h> int main( ) { int x[10],i,sum =0; for(i=0;i<=10;i++) if(i%2= =0 ) sum = = sum+x[i]; else sum = sum – x[i]; cout<<”\n Sum of element :”<< sum return 0; } Find out the output of the following program #include<iostream.h> int main( ) { int x[5] ={ 1,5,3}; for(i=0;i<5;i++) cout<<setw(6)<<x[i]; return 0; } Write a program in C++ to read a list of 10 integer numbers from the keyboard and find out the sum and Page 1 of 3

Q5.

Q2.

Last updated on: 23/01/2006 22:45 a1/p1

Q6.6.10) resultant array =(2.7.4.8. Q16. Write a program in C++ to read a list of 10 floating point numbers from the keyboard and arrange them in ascending order (use Bubble sort algorithm) Write a program in C++ to read a list of 10 floating point numbers from the keyboard and arrange them in descending order (use Bubble sort algorithm) Write a program in C++ to read a list of 10 floating point numbers from the keyboard and arrange them in ascending order (use selection sort algorithm) Write a program in C++ to read a list of 10 floating point numbers from the keyboard and arrange them in descending order (use selection sort algorithm) Write a program in C++ to read a list of 10 floating point numbers from the keyboard and arrange them in ascending order (use insertion sort algorithm) Write a program in C++ to read a list of 10 floating point numbers from the keyboard and arrange them in ascending order (use insertion sort algorithm) Last updated on: 23/01/2006 22:45 a1/p1 Page 2 of 3 . Q9. Q8.9. Q17.8.5.3.4. Write a program in C++ to read a list of 10 sorted integer numbers and one more integer number from the keyboard and find out whether the given number is available in the list or not (Use Binary search algorithm) Q14. Write a program in C++ to red a list of 10 integer numbers from the keyboard and find out the largest number among them.5. Write a program in C++ to read a decimal integer number and find out it’s binary equivalent ? Write a program in C++ to read a decimal integer number and find out it’s octal number? Write a program in C++ to read a list of 10 integer numbers and one more integer number from the keyboard and find out whether the given number is available in the list or not (Use Linear search algorithm) Q13. Q5. Also display the original numbers and the swap numbers.7. Q19.average of these numbers? Also Display the entered numbers? Q3. Also display the original list and modified list ? Write a program in C++ to read a list of 10 integer numbers and find out the sum of those elements which is either divisible by 2 or 3.2. Also display the entered list and the sum ? Write a program in C++ to read a list of 10 integer numbers and arrange them in such a manner that all the even numbers start from the left and all the odd numbers start from the right. Write a program in C++ to read a list of 1o integer numbers and give the increment of 20 to each element .6. Example x ={1. Q15. Display the largest number and the number entered Write a program in C++ to read a list of 10 integer number from the keyboard and find out the sum of all the even numbers and the sum of all the odd numbers? Also display the entered numbers Write a program in C++ to read a list of 10 integer numbers from the keyboard and find out the sum of all the positive numbers and the sum of all the negative numbers? Write a program in C++ to read a list of 10 integer numbers from the keyboard and swap the position of first half numbers with the second half numbers. Q12. Q18. Q7.3. Q4. Q11.1 } Q10.10 .8.

Q20. Write a program in C++ to read two sorted array A and B of order M and N respectively. Display the original array and the array after deletion of the element. Q23. Also display the original arrays and the merge array. Write a program in C++ to read two arrays A and B of order M and N respectively. Q22. You are required to merge these two arrays to form the third array C in ascending order only visiting the array A and B only once. Last updated on: 23/01/2006 22:45 a1/p1 Page 3 of 3 . both the arrays A and B are arranged in ascending order. Q21. Write a program in C++ to read an array of order N and delete an element from this list of element . Write a program in C++ to read one array of order N and insert a new element in this array . Display the array after insertion of the element. Concatenate them to form a new array C of order M+N.