Recent questions and answers in Programming in C

187
views
1 answers
2 votes
Consider the following function:int arc(int i, int j){if(i<2) return j+2;else if(j<2) return arc(i-1, 1);else return arc(i-1, arc(i, j-2));}The value returned by arc(2, 6...
121
views
1 answers
0 votes
Consider the following function:int arc(int i, int j){if(i<2) return j+2;else if(j<2) return arc(i-1, 1);else return arc(i-1, arc(i, j-2));}The value returned by arc(2, 6...
3.6k
views
3 answers
5 votes
​​​​​What is the output of the following $\text{C}$ program?#include <stdio.h int main() { double a =20.0,25.0,* p,* q; p=a ; q=p+1 ; printf("%d,%d", (int) (q-...
122
views
0 answers
0 votes
let suppose address of first index of array is n and size of each block of array is u. then the index of second element is a+u.let suppose the array has m elements.what w...
53
views
0 answers
0 votes
1.5k
views
1 answers
0 votes
Consider the following left associative operators in decreasing order of precedence :- subtraction (highest precedence)* multiplication$ exponentiation (lowest precedence...
271
views
1 answers
1 votes
In which of the following case(s) character array must end with null char?char c[] = "GATE";char c[] = {'2', '0', '2', '3'};char c[4] = "GATE";char c[16] = "2023";
208
views
1 answers
0 votes
#include <stdio.h int main() { int a[3] = {1, 3, 5, 7, 9, 11}; int *ptr = a[0]; ptr += sizeof(int); printf("%d", *ptr); return 0; }(Assume size of int to be $2$ bytes.)T...
247
views
2 answers
2 votes
What will be printed by following $\text{C}$ code?int a[7] = {0, 1, 2, 3, 4, 5, 6}; int *p = &a[3]; p += 2; *p += 2; printf("%d", *p++);$6$$7$$8$$9$
238
views
2 answers
1 votes
#include<stdio.h>#define ADD(a,b)(a+b)#define SQUARE(x)(x*x)int main(){int x=2;int y=3;int z = ADD(SQUARE(x++),y);printf("%d\n",z);return 0;}What is the output of the abo...
2.8k
views
2 answers
7 votes
​​​Consider the following $\mathrm{C}$ function definition.int f X(char * a) { char * b = a; while (*b) b ++; return b - a; }Which of the following statements is/ar...
2.6k
views
2 answers
2 votes
​​Consider the following $\mathrm{C}$ function definition.int f (int x, int y){ for (int i=0 ; i<y ; i++ ) { x= x + x + y; } return x; }Which of the following stateme...
248
views
0 answers
0 votes
Problem Statement: Class teacher to IX-C wants to store whether a particular student has passed in exams. The class has a strength of $32$ students. Their roll numbers li...
212
views
2 answers
0 votes
What is the output of the below code?#include <stdio.h void main() { static int var = 5; printf("%d ", var ); if (var) main(); }a. 1 2 3 4 5b. 1c. 5 4 3 2 1d. Error
145
views
1 answers
1 votes
int bar(int val){int x=0;while(val 0){x=x+bar(val -1);}return val;}Q: For bar(3) this function is supposed to be stuck in an infinite loop but I do not know how please c...
249
views
1 answers
0 votes
#include<stdio.h>#include<conio.h>int main(){ int a[][3]={ {4,14,24},{5,15,25},{6,16,26}}; int *p[3]; int ptr=p; p[0]=a; p =a+1; p =a+2; ++*p; ...
1.2k
views
3 answers
0 votes
int main(){extern int a = 20;printf("%d",a); }//why this gives error but followig code is not extern int a =20;int main(){printf("%d",a); } //why this happens that first ...
16.0k
views
4 answers
132 votes
Suppose $n$ and $p$ are unsigned int variables in a C program. We wish to set $p$ to $^nC_3$. If $n$ is large, which one of the following statements is most likely to set...
1.2k
views
4 answers
6 votes
What will be output printed by the following program?#include<stdio.h main() { int c=4; switch(c) { c=c-1; case 4: printf("IITB ")...
453
views
3 answers
2 votes
What is the output of the following $\text{C}$ program?#include<stdio.h int main(void){ char s1[] = “Hello”; char s2[] = “World!”; s1 = s2; printf(“%s”,s1); }...
11.5k
views
4 answers
19 votes
The integer value printed by the $\textsf{ANSI-C}$ program given below is _______________#include<stdio.h int funcp(){ static int x = 1; x++; return x; } int main(){ int ...
519
views
1 answers
0 votes
Write a LISP function to compute the product of all the numbers in a list. Assume that the list contains only number.
189
views
0 answers
3 votes
My question is that can we use command line arguments without use of main function's parameters argc and *argv?
30.6k
views
11 answers
40 votes
Consider the following $\text{ANSI C}$ program.#include <stdio.h int main() { int arr[4][5]; int i, j; for (i=0; i<4; i++) ​​​​​​{ for (j=0; j<5; j++) { arr[i...
16.7k
views
8 answers
49 votes
Consider the following C program segment.# include <stdio.h int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = '0'; printf("%s", s1); }What will be printed by the pro...
189
views
0 answers
0 votes
 I have a question that can we use command line arguments without main function arguments?int main(int argc, char argv){}
242
views
1 answers
0 votes
Consider an array A of size 31 consisting of 0's followed by number of 1's. In order to find the smallest index i such that A[i]=1 minimum number of comparisons required ...
2.7k
views
2 answers
2 votes
let x be an array of integer . which of the following can not be present in the left hand side of an assignment statementa)x b) x+i c) * (x+i) d) &x[i]
222
views
1 answers
1 votes
Does C support fractional Indices?float x = some fraction;Is float a[x] valid declaration?
447
views
3 answers
2 votes
how does the program is working..?answer – 8
459
views
3 answers
6 votes
What will be the output of the following program?#include<stdio.h int rec(int x, int y) { static int count = 0; if (x == 0) return count; count++; if (x y) rec(x - y, y)...
3.5k
views
3 answers
2 votes
​​​Consider the following $\mathrm{C}$ program:#include <stdio.h void fX (); int main(){ fX(); return 0 };void fX () { char a; if ((a=g e t c h a r()) ! = '\n') ...
150
views
1 answers
0 votes
Find the error of the following IP addresses. If the IP is valid, check its Class and determine whether the address is Unicast or Multicast.i) 237.15.2.1ii) 256.1.8.9iii)...
6.1k
views
2 answers
2 votes
include <stdio.h int main() { int a[][3] = {1, 2, 3, 4, 5, 6}; int (*ptr)[3] = a; printf("%d %d ", (*ptr) , (*ptr) ); ++ptr; printf("%d %d\n", (*ptr) , (*ptr) ); return 0...
310
views
1 answers
2 votes
#include <stdio.h int main() { int i = -1; int x = (unsigned char)i; printf("%d", x); return 0; }output is 255 , but please explain how
4.5k
views
2 answers
5 votes
Consider the following $\text{C}$ program. Assume parameters to a function are evaluated from right to left.#include <stdio.h int g( int p) { printf("%d", p); return p; }...
28.8k
views
13 answers
70 votes
Consider the following C program.#include<stdio.h #include<string.h int main() { char* c="GATECSIT2017"; char* p=c; printf("%d", (int)strlen(c+2[p]-6[p]-1)); return 0; }T...
19.6k
views
4 answers
59 votes
Consider the following function.double f(double x){ if( abs(x*x - 3) < 0.01) return x; else return f(x/2 + 1.5/x); }Give a value $q$ (to $2$ decimals) such that $f(q)$ wi...
226
views
1 answers
0 votes
How can we find the highest element in a singly linked list in O(1)? We are free to use any extra space.
To see more, click for all the questions in this category.