BEL computer science engg Interview questions and answers,BEL previous years candidates experinces,BEL free solved sample placement papers
Which is the parameter that is added to every non-static member function when it is called?
Answer: ‘this’ pointer
What is a binary semaphore? What is its use?
Answer:
A binary semaphore is one, which takes only 0 and 1 as values. They are used to implement mutual exclusion and synchronize concurrent processes.
What is thrashing?
Answer:
It is a phenomenon in virtual memory schemes when the processor spends most of its time swapping pages, rather than executing instructions. This is due to an inordinate number of page faults.
What are turnaround time and response time?
Answer:
Turnaround time is the interval between the submission of a job and its completion. Response time is the interval between submission of a request, and the first response to that request.
What is data structure?
Answer: A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.
List out the areas in which data structures are applied extensively?
Answer: The name of areas are:
Compiler Design,
Operating System,
Database Management System,
Statistical analysis package,
Numerical Analysis,
Graphics,
Artificial Intelligence,
Simulation
What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.
Answer: The major data structures used are as follows:
RDBMS – Array (i.e. Array of structures)
Network data model – Graph
Hierarchical data model – Trees
What is the data structures used to perform recursion?
Answer: Stack. Because of its LIFO (Last In First Out) property it remembers its ‘caller’ so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.
Predict the output or error(s) for the following:
void main()
{
int const * p=5;
printf(“%d”,++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.
Explanation:p is a pointer to a “constant integer”. But we tried to change the value of the “constant integer”.
main()
{
char s[ ]=”man”;
int i;
for(i=0;s[ i ];i++)
printf(“\n%c%c%c%c”,s[ i ],*(s+i),*(i+s),i[s]);
}
Answer:
mmmm
aaaa
nnnn
Explanation:s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].
main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf(“I love U”);
else
printf(“I hate U”);
}
Answer:
I hate U
Explanation:For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb:
Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ).
List out few of the Application of tree data-structure?
Answer: The list is as follows:
The manipulation of Arithmetic expression,
Symbol Table construction,
Syntax analysis.
List out few of the applications that make use of Multi linked Structures?
Answer: The applications are listed below:
Sparse matrix,
Index generation.
In tree construction which is the suitable efficient data structure?
Answer: Linked list is the efficient data structure.
What is the type of the algorithm used in solving the 8 Queens problem?
Answer: Backtracking
In RDBMS, what is the efficient data structure used in the internal storage representation?
Answer: B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.
Whether Linked List is linear or Non-linear data structure?
Answer: According to Access strategies Linked list is a linear one.
According to Storage Linked List is a Non-linear one.
Predict the output or error(s) for the following:
main()
{
int c=- -2;
printf(“c=%d”,c);
}
Answer:
c=2;
Explanation:Here unary minus (or negation) operator is used twice. Same maths rules applies, ie. minus * minus= plus.
#define int char
main()
{
int i=65;
printf(“sizeof(i)=%d”,sizeof(i));
}
Answer:
sizeof(i)=1
Explanation: Since the #define replaces the string int by the macro char
What is dangling pointer in c?
If any pointer is pointing the memory address of any variable but after some variable has deleted from that memory location while pointer is still pointing such memory location. Such pointer is known as dangling pointer and this problem is known as dangling pointer problem.
In C++, what is the difference between method overloading and method overriding?
Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class.
What methods can be overridden in Java?
In C++ terminology, all public methods in Java are virtual. Therefore, all Java methods can be overwritten in subclasses except those that are declared final, static, and private.
What are the defining traits of an object-oriented language?
The defining traits of an object-oriented langauge are:
* encapsulation
* inheritance
* polymorphism
Write a program that ask for user input from 5 to 9 then calculate the average
int main()
{
int MAX=4;
int total =0;
int average=0;
int numb;
cout<<“Please enter your input from 5 to 9”;
cin>>numb;
if((numb <5)&&(numb>9))
cout<<“please re type your input”;
else
for(i=0;i<=MAX; i++)
{
total = total + numb;
average= total /MAX;
}
cout<<“The average number is”<<
return 0;
}
Assignment Operator – What is the diffrence between a “assignment operator” and a “copy constructor”?
In assignment operator, you are assigning a value to an existing object. But in copy constructor, you are creating a new object and then assigning a value to that object. For example:
complex c1,c2;
c1=c2; //this is assignment
complex c3=c2; //copy constructor
What will be printed as the result of the operation below:
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%dn”,x,y);}
Answer : 5794
Explain the popular multiprocessor thread-scheduling strategies.
Answer:
Load Sharing: Processes are not assigned to a particular processor. A global queue of threads is maintained. Each processor, when idle, selects a thread from this queue. Note that load balancing refers to a scheme where work is allocated to processors on a more permanent basis.
Gang Scheduling: A set of related threads is scheduled to run on a set of processors at the same time, on a 1-to-1 basis. Closely related threads / processes may be scheduled this way to reduce synchronization blocking, and minimize process switching. Group scheduling predated this strategy.
Dedicated processor assignment: Provides implicit scheduling defined by assignment of threads to processors. For the duration of program execution, each program is allocated a set of processors equal in number to the number of threads in the program. Processors are chosen from the available pool.
Dynamic scheduling: The number of thread in a program can be altered during the course of execution.
What is a trap and trapdoor?
Answer:
Trapdoor is a secret undocumented entry point into a program used to grant access without normal methods of access authentication. A trap is a software interrupt, usually the result of an error condition.
What is time-stamping?
Answer:
It is a technique proposed by Lamport, used to order events in a distributed system without the use of clocks. This scheme is intended to order events consisting of the transmission of messages. Each system ‘i’ in the network maintains a counter Ci. Every time a system transmits a message, it increments its counter by 1 and attaches the time-stamp Ti to the message. When a message is received, the receiving system ‘j’ sets its counter Cj to 1 more than the maximum of its current value and the incoming time-stamp Ti. At each site, the ordering of messages is determined by the following rules: For messages x from site i and y from site j, x precedes y if one of the following conditions holds….(a) if Ti<=”” blockquote=””>
How are the wait/signal operations for monitor different from those for semaphores?
Answer:
If a process in a monitor signal and no task is waiting on the condition variable, the signal is lost. So this allows easier program design. Whereas in semaphores, every operation affects the value of the semaphore, so the wait and signal operations should be perfectly balanced in the program.
What you know about C++?
Released in 1985, C++ is an object-oriented programming language created by Bjarne Stroustrup. C++ maintains almost all aspects of the C language, while simplifying memory management and adding several features – including a new datatype known as a class (you will learn more about these later) – to allow object-oriented programming. C++ maintains the features of C which allowed for low-level memory access but also gives the programmer new tools to simplify memory management.
C++ used for:
C++ is a powerful general-purpose programming language. It can be used to create small programs or large applications. It can be used to make CGI scripts or console-only DOS programs. C++ allows you to create programs to do almost anything you need to do. The creator of C++, Bjarne Stroustrup, has put together a partial list of applications written in C++.
What is an object?
Object is a software bundle of variables and related methods. Objects have state and behavior.
What do you mean by inheritance?
Inheritance is the process of creating new classes, called derived classes, from existing classes or base classes. The derived class inherits all the capabilities of the base class, but can add embellishments and refinements of its own.
What is polymorphism?
Polymorphism is the idea that a base class can be inherited by several classes. A base class pointer can point to its child class and a base class array can store different child class objects.
44. What is a scope resolution operator?
A scope resolution operator (::), can be used to define the member functions of a class outside the class.
Anything wrong with this code?
T *p = new T[10];
delete p;
Everything is correct, Only the first element of the array will be deleted”, The entire array will be deleted, but only the first element destructor will be called.
What is Boyce Codd Normal form?
A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional dependencies in F+ of the form a-> , where a and b is a subset of R, at least one of the following holds:
* a- > b is a trivial functional dependency (b is a subset of a)
* a is a superkey for schema R
What is virtual class and friend class?
Friend classes are used when two or more classes are designed to work together and need access to each other’s implementation in ways that the rest of the world shouldn’t be allowed to have. In other words, they help keep private things private. For instance, it may be desirable for class DatabaseCursor to have more privilege to the internals of class Database than main() has.
How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
You can find out by using 2 pointers. One of them goes 2 nodes each time. The second one goes at 1 nodes each time. If there is a cycle, the one that goes 2 nodes each time will eventually meet the one that goes slower.
If that is the case, then you will know the linked-list is a cycle.
What is the difference between realloc() and free()?
The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur. The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or realloc subroutines. Undefined results occur if the Pointer parameter is not a valid pointer.
What is function overloading and operator overloading?
Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This capability is called function overloading. When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and order of the arguments in the call. Function overloading is commonly used to create several functions of the same name that perform similar tasks but on different data types.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of user-defined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form a pleasant facade that doesn’t add anything fundamental to the language (but they can improve understandability and reduce maintenance costs).
What is the difference between declaration and definition?
The declaration tells the compiler that at some later point we plan to present the definition of this declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.: void stars () // declarator
{
for(int j=10; j > =0; j–) //function body
cout << *;
cout <<>
What are the advantages of inheritance?
It permits code reusability. Reusability saves time in program development. It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional.
How do you write a function that can reverse a linked-list?
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur-> next = head;
for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
What do you mean by inline function?
The idea behind inline functions is to insert the code of a called function at the point where the function is called. If done carefully, this can improve the application’s performance in exchange for increased compile time and possibly (but not always) an increase in the size of the generated binary executables.
Write a program that ask for user input from 5 to 9 then calculate the average
#include “iostream.h”
int main() {
int MAX = 4;
int total = 0;
int average;
int numb;
for (int i=0; icout << “Please enter your input between 5 and 9: “;
cin >> numb;
while ( numb<5>9) {
cout << “Invalid input, please re-enter: “;
cin >> numb;
}
total = total + numb;
}
average = total/MAX;
cout << “The average number is: ” <<>return 0;
}
What is public, protected, private?
Public, protected and private are three access specifiers in C++.
Public data members and member functions are accessible outside the class.
Protected data members and member functions are only available to derived classes.
Private data members and member functions can’t be accessed outside the class. However there is an exception can be using friend classes.
What is scope & storage allocation of global and extern variables? Explain with an example
Extern variables: belong to the External storage class and are stored in the main memory. extern is used when we have to refer a function or variable that is implemented in other file in the same project.
The scope of the extern variables is Global.
Global variables: are variables which are declared above the main( ) function. These variables are accessible throughout the program. They can be accessed by all the functions in the program. Their default value is zero.
What is scope & storage allocation of static, local and register variables? Explain with an example.
Register variables: belong to the register storage class and are stored in the CPU registers. The scope of the register variables is local to the block in which the variables are defined. The variables which are used for more
number of times in a program are declared as register variables for faster access.
Example: loop counter variables.
register int y=6;
Static variables: Memory is allocated at the beginning of the program execution and it is reallocated only after the program terminates. The scope of the static variables is local to the block in which the variables are defined.
Example:
#include <stdio.h>
void decrement(){
static int a=5;
a–;
printf(“Value of a:%d\n”, a);
}
int main(){
decrement();
return 0;
}
Local variables: are variables which are declared within any function or a block. They can be accessed only by function or block in which they are declared. Their default value is a garbage value.
What are the advantages of using unions?
Union is a collection of data items of different data types.
It can hold data of only one member at a time though it has members of different data types.
If a union has two members of different data types, they are allocated the same memory. The memory allocated is equal to maximum size of the members. The data is interpreted in bytes depending on which member is being accessed.
Example:
union pen {
char name;
float point;
};
Here name and point are union members. Out of these two variables, ‘point’ is larger variable which is of float data type and it would need 4 bytes of memory. Therefore 4 bytes space is allocated for both the variables. Both the variables have the same memory location. They are accessed according to their type.
Union is efficient when members of it are not required to be accessed at the same time.
Tell how to check whether a linked list is circular.
Create two pointers, each set to the start of the list. Update each as follows:
while (pointer1) {
pointer1 = pointer1->next;
pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next;
if (pointer1 == pointer2) {
print (\”circular\n\”);
}
}
If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1, or the item before that. Either way, it’s either 1 or 2 jumps until they meet.
What is virtual constructors/destructors?
Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object.
There is a simple solution to this problem – declare a virtual base-class destructor. This makes all derived-class destructors virtual even though they don’t have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called.
Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error.
What are the advantages of inheritance?
• It permits code reusability.
• Reusability saves time in program development.
• It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional.
Does c++ support multilevel and multiple inheritance?
Yes.
What is the difference between an ARRAY and a LIST?
Array is collection of homogeneous elements.
List is collection of heterogeneous elements.
For Array memory allocated is static and continuous.
For List memory allocated is dynamic and Random.
Array: User need not have to keep in track of next memory allocation.
List: User has to keep in Track of next location where memory is allocated.
Array uses direct access of stored members, list uses sequencial access for members.
What is a template?
Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro. Its prototype is any of the two following ones:
What is the difference between class and structure?
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public.
Class: Class is a successor of Structure. By default all the members inside the class are private.
What is encapsulation?
Packaging an object’s variables within its methods is called encapsulation.
What is a COPY CONSTRUCTOR and when is it called?
A copy constructor is a method that accepts an object of the same class and copies it’s data members to the object on the left part of assignment:
class Point2D{
int x; int y;
public int color;
protected bool pinned;
public Point2D() : x(0) , y(0) {} //default (no argument) constructor
public Point2D( const Point2D & ) ;
};
Point2D::Point2D( const Point2D & p )
{
this->x = p.x;
this->y = p.y;
this->color = p.color;
this->pinned = p.pinned;
}
main(){yu
Point2D MyPoint;
MyPoint.color = 345;
Point2D AnotherPoint = Point2D( MyPoint ); // now AnotherPoint has color = 345
Program: To calculate the factorial value using recursion.
Program: To calculate the factorial value using recursion.
#include <stdio.h>
int fact(int n);
int main() {
int x, i;
printf(“Enter a value for x: \n”);
scanf(“%d”, &x);
i = fact(x);
printf(“\nFactorial of %d is %d”, x, i);
return 0;
}
int fact(int n) {
/* n=0 indicates a terminating condition */
if (n <= 0) {
return (1);
} else {
/* function calling itself */
return (n * fact(n – 1));
/*n*fact(n-1) is a recursive expression */
}
}
Output:
Enter a value for x:4
Factorial of 4 is 24
swap 2 numbers without using third variable?
#include <stdio.h>
void main()
{
int a,b;
printf(“enter number1: ie a”);
scanf(“%d”,a);
printf(“enter number2:ie b “);
scanf(“%d”,b);
printf(value of a and b before swapping is a=%d,b=%d”a,b);
a=a+b;
b=a-b;
a=a-b;
printf(value of a and b after swapping is a=%d,b=%d”a,b);
}
Write a C++ Program to check whether a number is prime number or not?
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i,flag=1;
cout<<“Enter any number:”;
cin>>n;
for(i=2;i<=n/2;++i)
{
if(n%i==0)
{
flag=0;
break;
}
}
if(flag)
cout<<“\n”<<n<<” is a Prime number”;
else
cout<<“\n”<<n<<” is not a Prime number”;
getch();
}
Write a program in c to replace any vowel in a string with z?
// Replace all vowels in str with ‘z’
void replaceWithZ(char* str) {
int i = 0;
while(str[i] != ‘z’) {
if(isVowel(str[i])) {
str[i] = ‘z’;
}
++i;
}
}
// Returns 1 if ch is a vowel, 0 otherwise
int isVowel(const char ch) {
switch(ch) {
case ‘a’:case ‘A’:
case ‘e’:case ‘E’:
case ‘i’:case ‘I’:
case ‘o’:case ‘O’:
case ‘u’:case ‘U’:
return 1;
}
return 0;
}
// Sample call
int main() {
char str[] = “HELLO”;
printf(“%s\n”, str);
replaceWithZ(str);
printf(“%s\n”, str);
return 0;
}
Question from Java
What is the final keyword denotes?
final keyword denotes that it is the final implementation for that method or variable or class. You can’t override that method/variable/class any more.
What is the significance of ListIterator?
You can iterate back and forth.
What is the major difference between LinkedList and ArrayList?
Linked List are meant for sequential accessing. ArrayList are meant for random accessing.
What is nested class?
If all the methods of a inner class is static then it is a nested class.
What is inner class?
If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.
What is composition?
Holding the reference of the other class within some other class is known as composition.
What is aggregation?
It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation.
What are the methods in Object?
clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString
Can you instantiate the Math class?
You can’t instantiate the math class. All the methods in this class are static. And the constructor is not public.
What is singleton? – It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton { private static final Singleton s = new Singleton(); private Singleton() { } public static Singleton getInstance() { return s; } // all non static methods … }
1.What is the difference between C and Java?
1.JAVA is Object-Oriented while C is procedural.
2.Java is an Interpreted language while C is a compiled language.
3.C is a low-level language while JAVA is a high-level language.
4.C uses the top-down approach while JAVA uses the bottom-up approach.
5.Pointer go backstage in JAVA while C requires explicit handling of pointers.
6.The Behind-the-scenes Memory Management with JAVA & The User-Based Memory Management in C.
7.JAVA supports Method Overloading while C does not support overloading at all.
8.Unlike C, JAVA does not support Preprocessors, & does not really them.
9.The standard Input & Output Functions–C uses the printf & scanf functions as its standard input & output while JAVA uses the System.out.print & System.in.read functions.
10.Exception Handling in JAVA And the errors & crashes in C.
2.What is the difference between array and pointer?
Pointer is a variable in a program is something with a name, the value of which can vary. The way the compiler and linker handles this is that it assigns
a specific block of memory within the computer to hold the value of that variable.
An array is a conceptual data representation consisting of a list of more than one item of a particular scalar type (int, float, char, structure, etc.) where each element is accessed by its index.3.What is the difference between Strings and Arrays?
– String can hold only char data. Where as an array can hold any data type.
– An array size can not be changed. Where as a string size can be changed if it is a char pointer
– The last element of an array is an element of the specific type. The last character of a string is a null – ‘’ character.
– The length of an array is to specified in [] at the time of declaration (except char[]). The length of the string is the number of characters + one (null character).
4.What is Recursion Function?
a) A recursive function is a function which calls itself.
b) The speed of a recursive program is slower because of stack overheads. (This attribute is evident if you run above C program.)
c) A recursive function must have recursive conditions, terminating conditions, and recursive expressions.
5.Diffrence between default and copy constructor?
6.What are abstract class?
An abstract class is a class which does not fully represent an object. Instead, it represents a broad range of different classes of objects. However, this representation extends only to the features that those classes of objects have in common. Thus, an abstract class provides only a partial description of its objects
7.Define Deadlock?
In an operating system, a deadlock is a situation which occurs when a process enters a waiting state because a resource requested by it is being held by another waiting process, which in turn is waiting for another resource. If a process is unable to change its state indefinitely because the resources requested by it are being used by other waiting process, then the system is said to be in a deadlock.
8.What is linked list?
Linked list is one of the fundamental data structures, and can be used to implement other data structures. In a linked list there are different numbers of nodes. Each node is consists of two fields. The first field holds the value or data and the second field holds the reference to the next node or null if the linked list is empty.
9.What is the difference bet do loop & do while loop?
The difference between a “do …while” loop and a “while {} ” loop is that the while loop tests its condition before execution of the contents of the loop begins; the “do” loop tests its condition after it’s been executed at least once. As noted above, if the test condition is false as the while loop is entered the block of code is never executed. Since the condition is tested at the bottom of a do loop, its block of code is always executed at least once.10.What is polymorphism & inheritance property?
Polymorphism is the ability to use an operator or function in different ways. Polymorphism gives different meanings or functions to the operators or functions. Poly, referring to many, signifies the many uses of these operators and functions. A single function usage or an operator functioning in many ways can be called polymorphism. Polymorphism refers to codes, operations or objects that behave differently in different contexts.
11.What is the difference between DBMS and RDBMS?
12.What is OOPS concept?
Object-oriented programming (OOP) is a programming paradigm using “objects” – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. Many modern programming languages now support OOP, at least as an option.
13.What are dynamic and static memory location?
The allocation of memory for the specific fixed purposes of a program in a predetermined fashion controlled by the compiler is said to be static memory allocation.
The allocation of memory (and possibly its later deallocation) during the running of a program and under the control of the program is said to be dynamic memory allocation.
14.Write a program in C to sort a list of numbers in ascending order?
#include <stdio.h>
#include <conio.h>
int main()
{
int a[10],i,j,temp=0;
printf(“Enter all the 10 numbers”);
for(i=0;i<10;i++)
scanf(“%d”,&a[i]);
for(i=0;i<10;i++) //This loop is for total array elements (n)
{
for(j=0;j<9;j++) //this loop is for total combinations (n-1)
{
if(a[j]>a[j+1]) //if the first number is bigger then swap the two numbers
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf(“The ordered array is”);
for(j=0;j<10;j++) //Finally print the ordered array
printf(“%d \t”,a[j]);
getch();
return 0;
}
15.Write a program in java to print the odd no. between 1 to 100?
16.What is the differentiate b/w analog and digital communication?
1. Ease of multiplexing. Multiplexing is used in both digital and analog systems to reduce the cost of wiring between two ends. However, FDM in analog systems is expensive and TDM suffers the effects of noise, distortion, and cross-talk. TDM in digital systems is simple and economical.
2. Ease of signalling. Call set-up establishment and other control information such as (on hook/off hook) are digital in nature and can be integrated easily into the digital system. In analog systems, this information needs a special attention.
3. Use of digital technology. The implementation of digital equipment is cheaper than its analog counterpart and more efficient. Digital processing of voice signals is also more effective in areas such as tone generation/detection, echo control, amplification, filtering, compounding, and format conversion.
4. Integration of transmission and switching. Traditionally, transmission and switching functions have been separate. In digital systems, these functions are integrated. As a result, the voice signals are digitized near the source and remain as such until delivered to the destination. Thus, eliminating the multiplexing/demultiplexing stages at each switch and improving the overall voice quality.
Advantages of a digital communication system over its analog:
Operability at low signal-to-noise
Signal regeneration
Accommodation of other services.
Performance monitorability
Ease of encryption
17.What is the difference between Truncate and Delete?
Truncate an Delete both are used to delete data from the table. These both command will only delete data of the specified table, they cannot remove the whole table data structure.Both statements delete the data from the table not the structure of the table.
TRUNCATE is a DDL (data definition language) command whereas DELETE is a DML (data manipulation language) command.
You can use WHERE clause (conditions) with DELETE but you can’t use WHERE clause with TRUNCATE .
You cann’t rollback data in TRUNCATE but in DELETE you can rollback data. TRUNCATE removes (delete) the record permanently.
A trigger doesn’t get fired in case of TRUNCATE whereas Triggers get fired in DELETE command.
If tables which are referenced by one or more FOREIGN KEY constraints then TRUNCATE will not work.
TRUNCATE resets the Identity counter if there is any identity column present in the table where delete not resets the identity counter.
Delete and Truncate both are logged operation.But DELETE is a logged operation on a per row basis and TRUNCATE logs the deallocation of the data pages in which the data exists.
TRUNCATE is faster than DELETE.
18.What are the advantages of SQL?
These are the advantages of PL/SQL.
Block Structures: PL SQL consists of blocks of code, which can be nested within each other. Each block forms a unit of a task or a logical module. PL/SQL Blocks can be stored in the database and reused.
Procedural Language Capability: PL SQL consists of procedural language constructs such as conditional statements (if else statements) and loops like (FOR loops).
Better Performance: PL SQL engine processes multiple SQL statements simultaneously as a single block, thereby reducing network traffic.
Error Handling: PL/SQL handles errors or exceptions effectively during the execution of a PL/SQL program. Once an exception is caught, specific actions can be taken depending upon the type of the exception or it can be displayed to the user with a message.
Hide data complexity
19.What is the difference between Dbms and OODbms?
DBMS: Database Management System
OODBMS: Object Oriented Database Management System
An object-relational database (ORD), or object-relational database management system (ORDBMS), is a database management system (DBMS) similar to a relational database, but with an object-oriented database model: objects, classes and inheritance are directly supported in database schemas and in the query language. In addition, just as with proper relational systems, it supports extension of the data model with custom data-types and methods.
Difference between SQL and PL /SQL?
Structured query language (SQL) is a database computer language designed for managing data in relational database management systems (RDBMS), and originally based upon relational algebra. Basic scope of SQL is to insert data and perform update, delete, schema creation, schema modification and data access control against databases.
PL SQL (Procedural Language/Structured Query Language) is a procedural extension language for data entry and manipulation by Oracle.
SQL is data oriented language for selecting and manipulating data but PL SQL is a procedural language to create applications.
SQL executes one statement at a time whereas in PL SQL block of code could be executed.
SQL is declarative where as PL SQL is procedural.
SQL is used to write Queries, Data Manipulation Language (DML) and Data Definition Language (DDL) whereas PL SQL is used to write Program blocks, Triggers, Functions, Procedures, and Packages.
Difference between DBMS and File System
In File System, files are used to store data while, collections of databases are utilized for the storage of data in DBMS.
Although File System and DBMS are two ways of managing data, DBMS clearly has many advantages over File Systems.
Typically when using a File System, most tasks such as storage, retrieval and search are done manually and it is quite tedious whereas a DBMS will provide automated methods to complete these tasks. Because of this reason, using
a File System will lead to problems like data integrity, data inconsistency and data security, but these problems could be avoided by using a DBMS.
Unlike File System, DBMS are efficient because reading line by line is not required and certain control mechanisms are in place.
20.What is the basic difference between a Join and a Union?
Union:
It combines the results of two or more queries into a single result set consisting of all the rows belonging to all queries in the union.
Basic Rules:
The number and the order of the columns must be the same in all queries.
The data types must be compatible.
Join:
To retrieve data from two tables or more than two tables then use joins.
Types: Inner Join, Outer Join(Right outer join, left outer join), cross join, Equi join, Self join.
The number and the order of the columns need not be the same in all queries.
21.what is a root?
“root” refers to the top-level directory of a file system. The word is derived from a tree root, since it represents the starting point of a hierarchical tree structure. The folders within the tree represent the branches, while the actual files are considered the leaves. However, unlike a real life tree, a data tree can be visualized upside down, with the root at the top and directories and subdirectories spanning downward.
The root node of a file system is also called the root directory. On a Windows-based PC, “C:\” represents the root directory of the C drive.
If you ever use a terminal program to view files and folders on a computer, you can use the command “cd /” (change directory to root) to navigate to the root directory.
“Root” is also the name of the user who has administrative privleges on a Unix or Linux server.