0% found this document useful (0 votes)
48 views6 pages

FOP Assignment U 4 To U 6

The document discusses multi-dimensional arrays and provides examples of programs involving arrays. It also discusses functions and classes in C++ and Java, providing examples of how to define and use functions and classes to solve problems.

Uploaded by

shwerghu2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views6 pages

FOP Assignment U 4 To U 6

The document discusses multi-dimensional arrays and provides examples of programs involving arrays. It also discusses functions and classes in C++ and Java, providing examples of how to define and use functions and classes to solve problems.

Uploaded by

shwerghu2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Unit 4

1. What is a multi-dimensional array? How declaration and initialization of multi-


dimensional arrays is done? Differentiate one-dimensional array and two dimensional
array with example.
2. Explain compile time and run time initialization of 2-D array with an
example.
3. Write a C++ or JAVA program to merge two integer arrays of the same size into a third
array sorted in descending order.
4. Write a C++ or JAVA program to arrange arrays of N elements into ascending order.
5. Write a C++ or JAVA program to copy the reverse of a user entered string in another
array. [Do not use inbuilt function]
6. Write a C++ or JAVA program to print all the repeated numbers with frequency
from 1-D array.
7. Sachin Tendulkar played lots of cricket for India. User wants to know the lowest scores,
highest scores, number of centuries and number of fifties he made in all played innings.
Allow users to input the number of innings runs in an array and display above
mentioned information in appropriate format in C++ or JAVA.
8. Write a program to print the last character of each word of a sentence assuming that
words are separated by a single blank space.
9. Write a C++ or JAVA program to accept N float numbers from the keyboard and
display the maximum number with all positions in the array.
10. Write a C++ or JAVA program to input two 3X3 matrices such as A and B. Perform
multiplication of A and B matrices and display the result of it.
11. Define a two dimensional array. Describe memory allocation of a two dimensional
array in detail with the help of appropriate examples.
12. Explain all the string handling functions with an example.
13. Explain parallel arrays with an example.
14. Write a C++ or JAVA program to calculate the number of vowels in a string.
15. Write a C++ or JAVA program to concatenate two strings without using an in-built
function.
16. How is a two-dimensional array declared?
17. Explain strcat() function with its syntax.
18. State whether the following statement is true or false. Justify your answer.
The array int num[26] has twenty-six elements.
19. Consider the following array:
int a[ ] ={1,2,3,4,5,4,3,2,1,0}, i;
What is the content of the array after the following loop completes?
for ( i = 0; i < 9; i++)
{ a[i] = a[i + 1]; }
20. What is the output of the following program?
int main()
{
char str[ ]="This is Test";
int m;
for(m=0;str[m]!='\0';m++)
if(m%2 ==0)
cout<<str[m];
return 0;
}
21. Define an array arr1 with an 4-element array of float and initialized with values 2.1,
21.2, 3.1, 4.5 .
22. Enlist string handling functions.
23. Write the output of following ’C’ code:
int main()
{
int m[]={1,2,3,4,5};
int x, y=0;
for(x=0;x<5;x++)
{
y=y+m[x];
}
cout<<y;
}

24. State whether the following initialization of an array is valid or invalid with proper
reason.
A)float item[3][2]={0,1,2,3,4,5};
B)int m[3,5]={1,2,3,4,5};

25. What is the output of the following program?


int main()
{
char str[ ]="Hello World";
int m;
for(m=0;str[m]!='\0';m+=2)
cout<<str[m];
return 0;
}

26. Consider the following array:


int a[ ] ={1,1,1,1,1,1,1,1,1}, i;
What is the content of the array after the following loop completes?
for ( i = 0; i < 9; i++)
{ a[i] = a[i + 1]+a[i - 1]; }
Unit 5

1. Write a C++ or Java program to find the maximum and minimum number among three
numbers using a function.
2. Write a C++ or Java program to check whether a number is prime or not using a
function.
3. Write a C++ or Java program to calculate the factorial of a number using a function.
4. Enlist the elements of the user defined function. Explain each element of the function
in detail.
5. List out the categories of function. Explain each of them with examples.
6. Explain a function category with argument and without return type with an example.
7. Explain a function category with no argument and without return type with an example.
8. Explain a function category with argument and with return type with an example.
9. Explain a function category with no argument and with return type with an example.
10. What is recursion? Explain with an appropriate example.
11. What do you understand by method? Explain method creation with multiple parameters
by giving a proper example.
12. Write a C++ or JAVA function namely InArray() that takes in an integer array, No of
elements in array and search value and it returns the number of times search value is
stored in the array.
13. What do you understand by method? Write any two advantages to use methods. Explain
method creation with a single parameter by giving a proper example.
14. Write a C++ or JAVA function namely MaxValIndex() that takes in an integer array,
No of elements in an array and it returns the index number that has maximum value in
the array.
15. Write a C++ or JAVA program that uses the user defined function Swap() to
interchange the value of two variables.
16. Explain the three elements of the function.
17. Write a program using a function that computes X^Y for integer x and y and returns
double type value.
18. How many maximum and minimum values can function return?
19. Write any two rules for defining function name.
20. Write a prototype of function "Display" that accepting an integer array as argument and
returns float value.
21. Find out error in following function given below.
void total(int value1, value2, value3)
{
return value1 + value2 + value3;
}

22. What will be the output of the following program?


int check ( int ch );
int main( )
{
int i = 45, c ;
c = check ( i ) ;
cout<<c;
return 0;
}
int check ( int ch )
{
if ( ch >= 45 )
{
return ( 10 * 10 ) ;
}
else
{
return ( 100 ) ;
}

}
23. What will be the output of the following code?
#include<iostream>
using namespace std;
void addprint()
{
int s = 1;
s++;
cout << s;
}
int main()
{
addprint();
addprint();
addprint();
return 0;
}
Unit 6
1. Write a C++ or JAVA program create a PlayerScore calss which having two properties
namely runs and no of balls and following methods:
void setscore(int r, int b) - it sets the values of object properties.
int isfifty() - it return true if score is between 50 to 99 otherwise false.
int iscentury() - it return true if score is more than equal to 100 otherwise false.
float strickrate() - it returns the strick rates (run * 100 / noofballs).
void display()-it display player details with status of fifties, century and strickrate.
Write a main() to demonstrate the class methods functionality.
2. What do you mean by class and object? How to create an object?
3. Explain different types of access specifiers.
4. Create a C++ or JAVA class namely employee which contains three members like
emp_id, emp_name, and total yearly income and following methods.
void input() - it accepts employee details from user.
float totaltax() - it calculate the tax and return it based on the following criteria.
Amount Tax Percentage on total Yearly income
Less than 500000 10 %
>=500000 20 %
void display() - it display employee details with tax.
Write a main() to demonstrate the class methods functionality.
5. How to call class instance methods through object? Give an appropriate example.
6. Define a class Banksystem which contains following:
7. Data Members:
− Name of account holder
− Account Number
− Balance
Member Functions:
- To get details of the account
− To display the balance
− To search account by account number
Write C++ program for aboveBanksystem that handles five customers.
8. Define a class Student which contains following:
Data Members:
− Name of student
− Enrollment number of student
− Contact number of student

Member Functions:
− To get details of the student
− To display details of the student

Write a C++ program to get and print records of a single student.

9. Explain Enum with an example.

You might also like