# Recent questions tagged output 1
The question is based on the following program fragment. f(intY,int x){ int u,j,k; i=0;j=9; do{ k=(i+j)/2; if(Y[k] < x) i=k; else j=k; } while(Y[k]!=x) && (i<j)); if (Y[k]==x) printf( x is in the array. ); else printf( x is not in the array. ); } On which of the following contents of ... $x>2$ $Y$ is $[2\;4\;6\;8\;10\;12\;14\;16\;18\;20]$ and $2<x<20$ and $'x'$ is even
2
What will be the output of following? main() { Static int a = 3; Printf(“%d”,a--); If(a) main(); } $3$ $3\;2\;1$ $3\;3\;3$ Program will fall in continuous loop and print $3$
3
The following program fragment prints int i = 5; do { putchar(i+100); printf(“%d”, i--;) } while(i); i5h4g3f2el 14h3g2f1e0 An error message None of the above
4
The following program fragment prints int i = 5; do { putchar(i+100); printf(“%d”, i--;) } while(i); i5h4g3f2el 14h3g2f1e0 An error message None of the above
5
What will be the output of following? main() { Static int a = 3; Printf(“%d”,a--); If(a) main(); } $3$ $3\;2\;1$ $3\;3\;3$ Program will fall in continuous loop and print $3$
6
The question is based on the following program fragment. f(intY,int x){ int u,j,k; i=0;j=9; do{ k=(i+j)/2; if(Y[k] < x) i=k; else j=k; } while(Y[k]!=x) && (i<j)); if (Y[k]==x) printf( x is in the array. ); else printf( x is not in the array. ); } On which of the following contents of ... $x>2$ $Y$ is $[2\;4\;6\;8\;10\;12\;14\;16\;18\;20]$ and $2<x<20$ and $'x'$ is even
7
#include int main( ) { int x=5, y=9; x=(x= x+y)-(y= x-y); printf("%d %d ", x, y); return 0; } A. 9 5 B. 5 14 C. 14 5 D. 5 9
8
#include<stdio.h> #include<stdlib.h> int main(void) { int maxLineCount = 500, maxCharCount = 500, index, j, count; char *line = NULL; size_t size; char *a[maxLineCount]; for (index = 0; index < maxLineCount; index++) a[index] = (char *)malloc(maxCharCount * ... of the code is doing. suppose we have 3 string given as input in 3 different lines then how can we access each character of the string?
9
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 *) short int a = 101; char ... *fptr)(&a,arr); printf("%d", arr); return 0; } $A)$ Compilation error. $B) 100$ $C)$ Garbage Value $D)$ Segmentation Fault. $E) 0$
10
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; }
11
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
12
#include <stdio.h> #include<stdlib.h> int main() { //code char *ptr,s[]="debasree"; ptr=s; printf("%s\n",*ptr); return 0; } I get this warning in geeks for geeks compiler Warnings: prog.c: In function 'main': prog.c:7:6: warning: assignment ... Segmentation Fault (SIGSEGV) can anyone pls explain what is the warning saying? i googled a lot but could not grasp it pls pls pls pls explain...
13
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;
14
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, const double*B, int total_size ... (ndim, B_trans, B, r_dim, r_perm); transpose_equal(A, B, total); free(A); free(B); free(B_trans); printf("\n"); } }
1 vote
15
In the above 4 Statements which would print 123 as output ? Explain also.
16
void print(int i){ static int x=4; if(i!=0){ print(--x); } printf("%d",x); } What will be output printed for print(10)? Will it print value as call by value or call by reference?
17
What will be the final output : #include <stdio.h> int r(){ static int num=7; return num--; } int main(){ for(r();r();r()) { printf("%d ",r()); } return 0; } A)63 B)41 C)52 D)630
18
when i printing x it is giving 0 but when comparing x with 5 ,it executing else part ,means condition fail ,why ?? #include <stdio.h> int main(void) { int x; if(x=(printf("Hello")) != 5) printf("Hello"); else printf("World \n"); printf("%d \n",x); return 0; } https://ideone.com/NJSj2i
19
int main() { int a=2,b=2,c=2; printf("%d",a==b==c); return 0; } what is the output??? and what will be done during execution can anyone explain this……...
20
#include<stdio.h> int main() { FILE *fp; if((fp=fp=fopen("test.txt","w"))!=NULL) //test.txt file should be empty during first compiling { fputs("one",fp); fclose(fp); fputs("two",fp); fclose(fp); } return 0; } what will be printed ... and also am not understanding what is done after fputs("one",fp); and fputs("two",fp); can anyone tell me with explanation...please .
21
#include <stdio.h> int arr[] = { 10, 20, 30, 40, 50 }; static int count ; inc() { return ++count; } int main() { arr[count++]=inc(); printf("%d ", arr[count]); printf("%d ", arr); } https://ideone.com/5LOuqj
22
is *ptr=&a is true in C i found this in can anyone explain what does *ptr = &i; in the above picture
23
#include<stdio.h> #include<string.h> int main() { char fullname[]="abcd"; char firstname[]="xxxxx"; //char lastName[]='Nagula'; printf("enter number\n"); printf("Press 1 for fullname\n"); printf("Press 2 for firstname\n"); printf("Press 3 for lastname\n"); int ... output it is giving error :invalid initialiser in line char name[]= ( a==1 ? fullname : firstname); how to correct it. thank you..!
24
#include<stdio.h> #define A -B #define B -C #define C 5 int main() { printf("The value of A is %dn", A); return 0; } what is the output?????
25
main() { unsigned int i= 255; char *p= &i; int j= *p; printf("%d\n", j); unsigned int k= *p; printf("%d", k); } Both the outputs are -1. I have even tried with - int i = 255(3rd line). Still the output is -1. I don't understand how it is -1.
1 vote
26
#include <stdio.h> main (){ unsigned x = -10; int X = 20; if (X > x) printf ("Hello"); else{ printf ("%d",x); printf ("Jello"); } }
27
#include<stdio.h> void main(){ int p=-8; int i= (p++,++p); printf("%d\n",i); }