# Accenture C Interview Questions

Study the Following Points:
a.One Cannot Take the address of a Bit Field
b.bit fields cannot be arrayed
c.Bit-Fields are machine Dependant
d.Bit-fields cannot be declared as static

Which of the Following Statements are true w.r.t Bit-Fields
A)a,b&c  B)Only a & b  C)Only c  D)All

2.What is the function of ceil(X) defined in math.h do?
A)It returns the value rounded down to the next lower integer
B)it returns the value rounded up to the next higher integer
C)the Next Higher Value
D)the next lower value 3.When do you say that a digraph is acyclic
A)if and only if its first search does not have back arcs
B)a digraph is acyclic if and only if its first search does not have back vertices
C)if and only if its first search does not have same dfnumber
D)None of these 4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as:
A)int (*q(char*)) []
B)int *q(char*) []
C)int(*q)(char*) []
D)None of the Above 5.What kind of sorting is this:SORT (k,n)
1.[Loop on I Index]
repeat thru step2 for i=1,2,........n-1
2.[For each pass,get small value]
min=i;
repeat for j=i+1 to N do
{
if K[j]<k[min]
min=j;
}
temp=K[i];K[i]=K[min];K[min]=temp;
3.[Sorted Values will be returned]A)Bubble Sort
B)Quick Sort
C)Selection Sort
D)Merge Sort 6.Which of the Following is not defined in string.h?
A)strspn()
B)strerror()
C)memchr()
D)strod() 7.Identify the correct argument for the function call fflush() in ANSI C:
A)stdout
B)stdin
C)stderr
D)All the above 8.Which of the Following will define a type NODE that is a node in a Linked list?
A)struct node {NODE*next;int x;};type def struct node NODE;
B)typedef struct NODE {struct NODE *next;int x;};
C)typedef struct NODE {NODE *next;int x;};
D)typedef struct {NODE *next;int x;}NODE;
9.Which of these statements are false w.r.t File Functions?
i)fputs() ii)fdopen() iii)fgetpos()   iv)ferror()A)ii       B)i,ii         C)iii        D)iv 10.Study the code:
void show()
main()
{
show();
}
void show (char *s)
{
printf("%sn",s);
}What will happen if it is compiled & run on an ANSI C Compiler?
A)It will compile & nothing will be printed when it is executed
B)it will compile but not link
C)the compiler will generate an error
D)the compiler will generate a warning 11.Look at the Code:
#include<string.h>
void main()
{
char s1[]="abcd";
char s2;
char s3[]="efgh";
int i;
clrscr();
i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd"));
printf("%d",i);
} What will be the output?
A)No output   B) A Non Integer  C)0   D) Garbage 12.Look at the Code:
main()
{
int a[]={1,2,3},i;
for(i=0;i<3;i++)
{
printf("%d",*a);
a++;
}
}Which Statement is/are True w.r.t the above code?
I.Executes Successfully & Prints the contents of the array
II.Gives the Error:Lvalue Required
III.The address of the array should not be changed
IV.None of the Above.A)Only I   B)Only II       C)II & III          D)IV 13.what is the output?
#define fun(a,b,t) (g ##t=(a),(a)=(b),(b)=g##t)
float gfloat;
main()
{
float a=1.12,b=3.14;
fun (a,b,float);
printf("na=%4.2f,b=%4.2f",a,b);
}A)Error in Defining Macro
B)a=1.12,b=3.14
C)a=3.14,b=1.12
D)None of teh Above 14.study the code:
#include<stdio.h>
void main()
{
const int a=100;
int *p;
p=&a;
(*p)++;
printf("a=%dn(*p)=%dn",a,*p);
}
What is printed?A)100,101       B)100,100       C)101,101  D)None of the above 15.Which of the following are valid "include" formats?
A)#include and #include[file.h]
B)#include (file.h) and #include
C)#include [file.h] and #include "file.h"
D)#include <file.h> and #include "file.h"

Showing Answers 1 - 11 of 11 Answers

#### Suprim Tiwari

• Jun 10th, 2005

Hi,

Thanks for posting this test. I was wondering in which country did Accenture had this C Test can you please advice me. I am going to have Stage 3 Tech Interview in Australia soon.
Regards
Suprim
SuprimT@yahoo.com

Was this answer useful?  Yes

#### prakash f havargi

• Jul 6th, 2005

hello i am going to face campus interview for next week plz mail me the papers of accenture papers and secret of success to this company

Was this answer useful?  Yes

#### Saru

• Jul 9th, 2005

Hello Prakash, Please find the questions I had used for my interview. Thanks, Saru

Instructions:
1. Please ignore any case-sensitive errors and un-included libraries.
2. You may use the back of this question paper for any rough work.

Q1.
main()

int i;
clrscr();
printf("%d", &i)+1;
scanf("%d", i)-1;

a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above

Ans: d, printf( ) prints address/garbage of i,
scanf() dont hav & sign, so scans address for i
+1, -1 dont hav any effect on code
Q2.
main(int argc, char *argv[])

(main && argc) ? main(argc-1, NULL) : return 0;

a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above

Ans: b) illegal syntax for using return
Q3.
main()

int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("n %d", i);

a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above

Ans: d) 0
Q4.
main()

int i = 0xff ;
printf("n%d", i<<2);

a. 4
b. 512
c. 1020
d. 1024

Ans: c) 1020

Q5.
#define SQR(x) x * x
main()

printf("%d", 225/SQR(15));

a. 1
b. 225
c. 15
d. none of the above

Ans: b) 225
Q6.
union u

struct st

int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()

u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);

a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0

Ans: c) 100, 4, 0
Q7.
union u

union u

int i;
int j;
}a;
int b;
}u;
main()

printf("n%d", sizeof(u));
printf(" %d", sizeof(u.a));
// printf("%d", sizeof(u.a.i));

a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4

Ans: 20, 200, error for 3rd printf
Q8.
main()

int (*functable)(char *format, ...) ={printf, scanf};
int i = 100;
(*functable)("%d", i);
(*functable)("%d", i);
(*functable)("%d", i);
(*functable)("%d", &i);

a. 100, Runtime error.
b. 100, Random number, Random number, Random number.
c. Compile error
d. 100, Random number

Q9.
main()

int i, j, *p;
i = 25;
j = 100;
p = &i; // Address of i is assigned to pointer p
printf("%f", i/(*p) ); // i is divided by pointer p

a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000

Ans: c) Error becoz i/(*p) is 25/25 i.e 1 which is int & printed as a float,
So abnormal program termination,
runs if (float) i/(*p) -----> Type Casting
Q10.
main()

int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);

a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user

Ans: d) two values entered, 3rd will be null pointer assignment
Q11.
main()

char *p = "hello world";
p = 'H';
printf("%s", p);

a. Runtime error.
b. ?Hello world?
c. Compile error
d. ?hello world?

Ans: b) Hello world
Q12.
main()

char * strA;
char * strB = I am OK;
memcpy( strA, strB, 6);

a. Runtime error.
b. I am OK
c. Compile error
d. I am O

Ans: c) I am OK is not in " "

Q13. How will you print % character?
a. printf(?%?)
b. printf(?%?)
c. printf(?%%?)
d. printf(?%%?)

Ans: c) printf(" %% ");
Q14.
const int perplexed = 2;
#define perplexed 3
main()

#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf("%d",perplexed);

a. 0
b. 2
c. 4
d. none of the above

Ans: c)
Q15.
struct Foo

char *pName;
};
main()

struct Foo *obj = malloc(sizeof(struct Foo));
clrscr();
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);

a. Your Name
b. compile error
c. Name
d. Runtime error

Ans a)
Q16.
struct Foo

char *pName;
char *pAddress;
};
main()

struct Foo *obj = malloc(sizeof(struct Foo));
clrscr();
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);

a. Your Name, Your Address
b. Your Address, Your Address
c. Your Name Your Name
d. None of the above

Ans: d) printd Nothing, as after free(obj), no memory is there containing
obj->pName & pbj->pAddress
Q17.
main()

char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcat(a,b));

a. Hello
b. Hello World
c. HelloWorld
d. None of the above

Ans: b)
Q18.
main()

char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcpy(a,b));

a. ?Hello?
b. ?Hello World?
c. ?HelloWorld?
d. None of the above

Ans: d) World, copies World on a, overwrites Hello in a.
Q19.
void func1(int (*a))

printf("Ok it works");

void func2(int a[])

printf("Will this work?");

main()
{
int a;
func1(a);
func2(a);

a. Ok it works
b. Will this work?
c. Ok it worksWill this work?
d. None of the above

Ans: c)
Q20.
main()

printf("%d, %d", sizeof('c'), sizeof(100));

a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4

Ans: a) 2, 2
Q21.
main()

int i = 100;
clrscr();
printf("%d", sizeof(sizeof(i)));

a. 2
b. 100
c. 4
d. none of the above

Ans: a) 2
Q22.
main()

int c = 5;
printf("%d", main||c);

a. 1
b. 5
c. 0
d. none of the above

Ans: a) 1, if we use main|c then error, illegal use of pointer

Q23.
main()

char c;
int i = 456;
clrscr();
c = i;
printf("%d", c);

a. 456
b. -456
c. random number
d. none of the above

Ans: d) -56
Q24.
void main ()

int x = 10;
printf ("x = %d, y = %d", x,--x++);

a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above

Ans: d) Lvalue required
Q25.
main()

int i =10, j = 20;
clrscr();
printf("%d, %d, ", j-- , --i);
printf("%d, %d ", j++ , ++i);

a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10

Ans: c)
Q26.
main()

int x=5;
clrscr();
for(;x==0;x--) {
printf("x=%dn?", x--);

a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above

Ans: d) prints nothing, as condition x==0 is False
Q27
main()

int x=5;
for(;x!=0;x--) {
printf("x=%dn", x--);

a. 5, 4, 3, 2,1
b. 4, 3, 2, 1, 0
c. 5, 3, 1
d. none of the above

Ans: d) Infinite loop as x is decremented twice, it never be 0
and loop is going on & on

Q28
main()

int x=5;
clrscr();
for(;x<= 0;x--)

printf("x=%d ", x--);

a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. ?3, -1, 1, 3, 5

Ans: prints nothing, as condition in loop is false.
Q29.
main()

unsigned int bit=256;
printf("%d", bit);

unsigned int bit=512;
printf("%d", bit);

a. 256, 256
b. 512, 512
c. 256, 512
d. Compile error

Ans: 256, 512, becoz these r different blocks, so declaration allowed
Q30.
main()

int i;
clrscr();
for(i=0;i<5;i++)

printf("%dn", 1L << i);

a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16

Ans: d) L does't make any diff.
Q31.
main()

signed int bit=512, i=5;
for(;i;i--)

printf("%dn", bit = (bit >> (i - (i -1))));

a. 512, 256, 128, 64, 32
b. 256, 128, 64, 32, 16
c. 128, 64, 32, 16, 8
d. 64, 32, 16, 8, 4

Ans: b)
Q32.
main()

signed int bit=512, i=5;
for(;i;i--)

printf("%dn", bit >> (i - (i -1)));

a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256

Ans: d) bit's value is not changed
Q33.
main()

if (!(1&&0))

printf("OK I am done.");

else

printf("OK I am gone.");

a. OK I am done
b. OK I am gone
c. compile error
d. none of the above

Ans: a)
Q34
main()

if ((1||0) && (0||1))

printf("OK I am done.");

else

printf("OK I am gone.");

a. OK I am done
b. OK I am gone
c. compile error
d. none of the above

Ans: a)
Q35
main()

signed int bit=512, mBit;

mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);

a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513

Ans: d)

Was this answer useful?  Yes

#### gaurav aggarwal

• Aug 22nd, 2005

Hello ,
It was nice to have the C questions ,could any one send me the C++ Questions too,
Accenture is coming in our campus next week.
gaurav
gaurav_aggarwal83@yahoo.com

Was this answer useful?  Yes

#### vivek mehta

• Jun 27th, 2006

hello friends

i am having campus placement tomm

so anybody can plz send me all the papers related to accenture

i cant find it anywhere

plz it is urgent

Was this answer useful?  Yes

#### divya

• Dec 22nd, 2006

Q2-a

Q4-d

@7-d

Q8-c

Q10-c

Q11-c (but it shd contain , before strcat)

Q12-c

Q13-a

Q14-c

Was this answer useful?  Yes

#### thiyagu7arun Profile Answers by thiyagu7arun

• Dec 8th, 2009

1) a 2) b 3) a 4) c 5) c 6) c 7) b 8) d 9) a 10) c 11) d 12) c 13)c 14) a 15) d

Was this answer useful?  Yes

#### kiran AN Profile Answers by kiran AN

• Feb 16th, 2010

void show()
main()
{
show();
}
void show (char *s)
{
printf("%sn",s);
}

when compiled and run it generates linker error

Was this answer useful?  Yes

#### kiran AN Profile Answers by kiran AN

• Feb 16th, 2010

#include<stdio.h>
void main()
{
const int a=100;
int *p;
p=&a;
(*p)++;
printf("a=%dn(*p)=%dn",a,*p);
}
What is printed?
A)100,101       B)100,100       C)101,101  D)None of the above

answer A)100,101
actually in the program we have to typecast &a to (int *) while assigning it to pointer p
(*p)++ increments the value at address stored in p

Was this answer useful?  Yes

#### prititripathi Profile Answers by prititripathi

• Oct 29th, 2010

q-15 ans is d
#include<file.h> or #include "file.h"

Was this answer useful?  Yes

#### prititripathi Profile Answers by prititripathi

• Oct 29th, 2010

q-5 ans is selection sort

Was this answer useful?  Yes

### Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.  