C programming language questions and answer for GATE CSE - Practice SET1

c programming test questions and answers, c programming test questions and answers,c aptitude questions with answers

C- Programming Practice Questions for GATE Computer Science

Hello friends today in this c programming language based  post we are going to practice some c aptitude questions with answers.

1. Consider the following program

main ( )
int i = 5;
if (i = = 5) return;
else printf “i is not five”);
printf (“over”);

results in

(a) a syntax error (b) an execution error
(c) printing of over (d) printing anything

Solution: Option (d)

2. The following statements

for (i = 3; i < 15; i +=3)
printf (“%d”, i);
will result in the printing of

(a) 36912 (b) 3691215
(c) 3711 (d) 371115

Solution: Option (c)

3. The possible output of printf (“%d %d”, wer, wer+1); is

(a) 262262 (b) 262263
(c) 262265 (d) 262266

Solution: Option (d)

4. The following program

main ( )
static char [3] [4] = {“abcd”, “mnop”, “fghi”};
putchar (**a);

(a) will not compile successfully (b) results in run-time error
(c) prints garbage (d) none of these

Solution: Option (d)

5. The following program

main ( )

int abc ( );
abc ( );
(*abc) ( );
int abc ( )
{ printf (“come”);}

(a) results in a compilation error (b) prints come come
(c) results in a run-time error (d) prints come

Solution: Option (b)

6. The time required to search an element in a linked list of length n is

(a) O(log2 n) (b) O(1)
(c) O(n) (d) O(n2)

Solution: Option (c)

7. A possible output of the following program fragment

static cahr wer [ ] [5] = {“harmot”, “merli”, “axari”);
printf ({“%d %d”, wer, wer [0], &wer [0] [0]); is

(a) 262164 262165 262166 (b) 2616 262164 262165
(c) 262164 262164 262164 (d) 262164 262165 262165

Solution: Option (c)

8. Consider the declaration

char x [ ] = “SUCCESS”;
char *y = “SUCCESS”;

Pick the correct answers.

(a) The output of puts (x) and puts (y) will be different
(b) The output of puts (x) and puts (y) will be same
(c) The output of puts (y) is implementation dependent
(d) None of the above comments are true

Solution: Option (b)

9. Use of macro instead of function is recommended.

(a) when one wants to reduce the execution time
(b) when there is a loop with a function call inside
(c) when a function is called in many places in a program
(d) In (a) and (b) above

Solution: Option (d)

10. For loop in a C-program, if the condition is missing

(a) it is assumed to be present and taken to be false
(b) it is assumed to be present and taken to be true
(c) it result in a syntax error
(d) execution will be terminated abruptly

Solution: Option (b)

gate study material for computer science

11. Consider the following statements.

#define hypotenuse (a, b) sqrt (a* a+b *b);

The macro-call hypotenuse (a+2, b+3);

(a) Finds the hypotenuse of a triangle with sides a+2 and b+3
(b) Finds the square root of (a+2)2 + (b+3)2
(c) Finds the square root of 3*a + 4*b + 5
(d) Is invalid

Solution: Option (c)

12.Consider the following program

main ( )
int x = 2, y = 2;
if (x
else printf (“z1”);
printf (“z1”);
printf (“z2”);

Choose the correct statements

(a) The output is z2 (b) The output is z1z2
(c) This will result in compilation error (d) None of the above

Solution: Option (b)

13.Choose the False statements:

(a) The scope of a macro definition need not be the entire program
(b) The scope of a macro definition extends from the point of definition to the end of the file
(c) A macro definition may go beyond a line
(d) None of the above

Solution: Option (d)

14.Consider the following program fragment

if (a>b)
printf (“a>b”)
printf (“else part”);
printf (“a<=b”);
then a <= b
will be printed if

(a) a > b (b) a < b
(c) a = = b (d) All of the above

Solution: Option (d)

15.Consider the two declarations

void *voidPtr;
char *charPtr;

Which of the following assignments are syntactically Correct?

(a) charPtr = voidPtr (b) voidPtr = charPtr
(c) *charPtr = voidPtr (d) *voidPtr = *charPtr

Solution: Option (b)

16.The output of the following program is

main ( )
static int x[ ] = {1, 2, 3, 4, 5, 6, 7, 8};
inti ;
for (i = 2; i<6 i="" p="">
x [x[i]] = x [i];
for (i = 0; i<8 i="" p="">
printf (“%d”, x [i]);

(a) 12335578 (b) 12345678
(c) 12354678 (d) 87654321

Solution: Option (a)

17. For ‘C’ programming language

(a) constant expressions are evaluated at compile time
(b) size of array should be known at compile time
(c) strings constants can be concatenated at compile time
(d) all of these

Solution: Option (d)

18. Consider the declarations:

char first (int(*) (char, float));
int second (char, float);

Which of the following function invocation is valid?

(a) first (*second) (b) first (&second);
(c) first (second) (d) none of these

Solution: Option (c)

19. The output of the following program

main ( )
int a = 1, b = 2, c = 3;
printf (“%d”, a+ = (a+ = 3, 5, a));
will be

(a) 12 (b) 6
(c) 9 (d) 8

Solution: Option (d)

Keywords: C Programming Multiple Choice Questions and Answers, C Multiple Choice Questions and Answer,C Programming Online Quiz,C Multiple Choice Questions



advance-java,2,advancejava,1,aktu entrance exam,1,aktu exam schedule,1,ASP,1,bare machine,1,base register and limit register,1,Basic Computer network questions,1,C Programming,15,C Plus Plus,1,C Programming,2,C Programming MCQ,2,C Programming Questions,2,C programming study material for gate exam,13,CBNST Program,1,Childcare,1,CJ,2,Cloud Computing,1,components of use case diagram,1,Computer architecture based questions for gate exam,11,Computer Network,3,Computer Network Study Material,4,Computer network study material for gate,2,Computer Networks,7,Computer Science Study Material for Gate,20,computer science study material for gate exam,37,content based image retrieval content based image retrieval system,1,contiguous memory allocation,2,Core Java,8,COre Java Interview Questions,1,core java interviews questions,1,cyber crime report,1,Cyber crime status,1,cybercrime and security,1,cybercrime examples,1,Data link Layer Questions,1,Data Mining,1,Data Structure Questions,1,Data Transmission Architecture,1,Data Transmission in wsn,1,DBMS,4,dbms question paper,1,DE,1,Different types of addressing modes,1,Digital Electronics,1,DS,1,dynamic linking,1,dynamic linking in memory management,1,Electroencephalogram,1,File Handling,1,file management in operating system notes,1,FOC,1,Fundamenatl of Computer,1,Gate 2017,5,Gate 2017 Admit card,1,Gate 2017 Exam Schedule,1,Gate 2017 Syllabus,1,gate 2018,1,gate cse study material,1,gate practice set,10,gate study material for computer science,19,Gate study material for computer science 2017,1,GatePreviousYear,1,General,3,HCL Aptitude Test,1,HR Interview Questions,1,HTML,1,Image Processing,1,Important Date of Gate 2017 Exam,1,Information Security Policy,1,internal and external fragmentation,1,JS,1,lagrange's interpolation formula,1,lagrange's interpolation formula examples,1,Looping in C,1,MComputing,1,memory fragmentation,1,memory management,1,Motivational,4,NCER,2,Numerical Techniques Lab,1,OOT,1,Operating System,10,Operating System Objective Questions,4,Operating System Questions Bank,1,Operating system questions for gate,1,Operating System Study material,2,operating system study material for gate exam,16,Operating system tutorial,2,ORACLE,1,page swapping,1,paged memory allocation,1,paged memory allocation in operating system,1,paging technique of memory management .paging technique,1,paging technique of memory management program in c,1,Pointer in C,5,Process based question for gate,1,Quiz on non conventional energy resources,1,Regression testing,1,relocation in memory management,1,relocation registe,1,relocation register,1,resident monitor,1,resident monitor in operating system,1,routing table,1,segmentation in memory management,1,segmentation in memory management in operating system,1,Servlet,1,session tracking,1,session tracking in java,1,session tracking in servlet,1,Software Engineering,8,Software Engineering baes study material for gate,1,software engineering interview questions,1,Software Quality Assurance,3,SPM,1,SQL,1,Structure in C,1,Study Material for gate Computer Science,11,swapping in memory management,1,swapping in operating system,1,TCS Code Vita,1,Technical Questions from DBMS,1,Thrashing in Operating System,1,Threads concept in operating system,1,Tips to Learn Coding,1,Top 30 Core Java Interview Questions with Answer,2,top down approach,1,top down approach in programming,1,Types of operating system,1,UML,1,use case diagram explanation,1,website uses cookies,1,what is cookies website,1,What is process control block ?,1,what is software testing?,1,Wireless Sensor Network,3,worst fit algorithm for memory allocation,1,XML,1,
Computer Science Junction: C programming language questions and answer for GATE CSE - Practice SET1
C programming language questions and answer for GATE CSE - Practice SET1
c programming test questions and answers, c programming test questions and answers,c aptitude questions with answers
Computer Science Junction
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share. STEP 2: Click the link you shared to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy