Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Webpage
Programming in C.
Recursion.
Filter
Recent
Hot!
Most votes
Most answers
Most views
Previous GATE
Featured
Highest voted questions in Programming and DS
1
votes
0
answers
2671
pointer question
int main() { int i = 10; int *p = &i; foo(&p); printf("%d ", *p); printf("%d ", *p); } void foo(int **const p) { int j = 11; *p = &j; printf("%d ", **p); } Output is 11 11 undefined value How?
int main(){ int i = 10; int *p = &i; foo(&p); printf("%d ", *p); printf("%d ", *p);}void foo(int const p){ int j = 11; *p = &j; printf("%d ", p);}Output is...
Aakash1125
2.3k
views
Aakash1125
asked
Apr 18, 2017
1
votes
1
answer
2672
C PROGRAMMING
Pick the best statement for the below program: #include "stdio.h" int main() { struct { int a[2], b; } arr[] = {[0].a = {1}, [1].a = {2}, [0].b = 1, [1].b = 2}; printf("%d %d %d and",arr[0].a[0],arr[0].a[1], ... . D No compile error and two elements of arr[] would be defined and initialized. Output would be 1 X 1 and 2 X 2 where X is some garbage random number.
Pick the best statement for the below program:#include "stdio.h" int main() { struct { int a , b; } arr[] = {[0].a = {1}, .a = {2}, [0].b = 1, .b = 2}; printf("%d %d %d...
sushmita
1.1k
views
sushmita
asked
Apr 15, 2017
Programming in C
programming-in-c
output
+
–
1
votes
3
answers
2673
C programming
void main() { unsigned char var=0; for(var=0;var<=255;var++) { printf("%d ",var); } } What is output of this code?
void main() { unsigned char var=0; for(var=0;var<=255;var++) { printf("%d ",var); } }What is output of this code?
anonymous
3.2k
views
anonymous
asked
Apr 14, 2017
Programming in C
programming-in-c
+
–
1
votes
2
answers
2674
c pointers
main() { char *p1="name"; char *p2; p2=(char*)malloc(20); memset(p2,0,20); while(*p2++=*p1++); printf("%s\n",p2); }
main() { char *p1="name"; char *p2; p2=(char*)malloc(20); memset(p2,0,20); while(*p2++=*p1++); printf("%s\n",p2); }
akankshadewangan24
1.5k
views
akankshadewangan24
asked
Apr 14, 2017
1
votes
1
answer
2675
C-Output
what is the output of the following program ??
what is the output of the following program ??
papesh
560
views
papesh
asked
Apr 12, 2017
1
votes
2
answers
2676
Dynamic declaration of 2D array
Dynamic declaration of 2D array int **arr=(int**) malloc(r* sizeof(int*)); for(i=0; i<r; i++) arr[i]=(int*) malloc(c* sizeof(int)); can anyone explain these lines?
Dynamic declaration of 2D arrayint arr=(int ) malloc(r* sizeof(int*));for(i=0; i<r; i++) arr[i]=(int*) malloc(c* sizeof(int));can anyone explain these lines?
shebya nautiyal
1.4k
views
shebya nautiyal
asked
Apr 5, 2017
Programming in C
programming-in-c
+
–
1
votes
1
answer
2677
Programming and time complexity
This is a recursive function to generate all possible n pairs of balanced parentheses for a given value of n<=20. Input: 1 Output: {} Input: 2 Output: {}{} {{}} What is the time complexity of the following code? Also, can it be done using Dynamic ... int main() { int n; scanf("%d", &n); printParenthesis(0, n, 0, 0); getchar(); return 0; }
This is a recursive function to generate all possible n pairs of balanced parentheses for a given value of n<=20. Input: 1 Output: {} Input: 2 Output: {}{} {{}} What is t...
shraddha priya
564
views
shraddha priya
asked
Apr 4, 2017
1
votes
1
answer
2678
c language
#include <stdio.h> int f1() { printf ("Geeks"); return 1;} int f2() { printf ("Quiz"); return 1;} int main() { int p = f1() + f2(); return 0; } (A) GeeksQuiz (B) QuizGeeks (C) Compiler Dependent (D) Compiler Error plz explain i m ... A bcz + is left associative so f1() first execute then f2() will be executed so answer will be A bt they given C why is it so ?
#include <stdio.h int f1() { printf ("Geeks"); return 1;} int f2() { printf ("Quiz"); return 1;} int main() { int p = f1() + f2(); return 0; } (A) GeeksQuiz(B) QuizGe...
rajan
923
views
rajan
asked
Apr 4, 2017
1
votes
5
answers
2679
CIL17
Gate Ranker18
2.5k
views
Gate Ranker18
asked
Apr 2, 2017
1
votes
1
answer
2680
What will be the output of the following C program? If you think it will give a runtime error, you need to mention it.
What will be the output of the following C program? If you think it will give a runtime error, you need to mention it. In either case,your answer must include proper just...
.
1.6k
views
.
asked
Apr 2, 2017
Programming in C
programming-in-c
+
–
1
votes
1
answer
2681
K&R BOOK
I have learnt that order of function call of f1() and f2() is compiler dependent from K&R book.Why precedence and associavity does not work in this case ?? Please clarify in details . #include<stdio.h> int x = 0; int f1() { x = 5; return x; } int f2() { x = 10; return x; } int main() { int p = f1() + f2(); printf("%d ", x); return 0; }
I have learnt that order of function call of f1() and f2() is compiler dependent from K&R book.Why precedence and associavity does not work in this case ?? Please clarify...
Ajitesh Mandal
905
views
Ajitesh Mandal
asked
Apr 2, 2017
Programming in C
programming-in-c
+
–
1
votes
1
answer
2682
Virtual Gate Test Series: Programming & DS - Output Of The Program
What does the following program print? int data[3][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; int main(void) { int r, c; for(r = 0; r < 3; r++) for(c = 0; c < 4; c++) if(r != c) printf("%3d,", *(*(data + c) + r) + 10); return 0; }
What does the following program print?int data[3][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; int main(void) { int r, c; for(r = 0; r < 3; r++) for(c = 0; c < 4; ...
sushmita
408
views
sushmita
asked
Mar 27, 2017
Programming in C
programming-in-c
output
virtual-gate-test-series
+
–
1
votes
1
answer
2683
list type
// Graph class represents a undirected graph // using adjacency list representation class Graph { int V; // No. of vertices // Pointer to an array containing adjacency lists list<int> *adj; } is 'list' a datatype?? where can i study about it??
// Graph class represents a undirected graph// using adjacency list representationclass Graph{ int V; // No. of vertices // Pointer to an array containing adjac...
Akriti sood
438
views
Akriti sood
asked
Mar 24, 2017
Programming in C
programming-in-c
+
–
1
votes
2
answers
2684
C programming doubt
I am getting segmentation fault for the following code.Please help to rectify. #include <stdio.h> #include <stdlib.h> struct person { int age; float weight; char *name; }; int main() { struct person *ptr; int i, num; printf("Enter number of persons: "); ... printf("%s\t%d\t%.2f\n", ptr->name[i], (ptr+i)->age, (ptr+i)->weight); return 0; }
I am getting segmentation fault for the following code.Please help to rectify. #include <stdio.h #include <stdlib.h struct person { int age; float weight; char *name; }; ...
Pranabesh Ghosh 1
1.3k
views
Pranabesh Ghosh 1
asked
Mar 23, 2017
1
votes
1
answer
2685
C Programming(interview)
Write an algorithm of the given problem Given a chess board of order NxM and source points (s1,s2) and destination points (d1,d2), Your task to find min number of moves required by the Knight to go to the destination cell.
Write an algorithm of the given problemGiven a chess board of order NxM and source points (s1,s2) and destination points (d1,d2), Your task to find min number of moves re...
srestha
1.2k
views
srestha
asked
Mar 23, 2017
Programming in C
programming-in-c
+
–
1
votes
2
answers
2686
C Programming (interview)
WAP where smallest subarrays with sum greater than x? Say an array={1,5,6,2,45,17}; Now, x=60 Now we have to find smallest subarray which is greater than x
WAP where smallest subarrays with sum greater than x?Say an array={1,5,6,2,45,17};Now, x=60Now we have to find smallest subarray which is greater than x
srestha
1.3k
views
srestha
asked
Mar 23, 2017
Programming in C
programming-in-c
output
+
–
1
votes
2
answers
2687
full binary tree , complete and almost complete binary tree difference
what is the difference between all these types of trees 1)full binary tree 2) complete binary tree 3) almost complete binary tree 4)perfect binary tree 5)strictly binary tree is every full binary tree is of all types of binary trees
what is the difference between all these types of trees1)full binary tree 2) complete binary tree 3) almost complete binary tree 4)perfect binary tree 5)strictly binary t...
Meenakshi Sharma
4.3k
views
Meenakshi Sharma
asked
Mar 19, 2017
1
votes
2
answers
2688
c programming
#include <stdio.h> int K = 4; int a[2]; unsigned int m; int* check(unsigned int n) { int res = 1; int count = 0; for(int i=0;i<K;i++) if(!(n&(1<<i))) { count++; res = 0; } a[0] = res; a[1] = count; return a; } int foo(unsigned int n,int i) ... ; count += x[1]; foo(m|i,i+1); return count; } int main() { int x = foo(0,0); printf("%d\n",x); } value of x ___ ?
#include <stdio.h int K = 4; int a ; unsigned int m; int* check(unsigned int n) { int res = 1; int count = 0; for(int i=0;i<K;i++) if(!(n&(1<<i))) { count++; res = 0; } a...
dd
606
views
dd
asked
Mar 19, 2017
Programming in C
programming-in-c
+
–
1
votes
1
answer
2689
C++ oops
Can someone explain the difference between abstraction and encapsulation with programming example?
Can someone explain the difference between abstraction and encapsulation with programming example?
Adiaspirant
813
views
Adiaspirant
asked
Mar 18, 2017
1
votes
1
answer
2690
pointer
int main(){ int a[5]={1,2,3,4,5}; char *str="hello"; printf("%p %p",a,&a); printf("%p %p",str,&str); } Why in $1$st printf , both the outputs are same($a$,&$a$) And in $2$nd printf ,both the outputs are different(str,&str) please help!
int main(){ int a[5]={1,2,3,4,5}; char *str="hello"; printf("%p %p",a,&a); printf("%p %p",str,&str); }Why in $1$st printf , both the outputs are same($a$,&$a$)And in $2$n...
Learner_jai
489
views
Learner_jai
asked
Mar 17, 2017
Programming in C
programming-in-c
+
–
Page:
« prev
1
...
129
130
131
132
133
134
135
136
137
138
139
...
310
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register