1 4 18 6 / 3 + + 5 / +
void fun(int x, long y)
{}
void main ()
{
int i = 10;
long j = 120;
long *p = &j;
__________ ; // call to fun() from main
}
Which one of the following expressions, when placed in the blank above, will NOT result in an error?
void count(int n) {
static int d=1;
printf("%d ", n);
printf("%d ", d);
d++;
if(n>2) count(n-1);
printf("%d ", d);
}
void main() {
count(3);
}
What will be the output of above program?
Pseudocode:
str [ ] = sequence of parenthesis
while (str[i])
{ if (open parenthesis) push into stack;
else
pop( )
}
int fun(int j)
{
static int i = 30;
int k;
if (i == j)
{
printf("something");
k = fun(i);
return 0;
}
else return 0;
}
Which one of the following is TRUE?
The above declaration syntax is for:
char *ch;
int *in;
float *fl;
sizeof(ch);
sizeof(in);
sizeof(fl);
What’s the size returned for each of sizeof() operator?
void fun1(char* s1, char* s2){
char* temp;
temp = s1;
s1 = s2;
s2 = temp;
}
void fun2(char** s1, char** s2){
char* temp;
temp = *s1;
*s1 = *s2;
*s2 = temp;
}
int main(){
char *t1="Corona", *t2 = "Go";
fun1(t1, t2); printf("%s %s", t1, t2);
fun2(&t1, &t2); printf("%s %s", t1, t2);
return 0;
}
The output of the program above is:
Note: consider base address to be 100, and array indexing starts from [0,0]
void main()
{
int arr[3][3]={1,2,3,4,5,6,7,8,9};
printf("%d",arr[2]);
}
What is the output of the above code?
#include<stdio.h>
void main()
{
char s[100];
s="Gate";
printf("%s",s);
}
return( (x<y) ? 0 : (x-y) );
}
void main()
{
int x=5, y=9,z;
Z = find(5,9);
}
Let x,y are non-negative numbers and if we call find(x, find(x,y)),then What is the Output of above code:
{
char ename[30];
int ssn;
int deptno;
} employee;
Choose incorrect statement about above snippet of code:
#include<stdio.h>
void main()
{
int a = 5;
int *ptr = NULL;
printf("%d\n",*ptr);
}
#include <stdio.h>
void my_fun(int x){
printf( "%d\n", x );
}
int main(){
void (*fptr)(int);
A ; // Initializing Function Pointers
fptr( 2 );
return 0;
}
What can be the statement A?
1) A : fptr = &my_fun
2) A : fptr = my_fun
3) A : *fptr = my_fun
4) A : *fptr = &my_fun
The inorder traversal of a BST is 11, 12, 13, 16, 24, 26 and pre-order traversal is 24, 12, 11, 16, 13, 26.
If we remove the root node , then which of the following from the left subtree will be the new root?
The inorder traversal of a BST is 11, 12, 13, 16, 24, 26 and the preorder traversal of the same tree is: 16, 12, 11, 13, 26, 24.
If the root node is deleted then what will be the next root of the resultant tree?
(i) 13 (ii) 24 (iii) 11 (iv) 26
{
int data;
struct Node *next;
};
void fun(struct Node* prev_node, int new_data)
{
/*1. check if the given prev_node is NULL */
if (prev_node == NULL)
{
printf("the given previous node cannot be NULL");
return;
}
struct Node* new_node =(struct Node*) malloc(sizeof(struct Node));
new_node->data = new_data;
prev_node->next = new_node;
new_node->next = prev_node->next;
}
void main()
{
struct Node* head=NULL;
struct Node* N1=NULL;
struct Node* N2=NULL;
struct Node* N3=NULL;
head=(struct Node*)malloc(sizeof(struct Node));
N1=(struct Node*)malloc(sizeof(struct Node));
N2 = (struct Node*)malloc(sizeof(struct Node));
N3 = (struct Node*)malloc(sizeof(struct Node));
head -> data = 0;
N1 -> data =1;
N2 -> data =2;
N3 -> data =3;
head -> next = N1;
N1 -> next = N2;
N2 -> next = N3;
N3 -> next =NULL;
fun(N2, 10);
}
What does the above code do?
Which among the following is primitive data structure? [MSQ]
Note: Full ternary tree is a tree whose all nodes have 0 or 3 children
{
int data; // Data
node *bwd; // A reference to the previous node
node *fwd; // A reference to the next node
};
Consider a doubly linked list, which has a pointer named ‘rearmost’, which is pointing to the last element of the list. Which among the following segments of code deletes the element pointed by ‘rearmost’?
A B X E M S W T P N C H
E X M B S A P T N W H C
The post-order traversal of the tree is?
struct node
{
int data; // Data
node *bwd; // A reference to the previous node
node *fwd; // A reference to the next node
};
I) 7, 6, 5, 4, 3, 2, 1
II) 1, 2, 3, 4, 5, 6, 7
III) 4, 2, 6, 1, 3, 5, 7
IV) 4, 6, 2, 5, 3, 1, 7
for(i = 1, i< = 8; i++)
q.enqueue(i);
for ( i = 1; i<=7; i++)
{
q.dequeue();
q.enqueue(q.dequeue());
}
Assume enqueue and dequeue are circular operations for insertion and deletion respectively. The number of elements that will remain in the queue after the completion of the program is ___________
#include<stdio.h>
void print(char *a)
{
if (*a && *a != '*')
{
print(a+2);
putchar(*a);
}
}
void main()
{
print("123456*");
}