Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged programming-in-c
4
votes
3
answers
511
Made Easy Test Series:Programming(FLT4)
#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 ___________
#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(...
srestha
1.0k
views
srestha
asked
May 20, 2019
Programming in C
made-easy-test-series
programming
programming-in-c
+
–
2
votes
1
answer
512
Made Easy Test Series:Programming in C
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 ... $a\geq c, B2:kickstart\left ( b,c,a \right );$ Is it $I) and II)$ or $I) and IV)$
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) r...
srestha
1.0k
views
srestha
asked
May 19, 2019
Programming in C
made-easy-test-series
programming
programming-in-c
+
–
1
votes
1
answer
513
Self doubt Data structures
Implement Linked list using stack.
Implement Linked list using stack.
shraddha priya
1.1k
views
shraddha priya
asked
May 19, 2019
Programming in C
programming-in-c
+
–
0
votes
1
answer
514
Gradeup - Programming in C
What will be the output of the below code? the answer given is E)0 but I am not getting it. #include <stdio.h> void fun(short int *a,char *b) { b += 2; short int *p = (short int*)b; *p = *a; } int main() { void (*fptr)(short int *,char ... printf("%d", arr[3]); return 0; } $A)$ Compilation error. $B) 100$ $C)$ Garbage Value $D)$ Segmentation Fault. $E) 0$
What will be the output of the below code? the answer given is E)0 but I am not getting it. #include <stdio.h void fun(short int *a,char *b) { b += 2; short int *...
Aishvarya Akshaya Vi
1.2k
views
Aishvarya Akshaya Vi
asked
May 18, 2019
Programming in C
programming-in-c
output
gradeup
+
–
2
votes
2
answers
515
Self Doubt-Programming
Can someone explain the output of this code? and what (char*) is doing actually? #include<stdio.h> struct Ournode{ char x, y, z; }; int main() { struct Ournode p={'1', '0', 'a'+2}; struct Ournode *q=&p; printf("%c, %c", '*((char*)q+1)', '*((char*)q+2)'); return 0; }
Can someone explain the output of this code? and what (char*) is doing actually?#include<stdio.h struct Ournode{ char x, y, z; }; int main() { struct Ournode p={'1', '0',...
srestha
972
views
srestha
asked
May 13, 2019
Programming in C
programming-in-c
output
self-doubt
+
–
2
votes
2
answers
516
Made Easy Test Series:Programming Test
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 ... $1$ or $2?$
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 r...
srestha
1.1k
views
srestha
asked
May 12, 2019
Programming in C
made-easy-test-series
programming
programming-in-c
+
–
1
votes
0
answers
517
Made Easy Test Series : Programming Test4
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 ... elements, then what output will print at last? I mostly stuck how bool function working here. Plz help me out, how program executing:(
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...
srestha
977
views
srestha
asked
May 10, 2019
Programming in C
made-easy-test-series
programming
programming-in-c
+
–
1
votes
0
answers
518
Made Easy Test Series:Programming Test4-Function Call
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= ... call $fun\left ( a,16,8 \right )=$_______________ Given ans $6,$ but I got $4.$ Which one correct?? Any shortcut to evaluate??
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=...
srestha
908
views
srestha
asked
May 8, 2019
Programming in C
made-easy-test-series
programming
programming-in-c
+
–
1
votes
1
answer
519
Can anyone please explain this question step by step
#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; }
#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...
kaveeshnyk
1.1k
views
kaveeshnyk
asked
May 7, 2019
Programming in C
programming-in-c
pointers
array-of-pointers
programming
+
–
0
votes
1
answer
520
Self-Doubt:Program
Can someone tell me, why these two same program giving different output?Is there any problem in code or compiler not producing right? Program1 Program2
Can someone tell me, why these two same program giving different output?Is there any problem in code or compiler not producing right?Program1Program2
srestha
458
views
srestha
asked
May 6, 2019
Programming in C
programming-in-c
output
+
–
1
votes
1
answer
521
Array of Pointers-Self Doubt
$1)$ How to access array element with array of pointers? By pointer to an array we can access like this $(*a)[0]$,$(*a)[22]$, .. like this right? but how with array of pointer? $2)$Check these three codes , one of them use array and one of them use ... main(void) { if(*(ptr+5)==*(ptr+3)){ printf("Equal"); } else{ printf("Not Equal"); } return 0; }
$1)$ How to access array element with array of pointers? By pointer to an array we can access like this $(*a)[0]$,$(*a)[22]$,….. like thisright?but how with array of po...
srestha
836
views
srestha
asked
May 5, 2019
Programming in C
pointers
programming-in-c
+
–
3
votes
3
answers
522
Made Easy Test Series:Programming-String
#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.
#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; }An...
srestha
1.6k
views
srestha
asked
May 4, 2019
Programming in C
made-easy-test-series
programming
programming-in-c
+
–
0
votes
1
answer
523
Doubt on Program:Self Doubt
#include <stdio.h> int main(void) { int s[6]={128,256,512,1024,2048,4096}; int *x=(int*)(&s+1); printf("%d",x); return 0; } #include <stdio.h> int main(void) { int s[6]={128,256,512,1024,2048,4096}; int *x=(int*)(&s+1); printf("%u",x); return 0; } Why both are printing different address? Is it not a fixed address of memory??
#include <stdio.h int main(void) { int s[6]={128,256,512,1024,2048,4096}; int *x=(int*)(&s+1); printf("%d",x); return 0; }#include <stdio.h int main(void) { int s[6]={128...
srestha
439
views
srestha
asked
May 4, 2019
Programming in C
programming-in-c
+
–
2
votes
0
answers
524
Made Easy Test Series:Programming-Function Call
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?$ .
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=10...
srestha
682
views
srestha
asked
May 4, 2019
Programming in C
made-easy-test-series
programming
programming-in-c
+
–
0
votes
2
answers
525
Made Easy Test Series: Programming
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 ... at P',So that code will work fine? $A)$array[i]!=0 && i<=n $B)$ array[i]!=0 && i<n
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 ...
srestha
648
views
srestha
asked
Apr 24, 2019
Programming in C
made-easy-test-series
programming-in-c
programming
+
–
2
votes
4
answers
526
Made Easy Test Series:Programming and DS
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?
Which of the following data structure is efficient to implement priority queue such as insertion ,deletion, searching?A)Linked ListB)HeapC)Sorted ArrayD)Unsorted ArrayHow...
srestha
3.8k
views
srestha
asked
Apr 24, 2019
DS
made-easy-test-series
programming-in-c
programming
+
–
0
votes
1
answer
527
Self doubt - Programming
X=2; Y=++x * ++x * ++x ; Printf("%d",Y); In the above question, we have to use the final value of x or it will be evaluated seperately and then multiplied. Ex: Y= 3*4*5; or Y=5*5*5;
X=2;Y=++x * ++x * ++x ;Printf("%d",Y);In the above question, we have to use the final value of x or it will be evaluated seperately and then multiplied.Ex: Y= 3*4*5; or Y...
Ashish Roy 1
607
views
Ashish Roy 1
asked
Apr 11, 2019
Programming in C
self-doubt
programming-in-c
output
+
–
0
votes
0
answers
528
GATE 1999
Consider the following C function definition: int trial (int a,int b,int c) { if ((a>=b) && (c<b)) return b; else if (a>=b) return Trial(a,c,b); else return Trial(b,a,c); } The function Trial : A) Finds the maximum of a,b,c B) Finds the minimum of a,b,c C)Finds the middle number of a,b,c D) None of these
Consider the following C function definition:int trial (int a,int b,int c) {if ((a>=b) && (c<b)) return b;else if (a>=b) return Trial(a,c,b);else return Trial(b,a,c);} Th...
Aishvarya Akshaya Vi
343
views
Aishvarya Akshaya Vi
asked
Apr 10, 2019
Programming in C
programming-in-c
+
–
1
votes
1
answer
529
ISI2017-PCB-CS-2(b)
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".$
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...
akash.dinkar12
510
views
akash.dinkar12
asked
Apr 8, 2019
Programming in C
isi2017-pcb-cs
programming
programming-in-c
descriptive
+
–
0
votes
2
answers
530
#arrays
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 ... i=0;i<20;i++) { a[i]=i+1; } for(i=0;i<20;i++) { printf("%d\n",a[i]); } }
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...
shiva0
700
views
shiva0
asked
Apr 7, 2019
Programming in C
programming-in-c
programming
array
memory-management
+
–
0
votes
1
answer
531
#Dynamic memory allocation malloc
how to know how much size is allocated while dynamically allocating memory to the pointer variable with malloc. i just write the below code to know the size of ptr2 after dynamically allocating memory. i want the output is 10 but it is displaying as 2 as ... allocation failed"); else{ printf("size of *ptr2 is == %d\n",(sizeof(ptr2)/sizeof(int))); } }
how to know how much size is allocated while dynamically allocating memory to the pointer variable with malloc.i just write the below code to know the size of ptr2 after ...
shiva0
682
views
shiva0
asked
Apr 6, 2019
Programming in C
programming-in-c
memory-management
+
–
1
votes
3
answers
532
#userdefined Data type union in C
What is the output of the program? int main() { union a { int i; char ch[2]; }; union a u; u.ch[0] = 3; u.ch[1] = 2; printf("%d, %d, %d", u.ch[0], u.ch[1], u.i); return 0; }
What is the output of the program? int main() { union a { int i; char ch ; }; union a u; u.ch[0] = 3; u.ch = 2; printf("%d, %d, %d", u.ch[0], u.ch , u.i); return 0; }
shiva0
472
views
shiva0
asked
Apr 3, 2019
Programming in C
programming-in-c
datatype
+
–
0
votes
0
answers
533
Programming:Self Doubt
Can somebody explain this code line by line. I am unable to get and what will be it's output? #include<stdio.h> #include<stdlib.h> void transpose(int n, const double *A, double *B, const int *lda, int *perm) { } int transpose_equal(const double *A, ... , B, r_dim, r_perm); transpose_equal(A, B, total); free(A); free(B); free(B_trans); printf("\n"); } }
Can somebody explain this code line by line. I am unable to getand what will be it’s output?#include<stdio.h #include<stdlib.h void transpose(int n, const double *A, do...
srestha
507
views
srestha
asked
Apr 3, 2019
Programming in C
programming-in-c
output
+
–
1
votes
1
answer
534
Self Doubt
1. #include <stdio.h> int main() { int i; char a[] = ""; // no tab space in between if(printf("%s",a)) printf("string empty"); else printf("string is not empty"); return 0; } Output: string is not empty 2. ... ;,a)) printf("string empty"); else printf("string is not empty"); return 0; } Output: string empty Why and how so?
1.#include <stdio.h>int main() { int i; char a[] = ""; // no tab space in between if(printf("%s",a)) printf("string empty"); else printf("string is ...
Reshu $ingh
315
views
Reshu $ingh
asked
Apr 1, 2019
Programming in C
programming-in-c
+
–
1
votes
2
answers
535
Made Easy Workbook
#include <stdio.h> int main() { int i = 258; int *iptr = &i; printf("%d",*(char*)iptr); printf("%d",*(char*)iptr+1); } Please explain the solution.
#include <stdio.h>int main() { int i = 258;int *iptr = &i;printf("%d",*(char*)iptr);printf("%d",*(char*)iptr+1); }Please explain the solution.
Reshu $ingh
704
views
Reshu $ingh
asked
Mar 31, 2019
Programming in C
programming-in-c
+
–
0
votes
0
answers
536
Allen Career Institute:Programming
Do something (x, n) { m = n, temp = 1, z = x ; while (m > 0) do { while ((m mod z) == 0) do { m = |m/2|; z = z^{2} ; } m = m – 1; } return temp ; } Complexity of the above problem $1)\Theta \left ( log n \right )$ $2)\Theta \left ( nlog n \right )$ $3)\Theta \left (n^{2} \right )$ $4)\Theta \left (n\right )$
Do something (x, n) { m = n, temp = 1, z = x ; while (m 0) do { while ((m mod z) == 0) do { m = |m/2|; z = z^{2} ; } m = m – 1; } return temp ; }Complexity of the abov...
srestha
469
views
srestha
asked
Mar 28, 2019
Programming in C
programming-in-c
+
–
1
votes
2
answers
537
Pointer question-C
Anyone kindly tell the reason why the outputs are differ ? #include<stdio.h> int main() { char *ptr = "geeksforgeeks"; printf("%c\n", *&*&*ptr); getchar(); return 0; } Output-g #include<stdio.h> int main() { char *ptr = "geeksforgeeks"; printf("%s\n", *&*&ptr); getchar(); return 0; } Output-geeksforgeeks
Anyone kindly tell the reason why the outputs are differ ?#include<stdio.h>int main(){ char *ptr = "geeksforgeeks"; printf("%c\n", *&*&*ptr); getchar(); return 0;}Outp...
val_pro20
1.5k
views
val_pro20
asked
Mar 24, 2019
Programming in C
programming-in-c
pointers
+
–
1
votes
1
answer
538
Self Doubt on scoping
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 ... 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$?
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); } v...
srestha
460
views
srestha
asked
Mar 23, 2019
Programming in C
programming-in-c
dynamic-scoping
parameter-passing
+
–
0
votes
1
answer
539
self doubt variable scope
#include <stdio.h> /* global variable declaration */ int g = 20; int main () { /* local variable declaration */ int g ; printf ("value of g = %d\n", g); return 0; } why this printing value of g is 0 instead of garbage because g is declared which is local variable in main function. are variables inside main function by default global?
#include <stdio.h /* global variable declaration */ int g = 20; int main () { /* local variable declaration */ int g ; printf ("value of g = %d\n", g); return 0; }why thi...
Ram Swaroop
418
views
Ram Swaroop
asked
Mar 17, 2019
Programming in C
programming-in-c
+
–
1
votes
0
answers
540
Geeks for Geeks : C Program
In the above 4 Statements which would print 123 as output ? Explain also.
In the above 4 Statements which would print 123 as output ? Explain also.
Ashish Roy 1
1.7k
views
Ashish Roy 1
asked
Mar 16, 2019
Programming in C
programming-in-c
output
pointers
programming
+
–
Page:
« prev
1
...
13
14
15
16
17
18
19
20
21
22
23
...
64
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register