Sample Question Set For Coding and Debugging

Similar documents
C PROGRAMMING QUESTIONS AND

C Multiple Choice Questions and answers MCQ with Ans.

(2) What is meaning of following pointer declaration? int(*(*ptr1)())[2];

Latest R Systems Placement Test Questions

C aptitude interview questions

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Sasken Technical Questions

Group of Institutions Test Paper: Technical (Set-4) T&P Department } (A) 0 (B) 25 (C) 1 (D) -1 (E) 2. } (A) Sachin (B) Rahul

Presented By : Gaurav Juneja

Q 1. Attempt any TEN of the following:

2. Which of the following will print the value 2 for the above code?

S.Purushothaman M.Sc.,B.Ed. WhatsApp

MCAT113: Principles of Programming with C

Practice Sheet #07 with Solutions

Lecture 02 C FUNDAMENTALS

Tutorial 10 Pointers in C. Shuyue Hu

CS 61C: Great Ideas in Computer Architecture Introduction to C

Section - Computer Science. int main() {! int a=10,b=20;! printf("a:%d B:%d\n",a,b);! a=(a+b)-(b=a);! printf("a:%d B:%d\n",a,b);!

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #07. Topic: Pointer in C Date:

C - Basics, Bitwise Operator. Zhaoguo Wang

2. C99 standard guarantees uniqueness of characters for internal names. A. 12 B. 26 C. 31 D. 48

C Programming Language

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

Pointer in C SHARDA UNIVERSITY. Presented By: Pushpendra K. Rajput Assistant Professor

Fundamental of Programming (C)

d)only getch() 9)conio.h has declaration of a)getch() and clrscr() b)printf() and scanf() c)scanf() and getch() d)only getch()

MCA Semester 1. MC0061 Computer Programming C Language 4 Credits Assignment: Set 1 (40 Marks)

Section - Computer Science

a. ++ b. -- c. sizeof d. - e. all the above 11. Which of the following is the wrong combination for any two operators in C a. different precedence,

Pointers, Dynamic Data, and Reference Types

Chapter 6. Data Structure. /* start contains the address of the first node */ start = &elephant1; print_elephants( start ); return EXIT_SUCCESS;

Fundamentals of Programming Session 19

More about BOOLEAN issues

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

{ int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } A. Function addmult() return 7 and 12 B. No output C. Error: Compile error D.

A Fast Review of C Essentials Part I

Q. 1 What will be the output of the following program? Justify your answer. [4] #include <stdio.h> main(){ int i=4, a[5]={1,2,3,4,5};

Week 1 Questions Question Options Answer & Explanation A. 10 B. 20 C. 21 D. 11. A. 97 B. 98 C. 99 D. a

Trắc nghiệm lập trình C

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04

Low-Level C Programming. Memory map Pointers Arrays Structures

Administrivia. Introduction to Computer Systems. Pointers, cont. Pointer example, again POINTERS. Project 2 posted, due October 6

6.096 Introduction to C++ January (IAP) 2009

Week 3 Lecture 2. Types Constants and Variables

Programming in C - Part 2

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

Lectures 5-6: Introduction to C

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

MIDTERM TEST EESC 2031 Software Tools June 13, Last Name: First Name: Student ID: EECS user name: TIME LIMIT: 110 minutes

Subject: Fundamental of Computer Programming 2068

Lectures 5-6: Introduction to C

Jagannath Institute of Management Sciences Lajpat Nagar. BCA II Sem. C Programming

CMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso

C Programming Review CSC 4320/6320

C Language, Token, Keywords, Constant, variable

F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C

EE 312 Fall 2018 Midterm 1 Version A October 10, 2018

cout << "How many numbers would you like to type? "; cin >> memsize; p = new int[memsize];

High Performance Programming Programming in C part 1

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Fundamentals of Programming Session 20

First of all, it is a variable, just like other variables you studied

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

Variables in C. CMSC 104, Spring 2014 Christopher S. Marron. (thanks to John Park for slides) Tuesday, February 18, 14

Dynamic Memory Allocation

Tokens, Expressions and Control Structures

Syntax and Variables

ET156 Introduction to C Programming

1d: tests knowing about bitwise fields and union/struct differences.

Storage class and Scope:

CS 61c: Great Ideas in Computer Architecture

CS349/SE382 A1 C Programming Tutorial

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

1. If you declare within a function: It retains the value between function calls

C PROGRAMMING Lecture 4. 1st semester

Princeton University COS 333: Advanced Programming Techniques A Subset of C90

Department of Computer Applications

Character Strings. String-copy Example

Memory Allocation. General Questions

DC104 DATA STRUCTURE JUNE Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

Operating Systems 2INC0 C course Pointer Advanced. Dr. Ir. Ion Barosan

PROGRAMMAZIONE I A.A. 2017/2018

80 Minutes CENG 230 MidtermExam :40

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

CMPE-013/L. Introduction to C Programming

C++ 8. Constructors and Destructors

#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0;

Unit IV & V Previous Papers 1 mark Answers

Pointers. Mr. Ovass Shafi (Assistant Professor) Department of Computer Applications

The Nifty Way to Call Hell from Heaven ANDREAS LÖSCHER AND KONSTANTINOS SAGONAS UPPSAL A UNIVERSIT Y

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100

Lecture 3. Variables. Variables

CS 0449 Sample Midterm

UNIT-IV. Structure is a user-defined data type in C language which allows us to combine data of different types together.

Prepared by: Shraddha Modi

AMCAT Automata Coding Sample Questions And Answers

Transcription:

Sample Question Set For Coding and Debugging 1.What will be the output of the following statements? int i = 1,j; int i = 1,j; j=i--- -2; printf("%d",j); a) error b) 2 c) 3 d) -3 2. 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 3. int const *p=5; printf("%d",++(*p)); what is the output? a) 6 b) 5 c) Compile error d) Run time error 4.main() printf("\nab"); printf("\bsi"); printf("\rha"); 1

what is the output? a) has b)hasaiaab c)hai d)aas 5. #define a 10 main() #define a 50 printf(%d",a); a) 10 b) 50 c) error d) none 6. Which of the following gives the memory address of a variable pointed to by pointer a? A. a; B. *a; C. &a; D. address(a); 7. Which of the following accesses a variable in structure b? A. b->var; B. b.var; C. b-var; D. b>var; 8. What wil be the output of the foll program int a=320; char *ptr; ptr=(char *)&a; printf("%d",*ptr); 2

a)2 b)320 c)64 d)compilation error e)none of the above Because,the binary equivalent of 320 is stored. But the pointer takes only the 8 bits. So the decimal equivalent is 64. 9.what is the output of the following program #include<string.h> char *ptr1=null; char *ptr2=0; strcpy(ptr1,"c"); strcpy(ptr2,"questions"); printf("\n%s%s",ptr1,ptr2); a)cquestions b)c (null) c)(null) (null) d)compiler error e)none of the above 10.what is the output of the following program int huge *a=(int huge *)0x59990005; int huge *b=(int huge *)0x59980015; if(a==b) printf("velammal Institute of Technology"); else printf("cse"); 3

a)velammal Institute of Technology b)cse c)csecse d)compilation error e)none of the above 4 www.profmariamichael.com 11.What would be the output of the foll program #include<string.h> register a=25; int far *p; p=&a; printf("%d",*p); a)25 b)4 c)address d)compilation error e)none of the above 12.What would be the output of the foll program #include<string.h> char far *p,*q; printf("%d%d",sizeof(p),sizeof(q)); a)2 2 b)4 4 c)4 2 d)2 4 e)none of the above 13.What would be the output of the foll program

int a=10; void *p=&a; int *ptr=p; printf("%u",*ptr); a)10 b)address c)2 d)compilation error e)none of the above 14.What would be the output of the foll program #include<string.h> int register a; scanf("%d",&a); printf(%d",a); //if a=25 a)25 b)address c)0 d)compilation error e)none of the above 15.What would be the output of the foll program char arr[100]; arr="world"; printf("%s",arr); 5

a)world b)w c)null d)compilation error e)none of the above 16. Which of the following gives the memory address of a variable pointed to by pointer a? A. a; B. *a; C. &a; D. address(a); 17.What would be the output of the foll program #include<string.h> int a,b,c,d; char *p=(char*)0; int *q=(int*q)0; float *r=(float*)0; double *s=0; a=(int)(p+1); b=(int)(p+1); c=(int)(p+1); d=(int)(p+1); printf("%d%d%d%d",a,b,c,d); a)2 2 2 2 b)1 2 4 8 c)1 2 2 4 d)compilaion error e)none of the above 18.What will be output of following program? #include<conio.h> 6

void (*p)(); int (*q)(); int (*r)(); p = clrscr; q = getch; r = puts; (*p)(); (*r)("coding and debugging"); (*q)(); (A) NULL (B) coding and debugging (C) c 7 www.profmariamichael.com 19.What will be output of following program? int i = 3; int *j; int **k; j=&i; k=&j; printf( %u %u %d,k,*k,**k); (A) Address, Address, 3 (B) Address, 3, 3 (C) 3, 3, 3 20.What will be output of following program? #include<string.h> int a = 5,b = 10,c; int *p = &a,*q = &b; c = p - q;

printf("%d", c); (A) 1 (B) 5 (C) -5 21.What will be output of following program? unsigned long int (* avg())[3] static unsigned long int arr[3] = 1,2,3; return &arr; unsigned long int (*ptr)[3]; ptr = avg(); printf("%d", *(*ptr+2)); (A) 1 (B) 2 (C) 3 22.What will be output of following program? int * p, b; b = sizeof(p); printf( %d, b); (A) 2 (B) 4 (C) 8 8

9 www.profmariamichael.com 23.What will be output of following program? int i = 5, j; int *p, *q; p = &i; q = &j; j = 5; printf("value of i : %d value of j : %d",*p,*q); (A) 5 5 (B) Address Address (C) 5 Address 24.What will be output of following program? int i = 5; int *p; p = &i; printf(" %u %u", *&p, &*p); (A) 5 Address (B) Address Address (C) Address 5 25.What will be output of following program? int i = 100; printf("value of i : %d addresss of i : %u",i,&i);

i++; printf("\nvalue of i : %d addresss of i : %u",i,&i); (A)value of i : 100 addresss of i : Address value of i : 101 addresss of i : Address (B)value of i : 100 addresss of i : Address value of i : 100 addresss of i : Address (C)value of i : 101 addresss of i : Address value of i : 101 addresss of i : Address 26.What will be output of following program? char far *p =(char far *)0x55550005; char far *q =(char far *)0x53332225; *p = 25; (*p)++; printf("%d",*q); (A) 25 (B) Address (C) Garbage (E)None of above 27.What will be output of following program? int I = 3; int *j; int **k; j = &i; k = &j; 10

printf( %u %u %u,i,j,k); (A) 3 Address 3 (B) 3 Address Address (C) 3 3 3 www.profmariamichael.com 28.What will be output of following program? main() printf("%d, %d", sizeof('c'), sizeof(100)); A) 4, 100 B) 2, 100 C) 2, 2 D) 4, 4 E)None of the above 29.What will be output of following program? void func1(int (*a)[10]) printf("ok it works"); void func2(int a[][10]) printf("will this work?"); main() int a[10][10]; func1(a); func2(a); A) Ok it workswill this work? B) Will this work? C) Ok it works D) Compiler error E)None of the above 11

30.What is the output for the program given below typedef enum errortypewarning, 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 31.What is the output of the following? main() int i; i = 64/square(4);//since / and * r given equal priority,its exec as 64/4*4=(64/4)*4 printf("%d\",i); a) 16 b) 4 c) 64 d) error 32.What will be the output of the following statement? /* /* printf("hello"); */ */ a) hello b) no output c) error d) "hello" 33.What will be the output of the following statements? int a = printf("00"); printf("%d",a); a) 0 b) 00 c) 002 12

d) garbage value 34. extern int x; printf("%d",x); int x = 10; what is the output? a) error b) 0 c) garbage value d) 10 35. What will be the output of the following program? 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 36.How many times the following program will print "hello"? printf("hello"); main(); a) 1 b) 2 13

c) infinite number of times d) none of these www.profmariamichael.com 37.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 38.What will be the output of the following statement? printf("hello""""world"); a) error b) hello""""world c) hello d) helloworld 39.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 40.What will be the output of following program? printf("%d"); a) error b) no output c) %d d) 0 14