Faq-c.com Overview

Share your C knowledge...

"There is no delight in owning anything unshared"

Faq-c.com is a place to share your C knowledge with the world in the form of multiple choice questions and answers with explanations. There is no limit to the number of questions you can submit. However, the submissions will be posted after it has been reviewed by the moderator.


Faq-c Archive 1

submitted by Ranjith Singh [Answer]

FAQ-C. main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}

Answers:

1) Compiler Error

2) mmmm
aaaa
nnnn

3) mmmmaaaannnn

4) manmanmanman

 

submitted by Ranjith Singh [Answer]

FAQ-C. What will be the output of this program?

void main()
{
int const * p=5;
printf("%d",++(*p));
}

1) 6

2) 7

3) Comiler Error: Cannot Modify a Constant Value

4) Linker Error

submitted by Ranjith Singh [Answer]

FAQ-C. What will be the output of the below program?
void main()
{
extern int i;
i=20;
printf("%d",i);
}

1) 20

2) Compile time Error

3) i

4) Linker Error - Undefined Symbol '_i'

submitted by Atul Vohra [Answer]

FAQ-C. What should be the output of the following?

void pascal f(int i,int j,int k)
{
printf(“%d %d %d”,i, j, k);
}
void cdecl f(int i,int j,int k)
{
printf(“%d %d %d”,i, j, k);
}
main()
{
            int i=10;
f(i++,i++,i++);
            printf(\" %d\\n\",i);
i=10;
f(i++,i++,i++);
printf(\" %d\",i);
}


a)10 11 12 13
12 11 10 13

b)10 11 12 13
11 12 10 13

c)10 12 11 13
12 11 10 13

d)10 11 13 12
12 10 11 13

submitted by Atul Vohra [Answer]

FAQ-C. What is the output for the program given below

typedef enum errorType{warning, error, exception,}error;
      main()
    {
        error g1;
        g1=1;
        printf(\"%d\",g1);
      }

a)Compiler error: Multiple declaration for error
b)Garbage error
c)No error
d)0

submitted by Vidyakiran [Answer]

FAQ-C. What is the output of the following?

main()
{
int i;
i = 64/square(4);
printf(\"%d\",i);
}

a) 16
b) 4
c) 64
d) error

submitted by Vidyakiran [Answer]

FAQ-C. What is the output of the following?

main()
{
struct xx
{
      int x=3;
      char name[]=\"hello\";
};
struct xx *s;
printf(\"%d\",s->x);
printf(\"%s\",s->name);
}


a) Compiler Error
b) hello
c) 3
d) 0

submitted by Vidyakiran [Answer]

FAQ-C. What is the output of the following?

main()
{
char s[]={\'a\',\'b\',\'c\',\'\\n\',\'c\',\'\\0\'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf(\"%d\",++*p + ++*str1-32);
}

a) 11
b) 22
c) 77
d) 66

submitted by Vijay Kumar Soni [Answer]

FAQ-C. What is the range of "real constants" in 'C'?

a) -3.8 x 10 38 to 3.8 x 10 38
b) -34E37 to 34E37
c) -6.4 x 10 34 to 6.4 x 10 34
d) -68E33 to 68E33

submitted by Vijay Kumar Soni [Answer]

FAQ-C. How many keywords are there in 'C' ?

a) 24
b) 32
c) 44
d) 52

submitted by Abhinav Asija [Answer]

FAQ-C. What will be the output of the following statement ?

/* /* printf("hello"); */ */

a) hello
b) no output
c) error
d) "hello"

submitted by Arvinder Singh Chawla [Answer]

FAQ-C. What will be the output of the following arithmetic expression ?

5+3*2%10-8*6

a) -37
b) -42
c) -32
d) -28

submitted by Rajiv Gupta [Answer]

FAQ-C. What will be the output of the following statement ?

printf("%i",35,2+8*5%10-2);

a) error
b) 0
c) 35
d) 350

submitted by Abhinav Asija [Answer]

FAQ-C. What will be the output of the following statement ?

int a=10; printf("%d &i",a,10);

a) error
b) 10
c) 10 10
d) none of these

submitted by Abhinav Asija [Answer]

FAQ-C. What will be the output of the following statement ?

printf("%X%x%ci%x",11,10,'s',12);

a) error
b) basc
c) Bas94c
d) none of these

submitted by Nitin Tomar [Answer]

FAQ-C. What will be the output of the following statements ?

int a = printf("00"); printf("%d",a);

a) 0
b) 00
c) 002
d) garbage value

submitted by Ayan Roy [Answer]

FAQ-C. What will be the output of the following statements ?

int a = 3,b = 8; printf("%d", a<=b);

a) error
b) garbage value
c) 3
d) 1

submitted by Taran Singh Matharoo [Answer]

FAQ-C. What will be the output of the following statements ?

int a = 4, b = 7,c; c = a = = b; printf("%i",c);

a) 0
b) error
c) 1
d) garbage value

submitted by Arpit Malhotra  [Answer]

FAQ-C. What will be the output of the following statements ?

int a = 1, b = 2 , c; c = = a = = b; printf("%d",c);

a) 0
b) 1
c) error
d) garbage value

submitted by Rajiv Gupta  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
#include<math.h>
void main()
{ float a = 3.26; printf("%f",ceil(a)); }

a) 4.0
b) 3.0
c) 3.2
d) none of these

submitted by Taran Singh Matharoo  [Answer]

FAQ-C. What will be the output of the following statements ?

int a = 5, b = 2, c = 10, i = a>b<c; printf("%d",i);

a) error
b) 1
c) garbage value
d) 5

submitted by Vijay Kumar Soni  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
int a = 10;
void main()
{ int a = 50; printf("%d",a); }

a) 50
b) error
c) 10
d) garbage value


submitted by Arvinder Singh Chawla  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
void main()
{ extern int x; printf("%d",x); }int x = 10;

a) error
b) 0
c) garbage value
d) 10

submitted by Abhinav Asija  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
void main()
{ struct p
{
int a,c ; float b;
}d = {1};
printf("%d%d%f",d.a,d.c,d.b);
}

a) garbage value
b) 100.0
c) error
d) 000.0

submitted by Arpit Malhotra  [Answer]

FAQ-C. What will be the output of the following statements ?

float *s; printf("%d",sizeof(s));

a) 1
b) 2
c) 4
d) s

submitted by Gautam Sharma  [Answer]

FAQ-C. What will be the output of the following statements ?

int *a; float far *b; char huge*c

printf("%d,%d,%d",sizeof(a),sizeof(b),sizeof(c));

a) 222
b) 444
c) 244
d) 224

submitted by Gautam Sharma  [Answer]

FAQ-C. What will be the output of the following statements ?

float k = 3.84; printf("%d",(int)k);

a) 3.8
b) 3.0
c) 3
d) 4

submitted by Abhinav Asija  [Answer]

FAQ-C. How many times the following program will print "hello" ?

#include<stdio.h>
void main()
{ printf("hello"); main(); }

a) 1
b) 2
c) infinite number of times
d) none of these

submitted by Manish Sharma  [Answer]

FAQ-C. What will be the output of the following statements ?

int x[4] = {1,2,3}; printf("%d %d %D",x[3],x[2],x[1]);

a) 03%D
b) 000
c) 032
d) 321

submitted by Abhinav Asija  [Answer]

FAQ-C. What will be the output of the following statements ?

float c = 1.3; printf("%d%d",sizeof(c),sizeof(1.3));

a) 44
b) 48
c) 42
d) 24

submitted by Manish Sharma  [Answer]

FAQ-C. Which of the following definition is incorrect ?

a) long int;
b) float double;
c) float real;
d) long long;

submitted by Manish Sharma  [Answer]

FAQ-C. Which of them can't be checked in a "switch-case" statement?

a) enum
b) int
c) char
d) float

submitted by Manish Sharma  [Answer]

FAQ-C. What will be the output of the following statement ?

printf( 3 + "goodbye");

a) goodbye
b) odbye
c) bye
d) dbye

submitted by Prabal Pratap  [Answer]

FAQ-C. What will be the output of the following statement ?

printf("hello""""world");

a) error
b) hello""""world
c) hello
d) helloworld

submitted by Mayank Kansal  [Answer]

FAQ-C. What will be the output of the following statements ?

long int a = scanf("%ld%ld",&a,&a); printf("%ld",a);

a) error
b) garbage value
c) 0
d) 2

submitted by Arpit Malhotra  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
void main()
{ int i = 30;
{ int i = 10;
printf("%d",i);
} printf("%d",i);
}

a) error
b) 1010
c) 3030
d) 1030

submitted by Rajiv Gupta  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
void main()
{ int a = 2;
switch(a)
{ case 1:
printf("goodbye"); break;
case 2:
continue;
case 3:
printf("bye");
}
}

a) error
b) goodbye
c) bye
d) byegoodbye


submitted by Mayank Kansal  [Answer]

FAQ-C. What will be the output of the following statements ?

int i = 1,j; j=i--- -2; printf("%d",j);

a) error
b) 2
c) 3
d) -3

submitted by Priyankan Goswami  [Answer]

FAQ-C. What will be the output of following program ?

#include<stdio.h>
main()
{
int x,y = 10;
x = y * NULL;
printf("%d",x);
}

a) error
b) 0
c) 10
d) garbage value

submitted by Priyankan Goswami  [Answer]

FAQ-C. What will be the output of following statements ?

char x[ ] = "hello hi"; printf("%d%d",sizeof(*x),sizeof(x));

a) 88
b) 18
c) 29
d) 19

submitted by Ayan Roy  [Answer]

FAQ-C. What will be the output of the following statements ?

int a[2][2] = { 1,2,3,4 }; int *r,**s; r = &a[0][0]; s = &r;
printf("%d",**s);

a) error
b) 1
c) 2
d) garbage value

submitted by Ayan Roy  [Answer]

FAQ-C. What will be the output of the following statements
?
int a[2][2] = { 3,2,5,4 };
printf("%d",*(*(*(a))));

a) error
b) 3
c) garbage value
d) 2

submitted by Mayank Kansal  [Answer]

FAQ-C. Which of the following are binary operators in C ?

a) !
b) sizeof
c) ~
d) =

submitted by Gautam Sharma  [Answer]

FAQ-C. What will be the output of the following statements ?

int k = 12; k=k--; printf("%d",k);

a) error
b) 11
c) 12
d) garbage value


submitted by Abhinav Asija  [Answer]

FAQ-C. What will be the output of the following statements
?
int a=5,b=6,c=9,d; d=(a<b?(a>c?1:2):(c>b?6:8)); printf("%d",d);

a) 1
b) 2
c) 6
d) 8

submitted by Modassar Aleem  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
#include<math.h>
void main()
{ int a = fmod(5,3); printf("%d",a); }

a) 0
b) 1
c) 2
d) 3

 

submitted by Tamoghna Dasgupta  [Answer]

FAQ-C. Which of the functions is most apt for reading a multi-word ?

a) puts()
b) gets()
c) scanf()
d) vsscanf()

submitted by Tamoghna Dasgupta  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
#include<math.h>
void main()
{
int n; char *str = "324.89";
n = atoi(str); printf("%d",n);
}

a) 300
b) 324
c) 32489
d) 89

submitted by Bidyut Bhowmik   [Answer]

FAQ-C. What will be the output of following program ?

#include<stdio.h>
void main()
{ printf("%d"); }

a) error
b) no output
c) %d
d) 0

submitted by Parthasarathy Muralidharan   [Answer]

FAQ-C. What will be the output of the following statements ?

int i = 3;
printf("%d%d",i,i++);

a) 34
b) 43
c) 44
d) 33

submitted by Prashant Game Patil   [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
void main()
{
int a = 36, b = 9;
printf("%d",a>>a/b-2);
}

a) 9
b) 7
c) 5
d) none of these

submitted by K. Ashwin Kumar  [Answer]

FAQ-C. What will be the output of the following program ?

#include<stdio.h>
int main()
{
printf("%d",main);
return 0;
}

a) exits with stack overflow
b) compile error "variable undeclared"
c) base address of the function main
d) 0

submitted by K. Ashwin Kumar  

FAQ-C. What will be the output of the following program ? [Answer]

#include<stdio.h>
a()
{
printf("Hello World");
}
main()
{
a();
a(1,3);
a(1,2,3,4,5,6);
}

a) Compiler Error ("undefined reference to a")
b) Segmentation Error
c) Hello WorldHello WorldHello World
d) Hello World<garbage value><garbage value>

submitted by Sonam Arora [Answer]

FAQ-C. What will be the output of the following program ?

main()
{
float a=5,b=2;
int c;
c=a%b;
printf(\"%d\",c);
}

a) 2
b) 2.5
c) 2.0
d) Error

submitted by Rimpu Varshney [Answer]

FAQ-C. Will this program run successfully?

//# NO HEADER FILES INCLUDED
void main void()
{
int i = 0;
}

a) Yes
b) No