Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged go-programming-1
8
votes
2
answers
1
GATE Overflow | Programming | Test 1 | Question: 28
int foo(int n) { if(n > 10000) return 1; int sum = 0, i; for( i = 0; i < n; i++) { sum += i; } return sum; } The value returned by the above function is $\Theta\left(n^2\right)$ $\Theta\left(n\right)$ $\Theta\left(1\right)$ $\Omega\left(n^2\right)$
int foo(int n) { if(n 10000) return 1; int sum = 0, i; for( i = 0; i < n; i++) { sum += i; } return sum; }The value returned by the above function is$\Theta\left(n^2\rig...
Arjun
1.3k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
asymptotic-notation
programming-in-c
+
–
5
votes
1
answer
2
GATE Overflow | Programming | Test 1 | Question: 30
Consider the following incomplete C function for reversing a singly linked list. node* reverse(node* trav){ if(trav->next) __________________ else { head -> next = null; head = trav; } return trav; } Here, head is a global pointer pointing to ... = trav; trav->next -> next = trav; trav -> next = trav; trav = reverse(trav->next);
Consider the following incomplete C function for reversing a singly linked list.node* reverse(node* trav){ if(trav->next) __________________ else { head - next = null; he...
Arjun
1.7k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
linked-list
+
–
3
votes
2
answers
3
GATE Overflow | Programming | Test 1 | Question: 29
What will be the output of the following code? #include <stdio.h> #include <string.h> int main() { struct mystruct{ char *name; unsigned int age; }; struct mystruct st1 = {"Ram", 12}; printf("%lu %u", strlen(st1.name), st1.age); } 4 12 3 12 compile error run time error
What will be the output of the following code?#include <stdio.h #include <string.h int main() { struct mystruct{ char *name; unsigned int age; }; struct mystruct st1 = {"...
Arjun
1.1k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
1
votes
3
answers
4
GATE Overflow | Programming | Test 1 | Question: 27
Which of the following statements is true regarding C language? S1: C is a functional language S2: C is a declarative language S3: C is a procedural language S4: C is a structured language S1, S2 and S3 only S2 and S4 only S2, S3 and S4 only S1, S3 and S4 only
Which of the following statements is true regarding C language?S1: C is a functional languageS2: C is a declarative languageS3: C is a procedural languageS4: C is a struc...
Arjun
3.3k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
3
votes
4
answers
5
GATE Overflow | Programming | Test 1 | Question: 26
What will be the output of the following code? #include <stdio.h> int main() { char a = 'A', z = 'Z'; printf("%d", z-a); }
What will be the output of the following code?#include <stdio.h int main() { char a = 'A', z = 'Z'; printf("%d", z-a); }
Arjun
816
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
numerical-answers
+
–
8
votes
1
answer
6
GATE Overflow | Programming | Test 1 | Question: 25
int foo1(float a) { int b = a; return b/2; } int foo2(double a) { int b = a; return b/2; } int foo3(unsigned int a) { int b = a; return b/2; } Consider the above three C functions and choose ... error foo2 and foo3 return the same value for all input integer values but not foo1 All 3 functions return different value for some input integer values
int foo1(float a) { int b = a; return b/2; } int foo2(double a) { int b = a; return b/2; } int foo3(unsigned int a) { int b = a; return b/2; }Consider the above three C f...
Arjun
1.6k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
7
votes
4
answers
7
GATE Overflow | Programming | Test 1 | Question: 24
The output of the following C program will be (assume IEEE-754 floating point representation) #include <stdio.h> int main() { float a = 0.25; if(a == 0.25) printf("Hello"); printf(" World"); } Hello World World Compile Error Hello
The output of the following C program will be (assume IEEE-754 floating point representation)#include <stdio.h int main() { float a = 0.25; if(a == 0.25) printf("Hello");...
Arjun
3.0k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
+
–
7
votes
2
answers
8
GATE Overflow | Programming | Test 1 | Question: 23
The value returned by the following function for foo(10) is ____ int foo(int x) { if(x < 1) return 1; int sum = 0; for(int i = 1; i <= x; i++) { sum += foo(x-i); } return sum; }
The value returned by the following function for foo(10) is ____int foo(int x) { if(x < 1) return 1; int sum = 0; for(int i = 1; i <= x; i++) { sum += foo(x-i); } return ...
Arjun
1.3k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
numerical-answers
+
–
6
votes
4
answers
9
GATE Overflow | Programming | Test 1 | Question: 22
Which one among the following definitions of string str could cause problem when passed as the first argument to printf function? char str[] = "Hello World"; char str[12] = "Hello World"; char *str = " ... ,'l','o',' ','W','o','r','l','d'};
Which one among the following definitions of string str could cause problem when passed as the first argument to printf function?char str[] = "Hello World";char str[12] =...
Arjun
1.8k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
2
votes
5
answers
10
GATE Overflow | Programming | Test 1 | Question: 21
The value returned by the following code is _____ int foo() { int a[] = { 10, 20, 30, 40, 50, 60 }; int *p = &a[1] , *q = &a[5] ; return q-p; }
The value returned by the following code is _____int foo() { int a[] = { 10, 20, 30, 40, 50, 60 }; int *p = &a , *q = &a[5] ; return q-p; }
Arjun
1.6k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
numerical-answers
+
–
9
votes
2
answers
11
GATE Overflow | Programming | Test 1 | Question: 20
Which of the following statements is correct? S1: A struct object will always occupy more space than an union object having the same elements. S2: Given an int array Arr and a struct object Str both having same size in memory, Arr[100] ... size in memory. Only S1 is correct Only S2 is correct Both S1 and S2 are correct Neither S1 nor S2 is correct
Which of the following statements is correct?S1: A struct object will always occupy more space than an union object having the same elements.S2: Given an int array Arr an...
Arjun
2.1k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
3
votes
1
answer
12
GATE Overflow | Programming | Test 1 | Question: 19
Arnold is a novice in C and by mistake he typed "intt" for all usage of "int" in a C code. Which of the following statement added at the beginning of the code should fix the issue for him? typedef int intt; typedef intt int; #define intt int; #define intt int 1 and 3 2 and 4 3 and 4 1 and 4
Arnold is a novice in C and by mistake he typed "intt" for all usage of "int" in a C code. Which of the following statement added at the beginning of the code should fix ...
Arjun
701
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
6
votes
3
answers
13
GATE Overflow | Programming | Test 1 | Question: 18
Consider the following two C codes: Code 1 Code 2 char *a = "hello world"; printf(a); char a[] = "hello world"; printf(a); Both are valid C codes Code 1 is valid but not code 2 Code 2 is valid but not code 1 Both codes are not valid in C
Consider the following two C codes:Code 1Code 2char *a = "hello world"; printf(a);char a[] = "hello world"; printf(a);Both are valid C codesCode 1 is valid but not code 2...
Arjun
1.6k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
12
votes
1
answer
14
GATE Overflow | Programming | Test 1 | Question: 17
#include <stdio.h> int foo(int a[100]) { return sizeof(a); } int main() { int a[10]; printf("%d", foo(a)); } What will be the output of the above code ignoring any compiler warnings and assuming sizeof(int) as 4 when run on a 64 bit machine?
#include <stdio.h int foo(int a[100]) { return sizeof(a); } int main() { int a[10]; printf("%d", foo(a)); }What will be the output of the above code ignoring any compiler...
Arjun
1.9k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
numerical-answers
+
–
3
votes
1
answer
15
GATE Overflow | Programming | Test 1 | Question: 16
What is the number of tokens in the below C code? int foo(int i, int j){ return printf(" I do it correctly", i > j); }
What is the number of tokens in the below C code?int foo(int i, int j){ return printf(" I do it correctly", i j); }
Arjun
945
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
compiler-tokenization
numerical-answers
+
–
11
votes
4
answers
16
GATE Overflow | Programming | Test 1 | Question: 15
Which of the following statements produce a compile time error in C? int a = sizeof 3; *(1000) = 5; int a = 5; ((int)a)++; int b = 5, *a = &b; ((int*)a)++; 1, 2 and 3 2 only 2, 3 and 4 All 4
Which of the following statements produce a compile time error in C?int a = sizeof 3;*(1000) = 5;int a = 5; ((int)a)++;int b = 5, *a = &b; ((int*)a)++;1, 2 and 32 only2, ...
Arjun
2.2k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
6
votes
2
answers
17
GATE Overflow | Programming | Test 1 | Question: 14
void foo(int x) { int *p = &x; *p = x*x; } The above code is supposed to modify any input integer with its square. Which of the following statements regarding the above code is correct? The given code is wrong as ... not returning any value The given code is wrong as it is illegal to access the memory of a parameter variable inside a function
void foo(int x) { int *p = &x; *p = x*x; }The above code is supposed to modify any input integer with its square. Which of the following statements regarding the above co...
Arjun
925
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
parameter-passing
+
–
11
votes
2
answers
18
GATE Overflow | Programming | Test 1 | Question: 13
What is the following function doing? unsigned int foo(unsigned int x) { unsigned int c = sizeof x; c <<= 3; if(x == 0) return c; c--; while(x = x & x-1) c--; return c; } Counting the number ... the number of set bits in the binary representation of x Counting the number of unset bits in the binary representation of x None of the above
What is the following function doing?unsigned int foo(unsigned int x) { unsigned int c = sizeof x; c <<= 3; if(x == 0) return c; c ; while(x = x & x-1) c ; return c; }Cou...
Arjun
1.8k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
identify-function
+
–
5
votes
4
answers
19
GATE Overflow | Programming | Test 1 | Question: 12
What will be returned by the following function foo when called as foo(10)? int foo(int n) { return n & n | 1; }
What will be returned by the following function foo when called as foo(10)?int foo(int n) { return n & n | 1; }
Arjun
1.4k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
numerical-answers
bitwise
+
–
7
votes
2
answers
20
GATE Overflow | Programming | Test 1 | Question: 11
What will be the outout of the following code? #include <stdio.h> int main() { int a = 1, b = 2; int c = a++ || b++; printf("%d %d %d", a, b, c); } 1 2 1 2 3 1 2 2 1 2 2 0
What will be the outout of the following code?#include <stdio.h int main() { int a = 1, b = 2; int c = a++ || b++; printf("%d %d %d", a, b, c); }1 2 12 3 12 2 12 2 0
Arjun
926
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
short-circuit-rule
+
–
4
votes
2
answers
21
GATE Overflow | Programming | Test 1 | Question: 10
What will be the output of the following program? #include <stdio.h> void f1(int p1, int *p2, int **p3) { p1 = 20; *p2 = p1; **p3 = *p2; p1 = 10; } int main() { int a = 5, b = 5, *c = &b; f1(a, &b, &c); printf("%d %d %d", a, b, *c); } 5 5 5 5 20 20 10 20 20 20 20 20
What will be the output of the following program?#include <stdio.h void f1(int p1, int *p2, int p3) { p1 = 20; *p2 = p1; p3 = *p2; p1 = 10; } int main() { int a = 5, b ...
Arjun
819
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
pointers
+
–
3
votes
2
answers
22
GATE Overflow | Programming | Test 1 | Question: 9
No. of times '*' will be printed by the following C code is _____ #include<stdio.h> void foo(int x) { switch(x){ case 1: printf("*"); case 2: printf("*"); case 3: printf("*"); default: printf("*"); } } int main() { foo(2.5); }
No. of times '*' will be printed by the following C code is _____#include<stdio.h void foo(int x) { switch(x){ case 1: printf("*"); case 2: printf("*"); case 3: printf("*...
Arjun
1.2k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
switch-case
numerical-answers
+
–
6
votes
2
answers
23
GATE Overflow | Programming | Test 1 | Question: 8
What is the output of this program? #include <stdio.h> int main() { char *ptr; char string[] = "Hello 2017"; ptr = string; ptr += 4; printf("%s",++ptr); } Hello 2017 ello 2017 2017 o 2017
What is the output of this program?#include <stdio.h int main() { char *ptr; char string[] = "Hello 2017"; ptr = string; ptr += 4; printf("%s",++ptr); }Hello 2017ello 201...
Arjun
663
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
pointers
+
–
9
votes
2
answers
24
GATE Overflow | Programming | Test 1 | Question: 7
The output for the following C program will be #include <stdio.h> int temp; int new(int t) { static int cal; cal = cal + t; return(cal); } int main() { int t, p; for(t=0; t<=4; t++) p = new(t) + ++temp; printf("%d", p); } 25 20 15 Garbage Value
The output for the following C program will be#include <stdio.h int temp; int new(int t) { static int cal; cal = cal + t; return(cal); } int main() { int t, p; for(t=0; t...
Arjun
1.1k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
7
votes
3
answers
25
GATE Overflow | Programming | Test 1 | Question: 6
The output of the following C program will be _____ #include<stdio.h> #define type int type foo(type b) { return b*b; } #undef type #define type float int main() { float a = foo(1.1); printf("%1.2f", a); }
The output of the following C program will be _____#include<stdio.h #define type int type foo(type b) { return b*b; } #undef type #define type float int main() { float a ...
Arjun
1.7k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
data-types
numerical-answers
+
–
10
votes
3
answers
26
GATE Overflow | Programming | Test 1 | Question: 5
Consider the following usage of variable a where b is an appropriate pointer variable. int * b = &a; Which of the following declarations is invalid for a? auto int a; register int a; static int a; const int a; 1 and 2 4 only 2 only 2 and 4
Consider the following usage of variable a where b is an appropriate pointer variable.int * b = &a;Which of the following declarations is invalid for a?auto int a;registe...
Arjun
1.7k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
5
votes
3
answers
27
GATE Overflow | Programming | Test 1 | Question: 4
Consider the following C functions: int f1(int a, int b) { while (a != b) { if(a > b) a = a - b; else b = b - a; } return a; } int f2(int a, int b) { while (b != 0) { int t = b; ... for all positive inputs but not f3 For some positive input all 3 functions return different values f2 and f3 return same value for all positive inputs but not f1
Consider the following C functions:int f1(int a, int b) { while (a != b) { if(a b) a = a - b; else b = b - a; } return a; } int f2(int a, int b) { while (b != 0) { int t...
Arjun
2.5k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
identify-function
+
–
10
votes
7
answers
28
GATE Overflow | Programming | Test 1 | Question: 3
What will be the output of the following code? #include <stdio.h> #include <string.h> int main() { char string[] = "Hello"; if(sizeof(string) <= strlen(string)) printf("1"); printf("0"); } ______
What will be the output of the following code?#include <stdio.h #include <string.h int main() { char string[] = "Hello"; if(sizeof(string) <= strlen(string)) printf("1");...
Arjun
1.9k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming-in-c
programming
numerical-answers
+
–
8
votes
2
answers
29
GATE Overflow | Programming | Test 1 | Question: 2
Consider the following C function: void foo() { int a[10][20][30] = {0}; __________ printf("%d", a[3][4][5]); } Which of the following could be used in the missing line so that the output is 2? a[3][4][5] = 2; *(*(*(a+3) + 4) + 5) = 2; (*(*(a ... *((int*)a + 3 * 20 * 30 + 4 * 30 + 5) = 2; Only 1 and 2 Only 1, 2 and 3 Only 1 1, 2, 3 and 4
Consider the following C function:void foo() { int a[10][20][30] = {0}; __________ printf("%d", a[3][4][5]); }Which of the following could be used in the missing line so ...
Arjun
1.4k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
pointers
+
–
4
votes
2
answers
30
GATE Overflow | Programming | Test 1 | Question: 1
What will be the output of the following C program? #include <stdio.h> int main() { int f1(int,int); int x = 9,n = 3; printf("%d", f1(x, n)); } int f1(int x, int n) { int y = 1,i = 1; for(i = 1;i <= n; i++) y = y * x; return(y); } 27 729 81 Compilation Error
What will be the output of the following C program?#include <stdio.h int main() { int f1(int,int); int x = 9,n = 3; printf("%d", f1(x, n)); } int f1(int x, int n) { int y...
Arjun
1.3k
views
Arjun
asked
Oct 18, 2016
Programming in C
go-programming-1
programming
programming-in-c
+
–
To see more, click for the
full list of questions
or
popular tags
.
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register