Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged programming-in-c
0
votes
1
answer
1081
Programming in C
#include<stdio.h> void test(int); void test1(int *); int main() { int x = 30, *s = &x; test(x++); //test(30++) ...statement P test1(s++); //test(some address++) ...statement S return 0; } void test(int x){ printf("%d\n" ... *s){ printf("%d\n",*s); } My doubt is why are we not getting L-value error in both the cases? The program correctly outputs 30 31
#include<stdio.h>void test(int);void test1(int *);int main() { int x = 30, *s = &x; test(x++); //test(30++) ...statement P te...
just_bhavana
594
views
just_bhavana
asked
Nov 10, 2017
Programming in C
programming-in-c
l-value
+
–
0
votes
1
answer
1082
online
Explain the behaviour of following code: int main() { int *j=0; { int i=10; j=&i; } printf("%d",*j); } a. output is 10. j pointed to address of i, so it was not freed. b. output may be 10 or garbage in given execution c. output is 10. i becomes invisible outside of its block scope, but lives as long as function scope d. output is 0.
Explain the behaviour of following code:int main(){int *j=0;{int i=10;j=&i;}printf("%d",*j);} a. output is 10. j pointed to address of i, so it was not freed.b. output ma...
targate2018
283
views
targate2018
asked
Nov 9, 2017
Programming in C
programming
programming-in-c
bad-question
+
–
0
votes
1
answer
1083
PTCUL-03
In C language, bitwise operation can be applied to which of the following operands A. char B. int C. short, long D. All of these
In C language, bitwise operation can be applied to which of the following operandsA. char B. int C. short, long ...
rishu_darkshadow
336
views
rishu_darkshadow
asked
Nov 8, 2017
Programming in C
ptcul-2017
programming-in-c
bitwise
+
–
1
votes
1
answer
1084
PTCUL-01
Semantic error can be detected at: A. compile time B. Runtime C. Both D. None of these
Semantic error can be detected at:A. compile timeB. RuntimeC. BothD. None of these
rishu_darkshadow
2.0k
views
rishu_darkshadow
asked
Nov 8, 2017
Programming in C
ptcul-2017
semantic-error
programming-in-c
compiler-design
+
–
1
votes
1
answer
1085
#techtud What does the following fragment of C- program print?
What does the following fragment of C- program print? char t[] = "PROGRAM1234"; char *r = t; printf ("%s", r + r[6]- r[3]); Explain.
What does the following fragment of C- program print?char t[] = "PROGRAM1234"; char *r = t; printf ("%s", r + r[6]- r[3]);Explain.
Rohit Gupta 8
468
views
Rohit Gupta 8
asked
Nov 8, 2017
Programming in C
programming-in-c
+
–
0
votes
1
answer
1086
#techtud. Let A be a square matrix of size n x n. Consider the following program. What is the expected output?
Let A be a square matrix of size n x n. Consider the following program. What is the expected output?C = 100 for(i=0; i<n; i++) for (j=0; j<n; j++) { Temp = A[i][j] + C A[...
Rohit Gupta 8
7.3k
views
Rohit Gupta 8
asked
Nov 8, 2017
Programming in C
programming-in-c
programming
+
–
2
votes
1
answer
1087
Output of a program
What will be the output of the following C program: void print1(void) { static int x=10; x+=5; printf("%d",x); } void print2(void) { static int x; x=10; x+=5; printf("%d",x); } int main() { print1(); print1(); print2(); print2(); return 0;} 15, 20, 25, 30 15, 20, 15, 20 15, 15, 15, 15 None of these
What will be the output of the following C program:void print1(void){static int x=10;x+=5;printf("%d",x);}void print2(void){static int x;x=10;x+=5;printf("%d",x);}int mai...
Shivi rao
627
views
Shivi rao
asked
Nov 7, 2017
Programming in C
programming-in-c
output
+
–
0
votes
1
answer
1088
linked list
i am getting 7 but ans given is 6.
i am getting 7 but ans given is 6.
raviyogi
423
views
raviyogi
asked
Nov 7, 2017
Programming in C
linked-list
programming-in-c
+
–
0
votes
1
answer
1089
mock test
#include <stdio.h> #define R 10 #define C 20 int main() { int (*p)[R][C]; printf("%d", sizeof(*p)); getchar(); return 0; } a 200 B 4 c 800 D 80
#include <stdio.h>#define R 10#define C 20int main(){ int (*p)[R][C]; printf("%d", sizeof(*p)); getchar(); return 0;}a200B4c800D80
chandra sai
274
views
chandra sai
asked
Nov 6, 2017
Programming in C
programming-in-c
pointers
+
–
1
votes
1
answer
1090
self doubt
Why does this code: char *p = "hello, world!"; p[0] = 'H'; crash?
Why does this code:char *p = "hello, world!"; p[0] = 'H';crash?
chandra sai
308
views
chandra sai
asked
Nov 6, 2017
DS
programming-in-c
+
–
–1
votes
0
answers
1091
C PROGRAM OUTPUT
Parshu gate
213
views
Parshu gate
asked
Nov 6, 2017
Programming in C
programming-in-c
+
–
0
votes
0
answers
1092
Scoping
int i ; program main () { i = 10; call f(); } procedure f() { i = 20; call g (); } procedure g () { print i; } What will be the output using Static Scoping and Dynamic Scoping ? My ans : In Static Scoping Global variable is set by main firstly,now global ... f , it sets the Global variable i to 20. Calling g ---> output is 20. Dynamic Scoping output is also 20 . Can someone check this ?
int i ; program main () { i = 10; call f(); } procedure f() { i = 20; call g (); } procedure g () { print i; }What will be the output using Static Scoping and Dynamic Sco...
Anjan
406
views
Anjan
asked
Nov 5, 2017
Programming in C
programming-in-c
+
–
2
votes
2
answers
1093
Find the output
OPTIONS A)7,19 B) 10,1 C) 10,23 D)10,32
OPTIONSA)7,19 B) 10,1 C) 10,23 D)10,32
Parshu gate
1.4k
views
Parshu gate
asked
Nov 5, 2017
Programming in C
programming-in-c
output
+
–
0
votes
3
answers
1094
NET nov-17 paper-2 Q11
ptrdata is a pointer to a data type . The expression *ptrdata++ is evaluated as ( in C++) a) *(ptrdata++) b) (*ptrdata)++ c) *(ptrdata)++ d) depends on compiler
ptrdata is a pointer to a data type . The expression *ptrdata++ is evaluated as ( in C++) a) *(ptrdata++) b) (*ptrdata)++c) *(ptrdata)++ d) depends on compiler
Meenakshi Sharma
2.4k
views
Meenakshi Sharma
asked
Nov 5, 2017
Programming in C
programming-in-c
pointers
+
–
0
votes
1
answer
1095
Call by name, by refrence, by need and by value
void main() { int i = 10, j = 20; evaluate(i+j); } void evaluate(int x) { print(x); x = 2 * 10; // in this I think call-by-name give lvalue error. print(x); } I think call-by-reference will also give an error, ... -reference needs an address to point. Evaluate the result using 1. call-by-reference 2. call-by-name 3. call-by-need 4. call-by-value.
void main() { int i = 10, j = 20; evaluate(i+j); } void evaluate(int x) { print(x); x = 2 * 10; // in this I think call-by-name give lvalue error. print(x); }I think call...
Shubhanshu
2.1k
views
Shubhanshu
asked
Nov 4, 2017
Programming in C
programming-in-c
+
–
2
votes
1
answer
1096
Use of macro instead of function is recommended.
Use of macro instead of function is recommended. (a) when one wants to reduce the execution time (b) when there is a loop with a function call inside (c) when a function is called in many places in a program (d) In (a) and (b) above Can some one explain how option 'b' is true?
Use of macro instead of function is recommended.(a) when one wants to reduce the execution time(b) when there is a loop with a function call inside(c) when a function is ...
sunil sarode
3.4k
views
sunil sarode
asked
Nov 4, 2017
Programming in C
programming-in-c
macros
functions
+
–
3
votes
2
answers
1097
scope of a macro definition
Choose the False statements: (a) The scope of a macro definition need not be the entire program (b) The scope of a macro definition extends from the point of definition to the end of the file (c) A macro definition may go beyond a line (d) None of the above
Choose the False statements:(a) The scope of a macro definition need not be the entire program(b) The scope of a macro definition extends from the point of definition to ...
sunil sarode
2.2k
views
sunil sarode
asked
Nov 4, 2017
Programming in C
programming-in-c
scoping-rule
+
–
2
votes
2
answers
1098
Programming2
#include<stdio.h> int fun(int a,int b) { if(b==0) return 0; if(b%2==0) return fun(a+a,b/2); return fun(a+a,b/2)+a; } int main() { printf("%d",fun(9,11)); return 0; }
#include<stdio.h int fun(int a,int b) { if(b==0) return 0; if(b%2==0) return fun(a+a,b/2); return fun(a+a,b/2)+a; } int main() { printf("%d",fun(9,11)); return 0; }
srestha
1.9k
views
srestha
asked
Nov 3, 2017
Programming in C
programming-in-c
+
–
3
votes
0
answers
1099
Programming
What is the function of x and n computed by the below code segment int myprog(int x,int n) { int val=1; if(n>0){ if((n%2)==1) val=val*x; val=val*myprog(x*x,n/2); } return val; } 1) xpow n 2) x*n 3) xpow(n/2) 4) x root n
What is the function of x and n computed by the below code segmentint myprog(int x,int n) { int val=1; if(n>0){ if((n%2)==1) val=val*x; val=val*myprog(x*x,n/2); } return ...
srestha
315
views
srestha
asked
Nov 3, 2017
Programming in C
programming-in-c
+
–
5
votes
2
answers
1100
Time Complexity
Consider the following function Void func(int n){ Int k=n; Int i=0; for(;i<n;i++){ while(k>1){ k>>=1; } } What is the worst case time complexity of the function?
Consider the following functionVoid func(int n){Int k=n;Int i=0;for(;i<n;i++){while(k>1){k>>=1;}}What is the worst case time complexity of the function?
shaurya vardhan
1.7k
views
shaurya vardhan
asked
Nov 2, 2017
Algorithms
time-complexity
algorithms
asymptotic-notation
recursion
programming-in-c
+
–
4
votes
1
answer
1101
Time Complexity
Consider the following code….. Search(int n){ if(n<2) then return; else{ s=0; for(i=1;i<=8;i++){ Search(n/2); } for(i=1;i<n*n;i++){ for(j=1;j<n;j=j*2){ s=s+i; } } } } Assume s is a global variable.Find the complexity of the given Search(n)?
Consider the following code…..Search(int n){if(n<2)then return; else{s=0;for(i=1;i<=8;i++){Search(n/2);}for(i=1;i<n*n;i++){for(j=1;j<n;j=j*2){s=s+i;}}}}Assume s is a gl...
shaurya vardhan
674
views
shaurya vardhan
asked
Nov 2, 2017
Algorithms
time-complexity
algorithms
asymptotic-notation
recursion
programming-in-c
+
–
2
votes
1
answer
1102
C CODING
#include <stdio.h> #include <stdlib.h> int* fun(); int main() { int *a = fun(); printf("%d",*a); return 0; } int* fun() { int *a =(int*) malloc(sizeof(int)); *a = 10; return a; } When it will give memory leak problem .. what should be changes ? pls explain in detail
#include <stdio.h #include <stdlib.h int* fun(); int main() { int *a = fun(); printf("%d",*a); return 0; } int* fun() { int *a =(int*) malloc(sizeof(int)); *a = 10; retur...
sid1221
529
views
sid1221
asked
Nov 2, 2017
Programming in C
programming-in-c
+
–
1
votes
1
answer
1103
Programming
Choose the right option. #define X 8 int main(void) { cout<<++X; return 0; } A) 8 B) 9 C) Garbage Value C) Compile Error
Choose the right option.#define X 8 int main(void) { cout<<++X; return 0; }A) 8 B) 9C) Garbage Value C) Compile Error
Rohit Gupta 8
289
views
Rohit Gupta 8
asked
Nov 1, 2017
Programming in C
programming-in-c
programming
output
+
–
3
votes
1
answer
1104
C PROGRAMMING
OUTPUT OF THE FOLLOWING PROGRAMME #include<stdio.h> int main() { int n1=10; int n2=15; int n3; n3=~n1; printf("%d",n3); return 0; } Basically here i want to understand how do we store negation value and what are the changes done,for a signed and unsigned integers here considering integer is of 4 bytes here.
OUTPUT OF THE FOLLOWING PROGRAMME#include<stdio.h int main() { int n1=10; int n2=15; int n3; n3=~n1; printf("%d",n3); return 0; }Basically here i want to understand how d...
junaid ahmad
451
views
junaid ahmad
asked
Oct 31, 2017
Programming in C
programming-in-c
non-gate
+
–
4
votes
0
answers
1105
C PROGRAMMING
What is the output of the following code snippet char ptr[]="Gateoverflow.in"; char qtr[]="GATE"; int i=0; for(;ptr[i++]=qtr[i++];); printf("%s\n",ptr);
What is the output of the following code snippetchar ptr[]="Gateoverflow.in"; char qtr[]="GATE"; int i=0; for(;ptr[i++]=qtr[i++];); printf("%s\n",ptr);
junaid ahmad
605
views
junaid ahmad
asked
Oct 31, 2017
Programming in C
programming-in-c
+
–
1
votes
2
answers
1106
Programming -3
fun(a,b) { if(a<0 && b<0) return 0; else if(a==0) return b+1; else if(b==0) return fun(a-1,1); else return fun(a-1,fun(a,b-1)); } compute fun(3,1)
fun(a,b) { if(a<0 && b<0) return 0; else if(a==0) return b+1; else if(b==0) return fun(a-1,1); else return fun(a-1,fun(a,b-1)); }compute fun(3,1)
srestha
1.2k
views
srestha
asked
Oct 31, 2017
Programming in C
programming-in-c
programming
+
–
0
votes
0
answers
1107
Program-2
Value of following function when x=3 and y=5 int f(int x, int y) { if(x==0 && y>=0) return y+1; else if(x>0 && y==0) return(x-1,1); else if(x>0 && y>0) return(f(x-1),f(x,y-1)); } value return will be _________________
Value of following function when x=3 and y=5int f(int x, int y) { if(x==0 && y>=0) return y+1; else if(x>0 && y==0) return(x-1,1); else if(x>0 && y>0) return(f(x-1),f(x,y...
srestha
396
views
srestha
asked
Oct 31, 2017
Programming in C
programming-in-c
+
–
0
votes
1
answer
1108
Program
Consider the following function that computes the value of $\binom{m}{n}$ correctly for legal m and n int func(int m,int n) { if(n==0)||(m==n) return 1; else return E; } In the function which is correct expression for E? a)func(m-1,n)+func(m-1,n-1) b)func(m-1,n+1)+func(m-1,n) c)func(m,n)+func(m,n-1) d)None
Consider the following function that computes the value of $\binom{m}{n}$ correctly for legal m and nint func(int m,int n) { if(n==0)||(m==n) return 1; else return E; }In...
srestha
592
views
srestha
asked
Oct 31, 2017
Programming in C
programming-in-c
+
–
0
votes
1
answer
1109
Programming
int main() { int array[] = {3, 5, 1, 4, 6, 2}; int done = 0; int i; while (done == 0) { done = 1; for (i = 0; i <= 4; i++) { if (array[i] = 1; i--) { if (array[i] > array[i-1]) { swap(&array[i], &array[i-1]); done = 0; } } } printf("%d", array[3]); } What does marked part do?
int main() { int array[] = {3, 5, 1, 4, 6, 2}; int done = 0; int i; while (done == 0) { done = 1; for (i = 0; i <= 4; i++) { if (array[i] = 1; i ) { if (array[i] array[i...
Shubham Kumar Gupta
603
views
Shubham Kumar Gupta
asked
Oct 30, 2017
Programming in C
programming-in-c
array
+
–
1
votes
0
answers
1110
Ace Test Series: Programming & DS - Programming In C
What is the output of below code considering the size of short int is 2, char is 1 and int is 4 bytes. #include<stdio.h> main() { short int i = 20; char c = 97; printf("%d, %d, %d \n", sizeof(i), sizeof(c), sizeof(c+i)); return 0; } (a) 2, 1, 2 (b) 2, 1, 1 (c) 2, 1, 4 (d) 2, 2, 8
What is the output of below code considering the size of short int is 2, char is 1 and int is 4 bytes.#include<stdio.h>main(){short int i = 20;char c = 97;printf("%d, %d,...
Aibi
1.6k
views
Aibi
asked
Oct 30, 2017
Programming in C
programming-in-c
programming
pointers
output
ace-test-series
+
–
Page:
« prev
1
...
32
33
34
35
36
37
38
39
40
41
42
...
64
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register