Sasken Technical Questions

Similar documents
{ 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.

Arrays. Example: Run the below program, it will crash in Windows (TurboC Compiler)

AMCAT Procedure functions and scope Sample 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

Memory Allocation. General Questions

Principles of C and Memory Management

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

COP 3223 Introduction to Programming with C - Study Union - Spring 2018

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

Huawei Test 3. 1 A card is drawn from a pack of 52 cards. The probability of getting a queen of club or a king of heart is:

Sample Question Set For Coding and Debugging

Final Intro to C Review

Dr. R. Z. Khan, Associate Professor, Department of Computer Science

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator

Huawei Test 2. 1 Two dice are thrown simultaneously. What is the probability of getting two numbers whose product is even?

C Multiple Choice Questions and answers MCQ with Ans.

High Performance Programming Programming in C part 1

C Programming Language: C ADTs, 2d Dynamic Allocation. Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008

M1-R4: Programing and Problem Solving using C (JAN 2019)

Programming I Assignment 04. Branching I. # Student ID Student Name Grade (10) -

Fundamental of Programming (C)

CGS 3460 Summer 07 Midterm Exam

Government Polytechnic Muzaffarpur.

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

Dynamic Memory Allocation

Section - Computer Science

Content. In this chapter, you will learn:

Parameter passing. Programming in C. Important. Parameter passing... C implements call-by-value parameter passing. UVic SEng 265

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

Q 1. Attempt any TEN of the following:

Outline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C

Introduction to C. Systems Programming Concepts

Chapter 2 (Dynamic variable (i.e. pointer), Static variable)

C PROGRAMMING QUESTIONS AND

Practice Sheet #07 with Solutions

C LANGUAGE A Short Course

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);!

Solutions to Assessment

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

Fundamentals of Programming Session 19

From Java to C. Thanks to Randal E. Bryant and David R. O'Hallaron (Carnegie-Mellon University) for providing the basis for these slides

Flipkart Placement Papers

Actually, C provides another type of variable which allows us to do just that. These are called dynamic variables.

Structured Programming. Functions and Structured Programming. Functions. Variables

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];

A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE

ITEC114 Structured Programming Midterm Exam, Spring 2015/ April Instructor: Akile Oday Research Assistant: Mohammed Abubakar SOLUTIONS

Dynamic memory allocation

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

Basic and Practice in Programming Lab7

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

MCAT113: Principles of Programming with C

CSC 270 Survey of Programming Languages. What is a Pointer?

INTRODUCTION TO C-PROGRAMING LANGUAGE

These problems are provided to you as a guide for practice. The questions cover important concepts covered in class.

C/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock)

C/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for

Answers to Practice Problems

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

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

Character Strings. String-copy Example

Pointers, Dynamic Data, and Reference Types

4) In C, if you pass an array as an argument to a function, what actually gets passed?

Arrays in C. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur. Basic Concept

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

int marks[10]; // fixed size and fixed address No change in Memory address.

Advanced Pointer Topics

Arrays. An array is a collection of several elements of the same type. An array variable is declared as array name[size]

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015

Introduction to C Language (M3-R )

Your first C++ program

Programming with Indexed Variables

AMCAT Automata Coding Sample Questions And Answers

Structures. Basics of Structures (6.1) EECS l Now struct point is a valid type. l Defining struct variables: struct point { int x; int y; };

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,

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

Lecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions

Dynamic Allocation of Memory Space

Library Functions. General Questions

MODULE Z THE C STORAGE CLASSES, SCOPE AND MEMORY ALLOCATION

Decision Making and Loops

C Program Development and Debugging under Unix SEEM 3460

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

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

A pointer is a variable just like other variable. The only difference from other variables is that it stores the memory address other variables.

Dynamically Allocated Memory in C

Huawei Test 5. Explanation: P.W. of Rs. 12,880 due 8 months hence=rs. [ (12880*100)/(100+(18*(8/12)))]

PDS Class Test 2. Room Sections No of students

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)

Heap Arrays. Steven R. Bagley

CS 61c: Great Ideas in Computer Architecture

Outline. Briefly review the last class Pointers and Structs Memory allocation Linked lists

Scope. Scope. Region of a program in which a defined object is visible. Defined Objects. Two types of regions. Variables Functions

CS61, Fall 2012 Section 2 Notes

Subject: Fundamental of Computer Programming 2068

Procedural Programming & Fundamentals of Programming

Programming and Data Structures Mid-Semester - Solutions to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring

Edward Garcia (ewg2115) Naveen Revanna (nr2443) Niket Kandya (nk2531) Sean Yeh (smy2112)

Discussion 3 Richard Guo Advanced C 01/28/09

Transcription:

Sasken Technical Questions 1. main() int a = 10,*j; void *k; j = k =&a; j++; k++; printf("\n %u %u",j,k); A.compiler error B.syntax error C.memory address D.no output Explanation: cannot increment a void pointer 2. What will be the output of the program? int i; int fun1(int); int fun2(int); extern int j; int i=3; fun1(i); printf("%d,", i); fun2(i); printf("%d", i); int fun1(int j) printf("%d,", ++j); int fun2(int i) printf("%d,", ++i); int j=1;

A.3, 4, 4, 3 B.4, 3, 4, 3 C.3, 3, 4, 4 D.3, 4, 3, 4 3. main() int i =3; for(; i ++ = 0;) printf("%d",i); A.compiler error B.syntax error C.some garbage value D.no output Explanation: Lvalue required in function main 4. Point out the error in the program int f(int); int b; b = f(20); printf("%d\n", b); int f(int a) a > 20? return(10): return(20); A.Error: Prototype declaration B.No error conditional operators D.None of above C.Error: return statement cannot be used with Explanation: In a ternary operator, we cannot use the return statement. The ternary operator requires expressions but not code. 5. What will be output of following c program?

#define max printf("%d",max); A.0 B.null C.Garbage D.Compilation error 6. What will be the output of the program? int i; int fun(); while(i) fun(); main(); printf("hello\n"); int fun() printf("hi"); A.Hello B.Hi Hello C.No output D.Infinite loop 7. What will be output of following c program? void main() int i; for(i=0;i<5;i++) int x=0; printf("%d",x); x++;

A.01234 B.001234 C.0000 D.Infinite loop 8. What will be the output of the program? int x, y, z; x=y=z=1; z = ++x ++y && ++z; printf("x=%d, y=%d, z=%d\n", x, y, z); A.x=2, y=1, z=1 B.x=2, y=2, z=1 C.x=2, y=2, z=2 D.error 9. What will be output of following c program? long fu(int); char vect[]=1,2,3,4,5; void main() int i=1; i=fu(++i)+ ++vect[++i]+ ++i+fu(i++); printf("%d",i); long fu(int x) return x*3; A.31 B.32 C.33 D.34 10. What will be the output of the program? unsigned int i = 65536; while(i!= 0) printf("%d",++i); printf("\n");

A.Infinite loop B.0 1 2... 65535 C.0 1 2... 32767-32766 -32765-1 0 D.No output 11.void main() int a = 10, b =20; char x = 1, y = 0; if(a,b,x,y) printf("freshersworld"); What is the output? A.res is printed B.freshersworld is printed C.Compiler Error D.Nothing is printed 12. What is x in the following program? typedef char (*(*arrfptr[3])())[10]; arrfptr x; A.x is a pointer B.x is an array of three pointer C.x is an array of three function pointers in x declaration D.Error 13. main() char throught[2][30] = "Don't walk in front of me..",'i am not follow"; printf("%c%c,*(thought[0]9),*(*(thought 0)5)); What is the output of this program? A.kk B.int**array2 = (int**)malloc(nrows*sizeof(int*));don't walk in front of me C.i may not follow D.k

14. What will be the output of the program? int k=1; printf("%d == 1 is" "%s\n", k, k==1?"true":"false"); A.k == 1 is TRUE B.1 == 1 is TRUE C.1 == 1 is FALSE D.K == 1 is FALSE 15. main() int i=5; printf("%d",i = ++i==6); A.5 B.1 C.6 D.compiler error 16. Which files will get closed through the fclose() in the following program? FILE *fs, *ft, *fp; fp = fopen("a.c", "r"); fs = fopen("b.c", "r"); ft = fopen("c.c", "r"); fclose(fp, fs, ft); A."A.C" "B.C" "C.C" B."B.C" "C.C" C."A.C"D.Error in fclose() 17. void main() printf("sizeof(void *) = %d \n",sizeof(void*));

printf("sizeof(int *) = %d \n",sizeof(int*)); printf("sizeof(double*) = %d \n",sizeof(double*)); printf("sizeof(struct unknown *) = %d \n",sizeof(struct unknown*)); A.no out put B.compiler error C.sizeof(void *) = 2 sizeof(int *) = 2 sizeof(double *) = 2 sizeof(struct unknown *) = 2 D.syntax error 18. Which of the following statements are correct about the program below? int size, i; scanf("%d", &size); int arr[size]; for(i=1; i<=size; i++) scanf("%d", arr[i]); printf("%d", arr[i]); A.The code is erroneous since the subscript for array used in for loop is in the range 1 to size. B.The code is erroneous since the values of array are getting scanned through the loop. C.The code is erroneous since the statement declaring array is invalid. D.The code is correct and runs successfully. 19. # include char *somefun1() char temp[] ="string"; return temp; char * somefun2() char temp[] = 's','t','r','i','n','g'; return temp;

puts (somefun1()); puts(somefun2()); A.syntax error B.some garbage value C.compiler error D.no out put 20. What will be the output of the program? int fun(int(*)()); fun(main); printf("hi\n"); int fun(int (*p)()) printf("hello "); A.Infinite loop B.Hi C.Hello Hi D.Error 21. Point out the error, if any in the while loop. int i=1; while() printf("%d\n", i++); if(i>10) break; A.There should be a condition in the while loop B.There should be at least a semicolon in the while C.The while loop should be replaced with for loop. D.No error

22. What will be output of following c program? void main() int num,a=10; num=a--- -a--; printf("%d %d",num,a); A.0 8 B.0 10 C.20 8 D.-1 10 23. What will be output of following c program? float avg(float,float,float); void main() float p=1,q=2,r=-2,a; a=avg(p,(q=4,r=-12,q),r); printf("%f",a); float avg(float x,float y,float z) return (x+y+z)/3; A.0.111111 B.1.000000 C.-0.777777 D.-1.000000 24. How many times "Freshersworld" is get printed? int x; for(x=-1; x<=10; x++) if(x < 5) continue; else break; printf("freshersworld");

A.Infinite times B.11 times C.0 times D.10 times 25. What will be output of following c program? struct mystruct int a; char b; *ptr; struct mystruct ms=400,'a'; printf("%d %d",ptr->a,ptr->b); A.400 A B.400 6 C.400 97 D.0 0 26. What will be the output of the program? int i; i = scanf("%d %d", &i, &i); printf("%d\n", i); A.1 B.2 C.Garbage value D.Error: cannot assign scanf to variable Explanation: scanf() returns the number of variables to which you are provding the input. i = scanf("%d %d", &i, &i); Here Scanf() returns 2. So i = 2. printf("%d\n", i); Here it prints 2. 27. What will be output of following c program? float x; x=(int)1.1,(float)2.2,(int)3.3,5.4;

printf("%f",x); A.1.000000 B.5.400000 C.2.200000 D.3.300000 28. Point out the correct statement which correctly allocates memory dynamically for 2D array following program? int *p, i, j; /* Add statement here */ for(i=0; i<3; i++) for(j=0; j<4; j++) p[i*4+j] = i; printf("%d", p[i*4+j]); A.p = (int*) malloc(3, 4); B.p = (int*) malloc(3*sizeof(int)); C.p = malloc(3*4*sizeof(int)); D.p = (int*) malloc(3*4*sizeof(int)); 29. What will be output if you will compile and execute the following c code? void main() int i=320; char *ptr=(char *)&i; printf("%d",*ptr); A.320 B.1 C.64 D.Compiler error 30. What will be the output of the program?

char *s; char *fun(); s = fun(); printf("%s\n", s); char *fun() char buffer[30]; strcpy(buffer, "RAM"); return (buffer); A.0xffff B.Garbage value C.0xffee D.Error