# Recent questions tagged programming

1
What can you say about the following statements? XML tags are case-insensitive In JavaScript, identifier names are case-sensitive Cascading Style Sheets (CSS) cannot be used with XML All well formed XML documents must contain a document type definition only I and II are false only III and IV are false only I and III are false only II and IV are false
2
#include int main( ) { int x=5, y=9; x=(x= x+y)-(y= x-y); printf("%d %d ", x, y); return 0; } A. 9 5 B. 5 14 C. 14 5 D. 5 9
3
What is the output of the code given below? # include<stdio.h> int main() { char name[]="satellites"; int len; int size; len= strlen(name); size = sizeof(name); printf("%d",len*size); return 0; } $100$ $110$ $40$ $44$
4
Consider the following recursive C function that takes two arguments unsigned int rer(unsigned int n, unsigned int r){ if(n>0)return(n%r + rer(n/r,r)); else retturn 0; } What is the return value of the function $rer$ when it is called as $rer(513,2)$? $9$ $8$ $5$ $2$
5
In the following procedure Integer procedure P(X,Y); Integer X,Y; value x; begin K=5; L=8; P=x+y; end $X$ is called by value and $Y$ is called by name. If the procedure were invoked by the following program fragment K=0; L=0; Z=P(K,L); then the value of $Z$ will be set equal to $5$ $8$ $13$ $0$
6
Following declaration of an array of struct, assumes size of byte, short, int and long are $1,2,3$ and $4$ respectively. Alignment rule stipulates that $n$ - byte field must be located at an address divisible by $n$, the fields in the struct are not rearranged, padding is used to ensure ... $8$, what is the total size of $C$, in bytes? $150$ $160$ $200$ $240$
7
What is the output in a $32$ bit machine with $32$ bit compiler? #include<stdio.h> rer(int **ptr2, int **ptr1) { int *ii; ii=*ptr2; *ptr2=*ptr1; *ptr1=ii; **ptr1*=**ptr2; **ptr2+=**ptr1; } void main(){ int var1=5, var2=10; int *ptr1=&var1,*ptr2=&var2; rer(&ptr1,&ptr2); printf("%d %d",var2,var1); } $60,70$ $50,50$ $50,60$ $60,50$
8
What is output of the following ‘C’ code assuming it runs on a byte addressed little endian machine? #include<stdio.h> int main() { int x; char *ptr; x=622,100,101; printf("%d",(*(char *)&x)*(x%3)); return 0; } $622$ $311$ $22$ $110$
9
#include<stdio.h> #include<stdlib.h> int main(void) { int maxLineCount = 500, maxCharCount = 500, index, j, count; char *line = NULL; size_t size; char *a[maxLineCount]; for (index = 0; index < maxLineCount; index++) a[index] = (char *)malloc(maxCharCount * ... of the code is doing. suppose we have 3 string given as input in 3 different lines then how can we access each character of the string?
10
#include<stdio.h> #include<iostream> int bar(int m, int n){ if(m==0)return n; if(n==0)return m; return bar(n%m,m); } int foo(int m,int n){ return(m*n/bar(m,n)); } int main(){ int x=foo(1000,1500); printf("%d",x); return 0; } Output of the program is ___________
11
Consider the following $C$ implementation which when given $3$ numbers a,b,c as input, find the maximum of $3$ numbers $a,b,c.$ int kickstart(int a,int b,int c) { if(B1) return a; if(a>=b) return B2; return kickstart(c,a,b); } How the boxes filled up correctly? $I)B1:a\geq b$ ... $IV)B1:a\geq b$ && $a\geq c, B2:kickstart\left ( b,c,a \right );$ Is it $I) and II)$ or $I) and IV)$
12
Consider the following function $foo()$ void foo(int n){ if(n<=0) printf("Bye"); else{ printf("Hi"); foo(n-3); printf("Hi"); foo(n-1); } } Let $P(n)$ represent recurrence relation, indicating number of time print statement executed. What will best recurrence for ... $n=0$ The options are confusing to me. Can someone explain the options well. Moreover , what will be constant added $1$ or $2?$
1 vote
13
Consider the following C code: int getNextGap(int gap){ gap=(gap*10)/13; if(gap<1)return 1; return gap; } void mystery(int a[ ],int n){ int gap=n; bool red=true; while(gap!=1||red==true){ gap=getNextGap(gap); red=false; for(int i=0;i<(n-gap ... n is number of array elements, then what output will print at last? I mostly stuck how bool function working here. Plz help me out, how program executing:(
1 vote
14
Consider the following function int fun(int a[ ],int l, int target){ int i=0,j=0,sum=0,count=0; while(j<l){ if(sum<target){ sum=sum+a[j]; j++; } else if(sum>target){ sum=sum-a[i]; i++; } else{ count++; sum=sum-a[i]; i++; } } if(sum==target) ... be return value of function call $fun\left ( a,16,8 \right )=$_______________ Given ans $6,$ but I got $4.$ Which one correct?? Any shortcut to evaluate??
1 vote
15
#include<stdio.h> int main(){ int (*a)[5]; int arr[5][5]={ {10,65,300,400,500}, {100,20,3000,40,5000} }; a = arr; ++a ; char *ptr = (char*)*a; ++a ; printf("%d %d %d",**a,*arr[1],*ptr); return 0; }
16
#include<stdio.h> #include<string.h> int main(void) { char *a="MADEEASY"; char *b="GATECSIT2019"; char *r=a; char *s=b; printf("%d",(int)strlen(b+3[r]-1[s])); return 0; } Ans is given $8.$ I know basic thing, but couldnot getting what strlen(b+3[r]-1[s]) returning?? Plz explain.
1 vote
17
Consider the following program: void A(int n){ printf("*"); if(n>1){ A(n/4); A(n/4); A(n/4); A(n/4); } } Let $X$ be number of asterisks printed by above function when $n=1024.$ Then the value of $X$ will be ____________ How ans will be $\frac{4^{k+1}-1}{3}$ , where $k=5?$ .
18
for(int i=0; i<=100;i++) { if (i % 3 == 0) printf("Great); if(i%5 == 0) printf("India"); } Count the number of times GreatIndia is printed. 6 20 33 none of these
19
Consider the following C program #include<stdio.h> int main(){ char *arr={"GATE","CAT","IES","IAS","PSU","IFS"}; call(arr); return 0; } void call(char **ptr){ char **ptr1; ptr1=(ptr+=(sizeof(int)))-2; printf("%s",*ptr1); } Assume size of int pointer 4B.What will be output?
1 vote
20
Suppose a queue $Q$ and two stacks $S_{1}$ and $S_{2}$ as given below. void enqueue(Q,x){ push(S1,x); } void dequeue(Q,x){ if(stack-empty(S2))then if(stack-empty(S1))then{ print("Q is empty"); return; } else while(!stack-empty(S1)){ x= ... is equal to______________ $Enqueue(4),Enqueue(3),Enqueue(2),Dequeue, Enqueue(6),Dequeue,Dequeue, Dequeue,Enqueue(5)$ Please tell value of X and Y are u getting
21
Consider the function give below, which should return the index of first zero in input array of length $n$ if present else return $-1.$ int index of zero(int[ ] array,int n){ for(int i=0; P ;i++); if(i==n){ return -1; } return i; } What should be placed in place code at ‘P’,So that code will work fine? $A)$array[i]!=0 && i<=n $B)$ array[i]!=0 && i<n
1 vote
22
Which of the following data structure is efficient to implement priority queue such as insertion ,deletion, searching? A)Linked List B)Heap C)Sorted Array D)Unsorted Array How priority queue can work more efficiently in any data structure, other than heap?
23
Consider a simple code $\mathcal{C}$ for error detection and correction. Each codeword in $\mathcal{C}$ consists of $2$ data bits $[d_1, d_0]$ followed by check bits $[c_2, c_1, c_0]$ ... $2$ addition. Write down all the codewords for $\mathcal{C}$ Determine the minimum Hamming distance between any two distinct codewords of $\mathcal{C}$
1 vote
24
Write a $C$ program to fins all permutations of a string (having at most 6 characters). For example, a string of $3$ characters like $“abc"$ has 6 possible permutations: $“abc", “acb", “bca", “bac", “cab", “cba".$
25
i write this program, during initialization of array i given the size as 11 means the number of elements stored in an array is 11. as we know array is not assigned a value of index 12 and above. but in in the program array a is initialized of index from 0 to 19,my question is how the array is initialized with 20 ... ; for(i=0;i<20;i++) { a[i]=i+1; } for(i=0;i<20;i++) { printf("%d\n",a[i]); } }
1 vote
26
int x = 5, y = 10 ; void main ( ) { int i = 2, j = 3 A (i, j); } void A (int i, int j) { int x = 10, y = 5 ; i = i + x : j = i + y : printf ("%d %d", i, j); B (i, j); } void B (int i, int j) { i = j + y ; j = ... 2. call-by-name 3. call-by-need 4. call-by-value 5.Static scoping 6.Dynamic scoping Any reference for call by name and call by need Is for static coping $12,17,54$ or $12,17,59$?
27
Consider the following code segment: pid t pid; pid = fork(); if (pid == 0) { /* child process */ fork(); thread create( . . .); } fork(); a. How many unique processes are created? b. How many unique threads are created?