Archive for c language questions
You are browsing the archives of c language questions.
You are browsing the archives of c language questions.
Answer :
C++ places greater emphasis on type checking, compiler can diagnose every difference between C and C++.
1. structures are a way of storing many different values in variables of potentially difference types under the same name.
2. classes and structures make program modular, easier to modify make things compact.
3. useful when a lot of [...]
21. What is the full form of CMM
(a) Capability Maturity Model
(b) Cost Maintainance Model
(c) Capability maintainance model
(d) Cost Maturity Model
Ans:A
22. Sorting is not possible by using which of the following methods?
(a) Insertion
(b) Selection
(c) Exchange
(d) Deletion
Ans:D
23. What are the methods available in storing sequential files ?
(a) Straight merging,
(b) Natural merging,
(c) Polyphase sort
(d) all
Ans:D
24. Conditional results [...]
1. What type of memory could be accessed in least time?
(a)cache memory
(b)secondary memory
(c)main memory
(d)none
Ans:A
2. void main()
{
int const * p=5;
printf("%d",++(*p));
}
What is the output?
(a) 6
(b) 5
(c) [...]
1.What is data structure?
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..
2. List out the areas in which data structures are applied extensively?
Compiler [...]
Data Structure - Exam Oriented Material
Must Read Before Examination
1. What is data structure?
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 [...]
/*queue various operation*/
#include<stdio.h>
#include<conio.h>
#define MAXSIZE 5
int front=-1, rear=-1,choice;
int q[10];
void main()
{
clrscr();
do
{
printf("\n1–>insert\n");
printf("2–>delete\n");
printf("3–>display\n");
printf("4–>exit\n");
printf("enter your choice\n");
scanf("%d",&choice);
switch(choice)
{
case 1:qinsert();
break;
case 2:qdelete();
break;
case 3:qdisplay();
break;
case 4:return;
}
}
while(choice!=4);
}
qinsert()
{
int num;
if(rear==(MAXSIZE-1))
{
printf("queue is full\n");
return;
}
else
{
printf("enter no\n");
scanf("%d",&num);
rear=rear+1;
q[rear]=num;
if(front==-1)
{
front++;
}
}
return;
}
qdelete()
{
int num;
if(front==-1)
{
printf("queue empty\n");
return;
}
else
{
if(front==rear)
front=rear=-1;
else
{
num=q[front];
printf("deleted item=%d",q[front]);
front++;
}
}
return(num);
}
qdisplay()
{
int i;
if(front==-1)
{
printf("queue empty\n");
return;
}
else
{
printf("\nThe status of the queu\n");
for(i=front;i<=rear;i++)
{
printf("%d\n",q[i]);
}
}
printf("\n");
}
/*search*/
#include<stdio.h>
#include<conio.h>
void main()
{
int [...]
/*Multiplication of the Matrix*/
#include<stdio.h>
#include<conio.h>
void main( )
{
int a[2][2], b[2][2],s[2][2];
int i,j,k;
clrscr();
printf("Enter first matrix:\n" );
for( i=1;i<=2;i++)
{
for( j=1;j<=2;j++)
{
printf("Enter%d%d\n",i,j);
scanf("%d",&a[i][j]);
}
}
printf("Enter second matrix:\n");
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
printf("Enter %d%d\n",i,j);
[...]
/*linked list*/
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
void main()
{
struct node
{
int num;
struct node *ptr;
};
typedef struct node NODE;
NODE *head, *first, *temp;
int count=0;
int choice=1;
first=NULL;
while(choice)
{
head=(NODE *)malloc(sizeof(NODE));
printf("Enter the data item\n");
scanf("%d",&head->num);
if(first!=NULL)
{
temp->ptr=head;
temp=head;
}
else
{
first=temp=head;
}
fflush(stdin);
printf("Do you want to continue(type 0 or 1)?\n");
scanf("%d",&choice);
}
temp->ptr=NULL;
temp=first;
printf("Status of the linked list is\n");
while(temp!=NULL)
{
printf("%d",temp->num);
count++;
temp=temp->ptr;
}
printf("NULL");
printf("NO of nodes in the list =%d\n",count);
getch();
}
/*insertion in tree*/
#include<stdio.h>
#include<conio.h>
struct rec
{
long num;
struct rec *left;
struct rec *right;
};
struct rec *tree=NULL;
struct [...]
/*Insertion and Deletion*/
#include<stdio.h>
#include<conio.h>
struct stack
{
int no;
struct stack *next;
}
*start=NULL;
typedef struct stack st;
void push();
int pop();
void display();
void main()
{
char ch;
int choice,item;
do
{
clrscr();
printf("\n 1: push");
printf("\n 2: pop");
printf("\n 3: display");
printf("\n Enter your choice");
scanf("%d",&choice);
switch (choice)
{
case 1: push();
break;
case 2: item=pop();
printf("The delete element in %d",item);
break;
case 3: display();
break;
default : printf("\n Wrong choice");
};
printf("\n do you want to continue(Y/N)");
fflush(stdin);
scanf("%c",&ch);
}
while (ch==’Y'||ch==’y');
}
void push()
{
st *node;
node=(st *)malloc(sizeof(st));
printf("\n Enter the number to be insert");
scanf("%d",&node->no);
node->next=start;
start=node;
}
int [...]
/*insert subtree*/
#include<stdio.h>
#include<conio.h>
struct rec
{
long num;
struct rec *left;
struct rec *right;
};
struct rec *tree=NULL;
struct rec *insert(struct rec *tree,long num);
void *exchange(struct rec *tree);
struct rec *temp;
void main()
{
struct rec *tree=NULL;
int choice;
long digit;
do
{
choice=select();
switch(choice)
{
case 1: puts("Enter integer: To quit enter [...]
30. What is an action class?
Answer:
The simplest and most obvious way to specify an action in C++ is to write a function. However, if the action has to be delayed, has to be transmitted ‘elsewhere’ before being performed, requires its own data, has to be combined with other actions, etc then it often becomes [...]
9. List out some of the OODBMS available.
Answer:
GEMSTONE/OPAL of Gemstone systems.
ONTOS of Ontos.
Objectivity of Objectivity inc.
Versant of Versant object technology.
Object store of Object Design
ARDENT of ARDENT software.
POET of POET software.
10. List out some of the object-oriented methodologies.
Answer:
Object Oriented Development (OOD) (Booch 1991,1994).
Object Oriented Analysis and [...]
146)
main()
{
static int a[3][3]={1,2,3,4,5,6,7,8,9};
int i,j;
static *p[]={a,a+1,a+2};
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j),
*(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i));
}
}
Answer:
1 1 1 1
2 4 2 4
3 7 [...]
All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment,
The underlying machine is an x86 system,
Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:
1.
[...]
1. What is the output of printf(”%d”)
2. What will happen if I say delete this
3. Difference between “C structure” and “C++ structure”.
4. Difference between a “assignment operator” and a “copy constructor”
5. What is the difference between “overloading” and “overriding”?
6. Explain the need for “Virtual Destructor”.
7. Can we have “Virtual Constructors”?
8. What are the different types of polymorphism?
9. What are Virtual Functions? How to implement [...]
1. What is a class?
2. What is an object?
3. What is the difference between an object and a class?
4. What is the difference between class and structure?
5. What is public, protected, private?
6. What are virtual functions?
7. What is friend function?
8. What is a scope resolution operator?
9. What do you mean by inheritance?
10. What is abstraction?
11. What is polymorphism? Explain with an example.
12. What is encapsulation?
13. What do you [...]
1. What is a class?
2. What is an object?
3. What is the difference between an object and a class?
4. What is the difference between class and structure?
5. What is public, protected, private?
6. What are virtual functions?
7. What is friend function?
8. What is a scope resolution operator?
9. What do you mean by inheritance?
10. What is abstraction?
11. What is polymorphism? Explain with an example.
12. What is encapsulation?
13. What do you [...]
1. What does static variable mean?
2. What is a pointer?
3. What is a structure?
4. What are the differences between structures and arrays?
5. In header files whether functions are declared or defined?
6. What are the differences between malloc() and calloc()?
7. What are macros? what are its advantages and disadvantages?
8. Difference between pass by reference and pass by value?
9. What is static identifier?
10. Where are the auto [...]