search
Log In

Recent questions tagged programming

0 votes
1 answer
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
asked Mar 24 in Web Technologies jothee 115 views
5 votes
3 answers
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
asked Mar 5 in Programming vivek_mishra 213 views
4 votes
3 answers
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$
asked Jan 13 in Programming Satbir 540 views
2 votes
3 answers
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$
asked Jan 13 in Programming Satbir 318 views
3 votes
0 answers
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$
asked Jan 13 in Programming Satbir 418 views
2 votes
2 answers
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$
asked Jan 13 in Programming Satbir 371 views
7 votes
1 answer
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$
asked Jan 13 in Programming srestha 679 views
7 votes
2 answers
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$
asked Jan 13 in Programming srestha 660 views
0 votes
1 answer
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?
asked Jun 1, 2019 in Programming Satbir 540 views
4 votes
3 answers
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 ___________
asked May 20, 2019 in Programming srestha 330 views
2 votes
1 answer
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)$
asked May 19, 2019 in Programming srestha 343 views
2 votes
2 answers
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?$
asked May 12, 2019 in Programming srestha 250 views
1 vote
0 answers
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:(
asked May 10, 2019 in Programming srestha 224 views
1 vote
0 answers
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??
asked May 8, 2019 in Programming srestha 231 views
1 vote
1 answer
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; }
asked May 7, 2019 in Programming kaveeshnyk 247 views
3 votes
3 answers
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.
asked May 4, 2019 in Programming srestha 278 views
1 vote
0 answers
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?$ .
asked May 4, 2019 in Programming srestha 187 views
3 votes
3 answers
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
asked Apr 29, 2019 in Programming manikgupta123 523 views
0 votes
1 answer
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?
asked Apr 25, 2019 in Programming srestha 190 views
1 vote
1 answer
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
asked Apr 24, 2019 in Programming srestha 144 views
0 votes
2 answers
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
asked Apr 24, 2019 in Programming srestha 169 views
1 vote
3 answers
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?
asked Apr 24, 2019 in DS srestha 282 views
0 votes
0 answers
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}$
asked Apr 8, 2019 in Digital Logic akash.dinkar12 130 views
1 vote
1 answer
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".$
asked Apr 8, 2019 in Programming akash.dinkar12 150 views
0 votes
2 answers
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]); } }
asked Apr 7, 2019 in Programming shiva0 246 views
1 vote
1 answer
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$?
asked Mar 23, 2019 in Programming srestha 91 views
0 votes
2 answers
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?
asked Mar 19, 2019 in Operating System akash.dinkar12 112 views
0 votes
0 answers
28
Using the program shown below, explain what the output will be at lines X and Y. #include <sys/types.h> #include <stdio.h> #include <unistd.h> #define SIZE 5 int nums[SIZE] = {0,1,2,3,4}; int main() { int i; pid t pid; pid = fork(); if (pid == 0) { for (i = 0; i < SIZE; i++) { ... else if (pid > 0) { wait(NULL); for (i = 0; i < SIZE; i++) printf("PARENT: %d ",nums[i]); /* LINE Y */ } return 0; }
asked Mar 19, 2019 in Operating System akash.dinkar12 46 views
0 votes
0 answers
29
Using the program in Figure 3.34, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively.) #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid t pid, pid1; /* fork a child ... printf("parent: pid = %d",pid); /* C */ printf("parent: pid1 = %d",pid1); /* D */ wait(NULL); } return 0; }
asked Mar 19, 2019 in Operating System akash.dinkar12 82 views
0 votes
1 answer
30
Explain the circumstances under which which the line of code marked printf("LINE J") in following program will be reached. #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid t pid; /* fork a child process */ pid = fork(); if (pid < 0) { / ... else { /* parent process */ /* parent will wait for the child to complete */ wait(NULL); printf("Child Complete"); } return 0; }
asked Mar 19, 2019 in Operating System akash.dinkar12 143 views
...