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

Size: px
Start display at page:

Download "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"

Transcription

1 1. Predict Output? int a=0; #if (a==0) printf("equal"); #else if printf("not equal"); #endif (A) (B) (C) (D) Equal Not equal Null Garbage 2. What will be output if you will execute following c code? for(;null;) printf("cquestionbank"); (A) c (B) bank (C) cquestionbank (D) Infinite loop 3. What will be output if you will execute following c code? int x=25; if(!!x) printf("%d",!x); else printf("%d",x); (A) 0 (B) 25 (C) 1 (D) -1 (E) 2 4. What will be output if you will execute following c code? float a=0.5, b=0.9; if(a&&b>0.9) printf("sachin"); else printf("rahul"); (A) Sachin (B) Rahul Page 1 of 12

2 (C) null (D) Run time error 5. What will be output if you will execute following c code? int x=5, y=10; if(!(!x) && x) printf("%d",x); else printf("%d",y); (A) 1 (B) 0 (C) 5 (D) What will be output if you will execute following c code? char ch=321; printf("%d %c",ch,ch); (A) 321 # (B) 65 A (C) 321! (D) 66 B 7. What will be output if you will execute following c code? int a,b; a = ; b = (-3 ); printf("%d %d",a,b); (A) 0 0 (B) 0-3 (C) -3 0 (D) What will be output if you will execute following c code? int x; x= * 9 % 6 / 12; printf("%d",x); Page 2 of 12

3 (A) 6 (B) 7 (C) 8 (D) 9 9. What will be output if you will execute following c code? int x=3, y=4, z=4; printf("%d", (z>=y>=x?100:200)); (A) 100 (B) 200 (C) 0 (D) What will be output if you will execute following c code? int a=30, b=40, x; x=(a!=10) && (b=50); printf("%d",x); (A) 1 (B) 2 (C) 3 (D) What will be output if you will execute following c code? float x=12.25, y=13.65; if(x=y) printf("x and y are equal"); else printf("x and y are not equal"); (A) x and y are equal (B) x and y are not equal (C) It will print nothing (D) Run time error 12. What will be output if you will execute following c code? int i=1, j=1; for(;j;printf("%d%d\t",i,j)) j=i++ <= 5; Page 3 of 12

4 (A) (B) (C) (D) Infinite loop 13. What function is used to release the allocated memory space? (A) deallocate() (B) release () (C) free () (D) drop() (E) empty () 14. What will be output if you will execute following c code? auto int a=5; int x; x=~a+a&a+a<<a; printf("%d",x); (A) 0 (B) 1 (C) 154 (D) What will be output if you will execute following c code? void main() int a=5; int b=10; ++b; ++a; int a=20; ++a; a=++b; ++a; ++b; printf("%d %d",a,b); printf(" %d",a); (A) (B) (C) (D) Page 4 of 12

5 16. What will be output if you will execute following c code? #include<conio.h> void main() int a[]=0,1,2,3,4,5,6,7,8,9,10; int i=0,num; num=a[++i+a[++i]]+a[++i]; printf("%d",num); (A) 6 (B) 7 (C) 8 (D) What will be output if you will execute following c code? #include<conio.h> void main() int i=3,val; val=sizeof f(i)+ +f(i=1)+ +f(i-1); printf("%d %d",val,i); int f(int num) return num*5; (A) 2 0 (B) 7 1 (C) 17 0 (D) What will be output if you will execute following c code? #include<conio.h> void main() int i; (i=8)+=1; printf("%d",i); (A) 9 (B) 10 (C) 32 (D) What will be output if you will execute following c code? #include<conio.h> void main() char c=-'a'; printf("%d",c); (A) 65 (B) -65 Page 5 of 12

6 (C) -a (D) What will be output if you will execute following c code? int num,a=5; num=-a--; printf("%d %d",num,a); (A) 5 4 (B) -4 4 (C) -5 4 (D) Turbo C 3.0 is based on Top of Form (A) DOS (B) UNIX (C) Windows (D) LINUX (E) None 22. Turbo C 4.5 is based on Top of Form (A) DOS (B) UNIX (C) Windows (D) LINUX (E) None 23. Find the output of following c code? int a=4,b=5; printit(a, b); printit(int b, int a) printf("%d %d", a, b); int a=0; int b=1; printf("%d %d", a, b); (A) (B) (C) (D) None of these Page 6 of 12

7 24. The contents of a file will be lost if it is opened in (A) a mode (B) a- mode (C) w+ mode (D) a+ mode (E) r mode 25. Find the output of following c code. int i=1,j=2,k=3; if(i==1) if(j==2) if(k==3) printf("ok"); break; else printf("continue"); printf("bye"); (A) ok (B) okbye (C) Misplaced break (D) None of these (E) It will print nothing 26. Find the output of following c code. printf("c\question\bank"); (A) Cquestionbank (B) cuestionank (C) cuestioank (D) cquestioank (E) None of these. 27. What will be output if you will execute following c code? char c=+'a'; printf("%d",c); (A) 65 (B) 130 (C) Garbage value (D) What will be output if you will execute following c code? Page 7 of 12

8 int num,a=5; num=+++a; printf("%d %d",num,a); (A) 5 5 (B) 6 6 (C) 7 7 (D) What will be output if you will execute following c code? int num,a=10; num=a a; printf("%d %d",num,a); (A) (B) (C) (D) What will be output if you will execute following c code? int z; z=5,3,2; printf("%d",z); (A) 5 (B) 3 (C) 2 (D) What will be output if you will execute following c code? int i=5,j=10,num; num=++i,++j,i+j; printf("%d %d %d",num,i,j); (A) (B) (C) (D) Page 8 of 12

9 32. What will be output if you will execute following c code? float avg(float,float,float); 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) (B) (C) (D) What will be output if you will execute following c code? char c='\x15'; char *ptr=&c; printf("%x",*ptr); (A) 0x15 (B) 0X15 (C) 21 (D) 0x What will be output if you will execute following c code? char array[]="ashfaq \0 Kayani"; char *str="ashfaq \0 Kayani"; printf("%s %c\n",array,array[2]); printf("%s %c\n",str,str[2]); printf("%d %d\n",sizeof(array),sizeof(str)); (A) (B) (C) (D) Ashfaq h Ashfaq h 16 2 Ashfaq h Ashfaq Kayani h 2 16 Ashfaq Kayani h Ashfaq h 16 2 Ashfaq h Ashfaq h What will be output if you will execute following c code? union mystruct Page 9 of 12

10 int a; char b; ; union mystruct ms=400; printf("%d %d",ms.a,ms.b); (A) (B) (C) (D) union cqbu int a; char b; ; struct cqbs int a; char b; ; struct cqbs s=25,50; struct cqbs *ps=(struct cqbs *)&s; union cqbu *pu=(union cqbu *)&s; printf("%d %d\n",ps->a,ps->b); printf("%d %d\n",pu->a,pu->b); (A) (B) (C) (D) float x; x=(int(float(double)5.5)); printf("%f",x); (A) 5.5 (B) (C) (D) What will be output if you will execute following c code? float x; (int)x=5.8f; printf("%f",x); Page 10 of 12

11 (A) (B) (C) (D) What will be output if you will execute following c code? int a=5,b=10,c=15; int *arr[3]=&a,&b,&c; printf("%d",*arr[*arr[1]-8]); (A) 5 (B) 10 (C) 18 (D) Garbage value 40. What will be output if you will execute following c code? int arr[][3]=1,2,3,4,5,5; printf("%d %d %d",sizeof(arr),arr[0][2],arr[1][2]); (A) (B) (C) (D) Which of the following about the following two declaration is true i ) int *F() ii) int (*F)() Choice : a) Both are identical b) The first is a correct declaration and the second is wrong c) The first declaraion is a function returning a pointer to an integer and the second is a pointer to function returning int d) Both are different ways of declarin pointer to a function 42. What are the values printed by the following program? #define dprint(expr) printf(#expr "=%d\n",expr) main() int x=7; int y=3; dprintf(x/y); Choice: a) #2 = 2 b) expr=2 c) x/y=2 d) none 43. What is th output of the following program? Page 11 of 12

12 int x= 0x65; main() char x; printf("%d\n",x) a) compilation error b) 'A' c) 65 d) unidentified 44. What is the output of the following program main() int a=10; int b=6; if(a=3) b++; printf("%d %d\n",a,b++); a) 10,6 b)10,7 c) 3,6 d) 3,7 e) none 45. What can be said of the following program? main() enum Months JAN =1,FEB,MAR,APR; Months X = JAN; if(x==1) printf("jan is the first month"); a) Does not print anything b) Prints : Jan is the first month c) Generates compilation error d) Results in runtime error 46. What is the output of the following program? main() int l=6; switch(l) default : l+=2; case 4: l=4; case 5: l++; break; printf("%d",l); a)8 b)6 c)5 d)4 e)none 47. What is the output of the following program? main() int x=20; int y=10; swap(x,y); printf("%d %d",y,x+2); swap(int x,int y) int temp; temp =x; x=y; y=temp; a)10,20 b) 20,12 c) 22,10 d)10,22 e)none 48. What is the size of the following union. Assume that the size of int =2, size of float =4 and size of char =1. Union Tag int a; flaot b; char c; ; a)2 b)4 c)1 d) Which of the following involves context switch, (a) system call (b) priviliged instruction (c) floating poitnt exception (d) all the above (e) none of the above 50. In OST, terminal emulation is done in (a) sessions layer (b) application layer (c) presentation layer (d) transport layer Page 12 of 12

HCL Placement Paper 10

HCL Placement Paper 10 HCL Placement Paper 10 HCL Technology Interview 2004 in MKU Technical interview is held for 30 min to 1 hr 20min depending upon the stuff. Concentrated areas are 1) OS Concepts 2) C Programming skill 3)

More information

HCL Aptitude Test a=2, b=3, c=6 Find the value of c/(a+b)-(a+b)/c Ans. 11/30

HCL Aptitude Test a=2, b=3, c=6 Find the value of c/(a+b)-(a+b)/c Ans. 11/30 HCL Aptitude Test 3 1. a=2, b=3, c=6 Find the value of c/(a+b)-(a+b)/c Ans. 11/30 2. What does the hexa number E78 in radix 7. (a) 12455 (b) 14153 (c) 14256 (d) 13541 (e) 131112 Ans. (d) 3. What does the

More information

Please note that, for all What will be output questions, the answer could be error or indefinite. However, there is no compile error.

Please note that, for all What will be output questions, the answer could be error or indefinite. However, there is no compile error. 이름 : 학번 : Please note that, for all What will be output questions, the answer could be error or indefinite. However, there is no compile error. 1. What will be output if you will execute following c code?

More information

Sasken Technical Questions

Sasken Technical Questions 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

More information

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

M1-R4: Programing and Problem Solving using C (JAN 2019) M1-R4: Programing and Problem Solving using C (JAN 2019) Max Marks: 100 M1-R4-07-18 DURATION: 03 Hrs 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter

More information

C PROGRAMMING QUESTIONS AND

C PROGRAMMING QUESTIONS AND 8/26/2011 C C PROGRAMMING QUESTIONS AND ANSWER http://cquestionbank.blogspot.com Ritesh kumar (1) What will be output if you will compile and execute the following c code? struct marks{ int p:3; int c:3;

More information

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

2. Which of the following will print the value 2 for the above code? Computers are good at following instructions, but not at reading your mind. - Donald Knuth IMPORTANT QUESTIONS ON C LANGUAGE 1. What is the output of this program? char *ptr; char string[] = "How are you?";

More information

80 Minutes CENG 230 MidtermExam :40

80 Minutes CENG 230 MidtermExam :40 80 Minutes CENG 230 MidtermExam 02.12.2014 17:40 There are 40 questions (each 2.5 points) for a total of 100 points. Exam Type: A All questions are multiple choice, no points will be lost for wrong answers.

More information

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 - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

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 - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

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

COP 3223 Introduction to Programming with C - Study Union - Spring 2018 COP 3223 Introduction to Programming with C - Study Union - Spring 2018 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

C Multiple Choice Questions and answers MCQ with Ans.

C Multiple Choice Questions and answers MCQ with Ans. C Multiple Choice Questions and answers MCQ with Ans. 1. Who is father of C Language? A. Bjarne Stroustrup B. Dennis Ritchie C. James A. Gosling D. Dr. E.F. Codd Answer : B 2. C Language developed at?

More information

Sample Question Set For Coding and Debugging

Sample Question Set For Coding and Debugging 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

More information

HCL Sample Test Paper

HCL Sample Test Paper HCL Sample Test Paper Section A 1. Which of the following involves context switch, (a) system call (b) priviliged instruction (c) floating poitnt exception (d) all the above (e) none of the above Ans:

More information

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

Week 1 Questions Question Options Answer & Explanation A. 10 B. 20 C. 21 D. 11. A. 97 B. 98 C. 99 D. a Sr. no. Week 1 Questions Question Options Answer & Explanation 1 Find the output: int x=10; int y; y=x++; printf("%d",x); A. 10 B. 20 C. 21 D. 11 Answer: D x++ increments the value to 11. So printf statement

More information

Practice Sheet #07 with Solutions

Practice Sheet #07 with Solutions Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Practice Sheet #07 with Solutions Topic: Pointer in C Date: 23-02-2017 1 Assume the following C variable declaration

More information

Lecture 02 C FUNDAMENTALS

Lecture 02 C FUNDAMENTALS Lecture 02 C FUNDAMENTALS 1 Keywords C Fundamentals auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void

More information

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

{ 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. SAP TECHNICAL PAPER 1. If int is 2 bytes wide.what will be the output of the program? void fun(char**); char *argv[] = "ab", "cd", "ef", "gh"; fun(argv); void fun(char **p) char *t; t = (p+= sizeof(int))[-1];

More information

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

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #07. Topic: Pointer in C Date: Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Practice Sheet #07 Topic: Pointer in C Date: 23-02-2017 1. Assume the following C variable declaration int *A [10],

More information

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

More information

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

Parameter passing. Programming in C. Important. Parameter passing... C implements call-by-value parameter passing. UVic SEng 265 Parameter passing Programming in C UVic SEng 265 Daniel M. German Department of Computer Science University of Victoria 1 SEng 265 dmgerman@uvic.ca C implements call-by-value parameter passing int a =

More information

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

(2) What is meaning of following pointer declaration? int(*(*ptr1)())[2]; (1) What is meaning of following declaration? int(*ptr[5])(); (a)ptr is pointer to function. (b)ptr is array of pointer to function (c)ptr is pointer to such function which return type is array. (d)ptr

More information

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 Name :. Roll No. :..... Invigilator s Signature :.. 2011 INTRODUCTION TO PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give

More information

Introduction to C Language (M3-R )

Introduction to C Language (M3-R ) Introduction to C Language (M3-R4-01-18) 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in OMR answer sheet supplied with the question paper, following

More information

OBJECTIVE QUESTIONS: Choose the correct alternative:

OBJECTIVE QUESTIONS: Choose the correct alternative: OBJECTIVE QUESTIONS: Choose the correct alternative: 1. Function is data type a) Primary b) user defined c) derived d) none 2. The declaration of function is called a) function prototype b) function call

More information

Solution Set(Reference Book - Programming with c By Byron Gottfried Thrid Edition)

Solution Set(Reference Book - Programming with c By Byron Gottfried Thrid Edition) (2½ Hours) [Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Make suitable assumptions wherever necessary and state the assumptions made. (3) Answers to the same question must be written together.

More information

Pointers, Dynamic Data, and Reference Types

Pointers, Dynamic Data, and Reference Types Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple

More information

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

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space

More information

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

d)only getch() 9)conio.h has declaration of a)getch() and clrscr() b)printf() and scanf() c)scanf() and getch() d)only getch() Practice Problems-2 Prepared by:dilip Kumar Gangwar(Faculty,CS/IT DEPTT GEHU) 1)C Language is developed by- 1.Bjarne stroutstrup 2.Dennis Ritchie 3.R.Byrant 4.None of the above 2)C is a a)middle level

More information

Flow of Control. Selection. if statement. True and False in C False is represented by any zero value. switch

Flow of Control. Selection. if statement. True and False in C False is represented by any zero value. switch Flow of Control True and False in C Conditional Execution Iteration Nested Code(Nested-ifs, Nested-loops) Jumps 1 True and False in C False is represented by any zero value The int expression having the

More information

b. array s first element address c. base address of an array d. all elements of an array e. both b and c 9. An array elements are always stored in a.

b. array s first element address c. base address of an array d. all elements of an array e. both b and c 9. An array elements are always stored in a. UNIT IV 1. Appropriately comment on the following declaration int a[20]; a. Array declaration b. array initialization c. pointer array declaration d. integer array of size 20 2. Appropriately comment on

More information

Principles of C and Memory Management

Principles of C and Memory Management COMP281 Lecture 8 Principles of C and Memory Management Dr Lei Shi Last Lecture Pointer Basics Previous Lectures Arrays, Arithmetic, Functions Last Lecture Pointer Basics Previous Lectures Arrays, Arithmetic,

More information

Subject: Fundamental of Computer Programming 2068

Subject: Fundamental of Computer Programming 2068 Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find

More information

C Syntax Out: 15 September, 1995

C Syntax Out: 15 September, 1995 Burt Rosenberg Math 220/317: Programming II/Data Structures 1 C Syntax Out: 15 September, 1995 Constants. Integer such as 1, 0, 14, 0x0A. Characters such as A, B, \0. Strings such as "Hello World!\n",

More information

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

First of all, it is a variable, just like other variables you studied Pointers: Basics What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the address (rather than the value)

More information

CS 0449 Sample Midterm

CS 0449 Sample Midterm Name: CS 0449 Sample Midterm Multiple Choice 1.) Given char *a = Hello ; char *b = World;, which of the following would result in an error? A) strlen(a) B) strcpy(a, b) C) strcmp(a, b) D) strstr(a, b)

More information

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

Administrivia. Introduction to Computer Systems. Pointers, cont. Pointer example, again POINTERS. Project 2 posted, due October 6 CMSC 313 Introduction to Computer Systems Lecture 8 Pointers, cont. Alan Sussman als@cs.umd.edu Administrivia Project 2 posted, due October 6 public tests s posted Quiz on Wed. in discussion up to pointers

More information

Q 1. Attempt any TEN of the following:

Q 1. Attempt any TEN of the following: Subject Code: 17212 Model Answer Page No: 1 / 26 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The

More information

Language comparison. C has pointers. Java has references. C++ has pointers and references

Language comparison. C has pointers. Java has references. C++ has pointers and references Pointers CSE 2451 Language comparison C has pointers Java has references C++ has pointers and references Pointers Values of variables are stored in memory, at a particular location A location is identified

More information

Functions. Cedric Saule

Functions. Cedric Saule Cedric Saule cedric.saule@uni-bielefeld.de or procedures? In algorithmic (and some programming languages), we use two kinds of unconditional branchings : Procedures : execute computations and do not return

More information

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine

More information

Flow Control. CSC215 Lecture

Flow Control. CSC215 Lecture Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements

More information

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ... Why Pointers Pointers They provide the means by which functions can modify arguments in the calling function. They support dynamic memory allocation. They provide support for dynamic data structures, such

More information

Midterm Exam 2 Solutions, C programming

Midterm Exam 2 Solutions, C programming Midterm Exam 2 Solutions, C programming April 26, 2010 Rules: Open book, open notes, open any printed or handwritten material. No electronic devices (except a music player). If you use a music player nobody

More information

TEST BDA24202 / BTI10202 COMPUTER PROGRAMMING May 2013

TEST BDA24202 / BTI10202 COMPUTER PROGRAMMING May 2013 DEPARTMENT OF MATERIAL AND ENGINEERING DESIGN FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING UNIVERSITI TUN HUSSEIN ONN MALAYSIA (UTHM), JOHOR TEST BDA24202 / BTI10202 COMPUTER PROGRAMMING May 2013

More information

UNIT - V STRUCTURES AND UNIONS

UNIT - V STRUCTURES AND UNIONS UNIT - V STRUCTURES AND UNIONS STRUCTURE DEFINITION A structure definition creates a format that may be used to declare structure variables. Let us use an example to illustrate the process of structure

More information

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

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

Functions. Arash Rafiey. September 26, 2017

Functions. Arash Rafiey. September 26, 2017 September 26, 2017 are the basic building blocks of a C program. are the basic building blocks of a C program. A function can be defined as a set of instructions to perform a specific task. are the basic

More information

Sample Paper Class XI Subject Computer Sience UNIT TEST II

Sample Paper Class XI Subject Computer Sience UNIT TEST II Sample Paper Class XI Subject Computer Sience UNIT TEST II (General OOP concept, Getting Started With C++, Data Handling and Programming Paradigm) TIME: 1.30 Hrs Max Marks: 40 ALL QUESTIONS ARE COMPULSURY.

More information

APS105. Pointers. Memory RAM 11/5/2013. Pointers. Need a way to refer to locations of things. a pointer: Address. Example: In C

APS105. Pointers. Memory RAM 11/5/2013. Pointers. Need a way to refer to locations of things. a pointer: Address. Example: In C APS105 Pointers Textbook Chapter5 1 A Broken Swap Example: a function to swap two values void swap(int x, int y) int temp = x; x = y; y = temp; int main() int a = 1, b = 2; swap(a,b); printf( %d %d\n,a,b);

More information

Answers to Practice Problems

Answers to Practice Problems Answers to Practice Problems Prepared by:dilip Kumar Gangwar(Faculty,CS/IT DEPTT GEHU) 1)C Language is developed by- 1.Bjarne stroutstrup 2.Dennis Ritchie 3.R.Byrant 4.None of the above 2)C is a a)middle

More information

C Programming Multiple. Choice

C Programming Multiple. Choice C Programming Multiple Choice Questions 1.) Developer of C language is. a.) Dennis Richie c.) Bill Gates b.) Ken Thompson d.) Peter Norton 2.) C language developed in. a.) 1970 c.) 1976 b.) 1972 d.) 1980

More information

The output will be: marks all or nothing. 1 #include <stdio.h> 2 main() { 3 int i; int j; 4 int *p; int *q; 6 p = &i; 7 q = &j; 8 i = 1;

The output will be: marks all or nothing. 1 #include <stdio.h> 2 main() { 3 int i; int j; 4 int *p; int *q; 6 p = &i; 7 q = &j; 8 i = 1; p. 2 of 9 Q1. [5 marks] The following program compiles and runs with no problems. Indicate what the output of the program is going to be (no explanation necessary). 1 #include 2 main() { 3 int

More information

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

From Java to C. Thanks to Randal E. Bryant and David R. O'Hallaron (Carnegie-Mellon University) for providing the basis for these slides From Java to C Thanks to Randal E. Bryant and David R. O'Hallaron (Carnegie-Mellon University) for providing the basis for these slides 1 Outline Overview comparison of C and Java Good evening Preprocessor

More information

COMPUTER APPLICATION

COMPUTER APPLICATION Total No. of Printed Pages 16 HS/XII/A.Sc.Com/CAP/14 2 0 1 4 COMPUTER APPLICATION ( Science / Arts / Commerce ) ( Theory ) Full Marks : 70 Time : 3 hours The figures in the margin indicate full marks for

More information

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

A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be

More information

[0569] p 0318 garbage

[0569] p 0318 garbage A Pointer is a variable which contains the address of another variable. Declaration syntax: Pointer_type *pointer_name; This declaration will create a pointer of the pointer_name which will point to the

More information

Answer 2.What will be printed as the result of the operation below: Answer 3.What will be printed as the result of the operation below:

Answer 2.What will be printed as the result of the operation below: Answer 3.What will be printed as the result of the operation below: 1.What will print out? main() char *p1= name ; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p2++ = *p1++); printf( %sn,p2); Answer:empty string. 2.What will be printed as the result of the

More information

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

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

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

C/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock) C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 By the end of this lecture, you will be able to identify the

More information

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

C/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 1 By the end of this lecture, you will be able to identify

More information

Variation of Pointers

Variation of Pointers Variation of Pointers A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before

More information

CMPE Experiment 3 Selective Structures

CMPE Experiment 3 Selective Structures Page1 CMPE 108 - Experiment 3 Selective Structures OBJECTIVES: Understand how to edit, compile and execute C computer codes. Understand C programming: sequential and selective structures NOTES: You should

More information

Functions in C C Programming and Software Tools

Functions in C C Programming and Software Tools Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the

More information

Practice Problems. 1)C Language is developed by- 1.Bjarne stroutstrup 2.Dennis Ritchie. 2)C is a a)middle level language b)high level language

Practice Problems. 1)C Language is developed by- 1.Bjarne stroutstrup 2.Dennis Ritchie. 2)C is a a)middle level language b)high level language Practice Problems Prepared by:dilip Kumar Gangwar(Faculty,CS/IT DEPTT GEHU) 1)C Language is developed by- 1.Bjarne stroutstrup 2.Dennis Ritchie 3.R.Byrant 4.None of the above 2)C is a a)middle level language

More information

FOR Loop. FOR Loop has three parts:initialization,condition,increment. Syntax. for(initialization;condition;increment){ body;

FOR Loop. FOR Loop has three parts:initialization,condition,increment. Syntax. for(initialization;condition;increment){ body; CLASSROOM SESSION Loops in C Loops are used to repeat the execution of statement or blocks There are two types of loops 1.Entry Controlled For and While 2. Exit Controlled Do while FOR Loop FOR Loop has

More information

Programming and Data Structure Solved. MCQs- Part 2

Programming and Data Structure Solved. MCQs- Part 2 Programming and Data Structure Solved MCQs- Part 2 Programming and Data Structure Solved MCQs- Part 2 Unsigned integers occupies Two bytes Four bytes One byte Eight byte A weather forecasting computation

More information

Pointers. Addresses in Memory. Exam 1 on July 18, :00-11:40am

Pointers. Addresses in Memory. Exam 1 on July 18, :00-11:40am Exam 1 on July 18, 2005 10:00-11:40am Pointers Addresses in Memory When a variable is declared, enough memory to hold a value of that type is allocated for it at an unused memory location. This is the

More information

UNIT III (PART-II) & UNIT IV(PART-I)

UNIT III (PART-II) & UNIT IV(PART-I) UNIT III (PART-II) & UNIT IV(PART-I) Function: it is defined as self contained block of code to perform a task. Functions can be categorized to system-defined functions and user-defined functions. System

More information

Tema 6: Dynamic memory

Tema 6: Dynamic memory Tema 6: Programming 2 and vectors defined with 2013-2014 and Index and vectors defined with and 1 2 3 and vectors defined with and and vectors defined with and Size is constant and known a-priori when

More information

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

Arrays in C. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur. Basic Concept Arrays in C Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur 1 Basic Concept Many applications require multiple data items that have common characteristics.

More information

Lecture 2: C Programm

Lecture 2: C Programm 0 3 E CS 1 Lecture 2: C Programm ing C Programming Procedural thought process No built in object abstractions data separate from methods/functions Low memory overhead compared to Java No overhead of classes

More information

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

Outline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C Lecture 1 C primer What we will cover A crash course in the basics of C You should read the K&R C book for lots more details Various details will be exemplified later in the course Outline Overview comparison

More information

More about BOOLEAN issues

More about BOOLEAN issues More about BOOLEAN issues Every boolean test is an implicit comparison against zero (0). However, zero is not a simple concept. It represents: the integer zero for all integral types the floating point

More information

MCAT113: Principles of Programming with C

MCAT113: Principles of Programming with C MCAT113: Principles of Programming with C Multiple choice questions UNIT I 1. After a programmer plans the logic of a program, she will next. a. understand the problem b. test the program c. translate

More information

Unit 7. Functions. Need of User Defined Functions

Unit 7. Functions. Need of User Defined Functions Unit 7 Functions Functions are the building blocks where every program activity occurs. They are self contained program segments that carry out some specific, well defined task. Every C program must have

More information

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

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015 CS 141 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015 You may take this test with you after the test, but you must turn in your answer sheet. This test has the following sections:

More information

Mechatronics and Microcontrollers. Szilárd Aradi PhD Refresh of C

Mechatronics and Microcontrollers. Szilárd Aradi PhD Refresh of C Mechatronics and Microcontrollers Szilárd Aradi PhD Refresh of C About the C programming language The C programming language is developed by Dennis M Ritchie in the beginning of the 70s One of the most

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

C Language, Token, Keywords, Constant, variable

C Language, Token, Keywords, Constant, variable C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C

More information

C LANGUAGE AND ITS DIFFERENT TYPES OF FUNCTIONS

C LANGUAGE AND ITS DIFFERENT TYPES OF FUNCTIONS C LANGUAGE AND ITS DIFFERENT TYPES OF FUNCTIONS Manish Dronacharya College Of Engineering, Maharishi Dayanand University, Gurgaon, Haryana, India III. Abstract- C Language History: The C programming language

More information

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

Lecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions Lecture 02 Summary C/Java Syntax Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 1 2 By the end of this lecture, you will be able to identify the

More information

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};

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}; Indian Institute of Technology Kharagpur Department of Computer Science & Engineering Programming & Data Structures (CS11001/CS13002) Autumn Semester 2009 Max. Time: 1 Hour Max. Marks: 50 Instructions:

More information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

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,

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, UNIT III 1. Which of the following cannot be value of the expression in switch case statement a. integer b. float c. char d. shortint 2. What will happen if we write semicolon after switch statement switch(choice);

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

Presented By : Gaurav Juneja

Presented By : Gaurav Juneja Presented By : Gaurav Juneja Introduction C is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs of UNIX are written

More information

ESC101N: Fundamentals of Computing End-sem st semester

ESC101N: Fundamentals of Computing End-sem st semester ESC101N: Fundamentals of Computing End-sem 2010-11 1st semester Instructor: Arnab Bhattacharya 8:00-11:00am, 15th November, 2010 Instructions 1. Please write your name, roll number and section below. 2.

More information

Final Intro to C Review

Final Intro to C Review Final Exam Content: Final Intro to C Review - Pass by reference Functions - General Syntax - Structures - Recursion(maybe?) - Programming by nature is cumulative so any past material is up for grabs as

More information

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

CS 61C: Great Ideas in Computer Architecture Introduction to C CS 61C: Great Ideas in Computer Architecture Introduction to C Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/ 1 Agenda C vs. Java vs. Python Quick Start Introduction

More information

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be

More information

A brief intro to pointers for the purposes of passing reference parameters

A brief intro to pointers for the purposes of passing reference parameters A brief intro to pointers for the purposes of passing reference parameters With respect to functions, we have only talked about pass by value parameters. Today we will discuss pass by reference parameters.

More information

Contents Lecture 3. C Preprocessor, Chapter 11 Declarations, Chapter 8. Jonas Skeppstedt Lecture / 44

Contents Lecture 3. C Preprocessor, Chapter 11 Declarations, Chapter 8. Jonas Skeppstedt Lecture / 44 Contents Lecture 3 C Preprocessor, Chapter 11 Declarations, Chapter 8 Jonas Skeppstedt (js@cs.lth.se) Lecture 3 2014 1 / 44 C Preprocessor Predefined macros Macro replacement Conditional inclusion Source

More information

LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE

LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE Department of Software The University of Babylon LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE By Dr. Samaher Hussein Ali Collage of Information Technology, University of Babylon, Iraq Samaher_hussein@yahoo.com

More information

Advanced Pointer Topics

Advanced Pointer Topics Advanced Pointer Topics Pointers to Pointers A pointer variable is a variable that takes some memory address as its value. Therefore, you can have another pointer pointing to it. int x; int * px; int **

More information

Consider the following statements. string str1 = "ABCDEFGHIJKLM"; string str2; After the statement str2 = str1.substr(1,4); executes, the value of str2 is " ". Given the function prototype: float test(int,

More information

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please

More information

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions.

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions. 1 of 22 8/4/2018, 4:03 PM Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008

More information

Compiling and Running a C Program in Unix

Compiling and Running a C Program in Unix CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 95 ] Compiling and Running a C Program in Unix Simple scenario in which your program is in a single file: Suppose you want to name

More information

Midterm Exam Answers Instructor: Randy Shepherd CSCI-UA.0201 Spring 2017

Midterm Exam Answers Instructor: Randy Shepherd CSCI-UA.0201 Spring 2017 Section 1: Multiple choice (select any that apply) - 20 points 01. Representing 10 using the 4 byte unsigned integer encoding and using 4 byte two s complements encoding yields the same bit pattern. (a)

More information