| Other C++ Code Interview Questions |
| |
| Question |
Asked @ |
Answers |
| |
| #include<iostream.h>
//main()
//{
class A
{
friend class B;
public:
void read();
};
class B
{
public :
int a,b;
};
void A::read()
{
cout<<"welcome";
}
main()
{
A x;
B y;
y.read();
}
In the above program......,
as B is a friend of A B can have access to all members,i
cant access y.read .
could you please tell me the reason and what would i code
to execute this program? |
| 2 |
| Wrie a function which returns the most frequent number in a
list of integers. Handle the case of more than one number
which meets this criterion.
public static int[] GetFrequency(int[] list)
|
Nagarro | 3 |
| write a function -oriented program that generates the
Fibonacci, the current numbers of n(as input) and display
them (series). In Fibonacci, the current third number is the
sum of the previous number. |
| 2 |
| #include<stdio.h>
#include<conio.h>
void main()
{
char str[10];
int,a,x,sw=0;
clrscr();
printf("Enter a string:");
gets(str);
for(x=0;x<=a;a++);
for(x=0;x<=a;x++)
{
if(str[x]==str[a-1-x])
{
sw=1;
}
else
sw=0;
}
if(sw==10
printf("The entered string is palindrome:");
else
printf("The entered string is not a palindrome:);
}
getch();
}
wht would be the explanation with this written code??? |
| 2 |
| Display Pattern:
1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
…
|
| 2 |
| write a c program, using for loop, that accepts and odds two
numbers. The output must be the sum and the addens. This
should be repeated 5 times while the first number is
decremented by one and the second number is incremented by 1.
|
IBM | 2 |
| Write a program using one dimensional array that accept five
values from the keyboard. Then it should also accept a
number to search. This number is to be searched if it among
the five input values. If it is found, display the message
“Search number is found!” otherwise, display “Search is lost”.
Example:
Enter 5 numbers: 10 15 20 7 8
Enter number to search: 7
Search number is found!
|
| 2 |
| Algorithm in O(2n)
Presently we can solve in our hypothetical machine problem
instances of size 100 in 1 minute using algorithm A, which
is a O(2n). We would like to solve instances of size 200 in
1 minute using algorithm A on a new machine.
What is the speed of the new machine should be? |
Qatar-University | 2 |
| Min-Max
Write an algorithm that finds both the smallest and
largest numbers in a list of n numbers and with complexity
T(n) is at most about (1.5)n comparisons. |
Qatar-University | 9 |
| Given 1 to n random number, find top 10 maximum numbers and
explain the time complexity of the algorithm. |
NetApp | 1 |
| . Write a program using two-dimensional arrays that computes
the sum of data in tows and the sum of data in columns of
the 3x3 (three by three) array variable n[3][3].
|
IBM | 2 |
| Here's the programm code:
int magic(int a, int b) {
return b == 0 ? a : magic(b, a % b);
}
int main() {
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", magic(a, b));
return 0;
}
on input stream we have integers 4, 45
What's the output integer?
How many times will be initiated "magic" function? |
| 1 |
| |
| For more C++ Code Interview Questions Click Here |