Sample Question Set For Coding and Debugging

Size: px
Start display at page:

Download "Sample Question Set For Coding and Debugging"

Transcription

1 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) 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

2 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

3 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 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 *)0x ; int huge *b=(int huge *)0x ; if(a==b) printf("velammal Institute of Technology"); else printf("cse"); 3

4 a)velammal Institute of Technology b)cse c)csecse d)compilation error e)none of the above 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

5 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

6 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) b) c) d)compilaion error e)none of the above 18.What will be output of following program? #include<conio.h> 6

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

8 printf("%d", c); (A) 1 (B) 5 (C) 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 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);

10 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 *)0x ; char far *q =(char far *)0x ; *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

11 printf( %u %u %u,i,j,k); (A) 3 Address 3 (B) 3 Address Address (C) 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

12 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)

13 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) 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) c) error d) How many times the following program will print "hello"? printf("hello"); main(); a) 1 b) 2 13

14 c) infinite number of times d) none of these 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) 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) What will be the output of following program? printf("%d"); a) error b) no output c) %d d) 0 14

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

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

(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

Latest R Systems Placement Test Questions

Latest R Systems Placement Test Questions APTITUDE: Q1. At a special sale, 5 tickets can be purchased for the price of 3 tickets. If 5 tickets are purchased at the sale, the amount saved will be what percent of the original price of the 5 tickets?

More information

C aptitude interview questions

C aptitude interview questions C aptitude interview questions What is the output of following C programs? 1) clrscr(); clrscr(); No output/error The first clrscr() occurs inside a function. So it becomes a function call. In the second

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

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

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

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

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

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

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

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

S.Purushothaman M.Sc.,B.Ed. WhatsApp 1 S.Purushothaman M.Sc.,B.Ed. WhatsApp-9944041212 2 Table Of content Basics of C Language 1. Overview of C 2. Features of C 3. My First C program 4. C Input / Output 5. C Syntax Rules 6. Keywords and Identifier

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

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

Tutorial 10 Pointers in C. Shuyue Hu

Tutorial 10 Pointers in C. Shuyue Hu Tutorial 10 Pointers in C Shuyue Hu Content Basic concept of pointers Pointer arithmetic Array of pointers Pointer to pointer Passing pointers to functions in C Return pointer from functions in C 2 Content

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

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

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);! Section - Computer Science 1. What will be the output of the following piece of code? int! 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);! return 1; (i) A: 10, B:

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

C - Basics, Bitwise Operator. Zhaoguo Wang

C - Basics, Bitwise Operator. Zhaoguo Wang C - Basics, Bitwise Operator Zhaoguo Wang Java is the best language!!! NO! C is the best!!!! Languages C Java Python 1972 1995 2000 (2.0) Procedure Object oriented Procedure & object oriented Compiled

More information

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

2. C99 standard guarantees uniqueness of characters for internal names. A. 12 B. 26 C. 31 D. 48 1. How can you make an infinite loop in C? A. while(1) { } B. loop:... goto loop; C. for(;;) { } D. All answers are right 2. C99 standard guarantees uniqueness of characters for internal names. A. 12 B.

More information

C Programming Language

C Programming Language Third Year Diploma Courses in Electronics, Electronics & telecommunications Engineering Branch. C Programming Language As per MSBTE I Scheme Syllabus CPR-22218 Topic 5 Pointers Total Marks- 10 Contents:

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

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

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify

More information

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE COURSE TITLE C LANGUAGE DETAILED SYLLABUS SR.NO NAME OF CHAPTERS & DETAILS HOURS ALLOTTED 1 INTRODUCTION TO C LANGUAGE About C Language Advantages of C Language Disadvantages of C Language A Sample Program

More information

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

Pointer in C SHARDA UNIVERSITY. Presented By: Pushpendra K. Rajput Assistant Professor Pointer in C Presented By: Pushpendra K. Rajput Assistant Professor 1 Introduction The Pointer is a Variable which holds the Address of the other Variable in same memory. Such as Arrays, structures, and

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 9 Pointer Department of Computer Engineering 1/46 Outline Defining and using Pointers

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

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

MCA Semester 1. MC0061 Computer Programming C Language 4 Credits Assignment: Set 1 (40 Marks) Summer 2012 MCA Semester 1 4 Credits Assignment: Set 1 (40 Marks) Q1. Explain the following operators with an example for each: a. Conditional Operators b. Bitwise Operators c. gets() and puts() function

More information

Section - Computer Science

Section - Computer Science Section - Computer Science 1. With respect to the C++ programming language, which is the parameter that is added to every non-static member function when it is called? (i) this pointer (ii) that pointer

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

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

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

Chapter 6. Data Structure. /* start contains the address of the first node */ start = &elephant1; print_elephants( start ); return EXIT_SUCCESS; Chapter 6 Data Structure Introductory notes are included in PowerPoint file. The programs illustrated are as follows: //elephnt1.c // This example is from C for Scientists and Engineers #include

More information

Fundamentals of Programming Session 19

Fundamentals of Programming Session 19 Fundamentals of Programming Session 19 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines

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

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

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park Variables in C CMSC 104, Fall 2012 John Y. Park 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What Are Variables in C? Variables in C have the

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

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

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

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

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

Trắc nghiệm lập trình C Title : Trắc nghiệm lập trình C Author : Vu Hong Viet Date : 07/09/2014 Các câu hỏi trắc nghiệm được thành viên diễn đàn vncoding sưu tập và biên soạn dựa trên quá trình học tập và kinh nghiệm thực tế.

More information

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

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04 Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Topic: Arrays and Strings Practice Sheet #04 Date: 24-01-2017 Instructions: For the questions consisting code segments,

More information

Low-Level C Programming. Memory map Pointers Arrays Structures

Low-Level C Programming. Memory map Pointers Arrays Structures Low-Level C Programming Memory map Pointers Arrays Structures Memory Map 0x7FFF_FFFF Binaries load at 0x20000 by default Stack start set by binary when started Stack grows downwards You will need one stack

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

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

Week 3 Lecture 2. Types Constants and Variables

Week 3 Lecture 2. Types Constants and Variables Lecture 2 Types Constants and Variables Types Computers store bits: strings of 0s and 1s Types define how bits are interpreted They can be integers (whole numbers): 1, 2, 3 They can be characters 'a',

More information

Programming in C - Part 2

Programming in C - Part 2 Programming in C - Part 2 CPSC 457 Mohammad Reza Zakerinasab May 11, 2016 These slides are forked from slides created by Mike Clark Where to find these slides and related source code? http://goo.gl/k1qixb

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

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

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

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine

More information

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

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

More information

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

MIDTERM TEST EESC 2031 Software Tools June 13, Last Name: First Name: Student ID: EECS user name: TIME LIMIT: 110 minutes MIDTERM TEST EESC 2031 Software Tools June 13, 2017 Last Name: First Name: Student ID: EECS user name: TIME LIMIT: 110 minutes This is a closed-book test. No books and notes are allowed. Extra space for

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

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

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

Jagannath Institute of Management Sciences Lajpat Nagar. BCA II Sem. C Programming Jagannath Institute of Management Sciences Lajpat Nagar BCA II Sem C Programming UNIT I Pointers: Introduction to Pointers, Pointer Notation,Decalaration and Initialization, Accessing variable through

More information

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

CMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso CMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso 1 Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 a + b Variables are notthe same thing as variables in algebra.

More information

C Programming Review CSC 4320/6320

C Programming Review CSC 4320/6320 C Programming Review CSC 4320/6320 Overview Introduction C program Structure Keywords & C Types Input & Output Arrays Functions Pointers Structures LinkedList Dynamic Memory Allocation Macro Compile &

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

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

F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1 (a) List any four relational operators.

More information

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

EE 312 Fall 2018 Midterm 1 Version A October 10, 2018 EE 312 Fall 2018 Midterm 1 Version A October 10, 2018 I promise that all work on this exam is my own, that I have not received assistance on it, and that I am adhering to the University's honor code. Name:

More information

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

cout << How many numbers would you like to type? ; cin >> memsize; p = new int[memsize]; 1 C++ Dynamic Allocation Memory needs were determined before program execution by defining the variables needed. Sometime memory needs of a program can only be determined during runtime, or the memory

More information

High Performance Programming Programming in C part 1

High Performance Programming Programming in C part 1 High Performance Programming Programming in C part 1 Anastasia Kruchinina Uppsala University, Sweden April 18, 2017 HPP 1 / 53 C is designed on a way to provide a full control of the computer. C is the

More information

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

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto Adapted from the slides Revisões sobre Programação em C, Sérgio Crisóstomo Compilation #include int main()

More information

Fundamentals of Programming Session 20

Fundamentals of Programming Session 20 Fundamentals of Programming Session 20 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines

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

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

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA. DECLARATIONS Character Set, Keywords, Identifiers, Constants, Variables Character Set C uses the uppercase letters A to Z. C uses the lowercase letters a to z. C uses digits 0 to 9. C uses certain Special

More information

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

Variables in C. CMSC 104, Spring 2014 Christopher S. Marron. (thanks to John Park for slides) Tuesday, February 18, 14 Variables in C CMSC 104, Spring 2014 Christopher S. Marron (thanks to John Park for slides) 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What

More information

Dynamic Memory Allocation

Dynamic Memory Allocation Dynamic Memory Allocation The process of allocating memory at run time is known as dynamic memory allocation. C does not Inherently have this facility, there are four library routines known as memory management

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Syntax and Variables

Syntax and Variables Syntax and Variables What the Compiler needs to understand your program, and managing data 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line

More information

ET156 Introduction to C Programming

ET156 Introduction to C Programming ET156 Introduction to C Programming Unit 1 INTRODUCTION TO C PROGRAMMING: THE C COMPILER, VARIABLES, MEMORY, INPUT, AND OUTPUT Instructor : Stan Kong Email : skong@itt tech.edutech.edu Figure 1.3 Components

More information

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

1d: tests knowing about bitwise fields and union/struct differences. Question 1 1a: char ptr[] = Hello World ; char a = ptr[1], b = *(ptr+6); Creates an array of 12 elements, 11 visible letters and a character value 0 at the end. i true ii true iii false iv false v true

More information

Storage class and Scope:

Storage class and Scope: Algorithm = Logic + Control + Data Data structures and algorithms Data structures = Ways of systematically arranging information, both abstractly and concretely Algorithms = Methods for constructing, searching,

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture Arrays, Strings, and Some More Pointers June 24, 2014 Review of Last Lecture C Basics Variables, functioss, control flow, types, structs Only 0 and NULL evaluate to false Pointers hold addresses Address

More information

CS349/SE382 A1 C Programming Tutorial

CS349/SE382 A1 C Programming Tutorial CS349/SE382 A1 C Programming Tutorial Erin Lester January 2005 Outline Comments Variable Declarations Objects Dynamic Memory Boolean Type structs, enums and unions Other Differences The Event Loop Comments

More information

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( End Semester ) SEMESTER ( Spring ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming

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

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

1. If you declare within a function: It retains the value between function calls 1. What is C language? The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since

More information

C PROGRAMMING Lecture 4. 1st semester

C PROGRAMMING Lecture 4. 1st semester C PROGRAMMING Lecture 4 1st semester 2017-2018 Structures Structure: Collection of one or more variables a tool for grouping heterogeneous elements together (different types) Array: a tool for grouping

More information

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

Princeton University COS 333: Advanced Programming Techniques A Subset of C90 Princeton University COS 333: Advanced Programming Techniques A Subset of C90 Program Structure /* Print "hello, world" to stdout. Return 0. */ { printf("hello, world\n"); -----------------------------------------------------------------------------------

More information

Department of Computer Applications

Department of Computer Applications Sheikh Ul Alam Memorial Degree College Mr. Ovass Shafi. (Assistant Professor) C Language An Overview (History of C) C programming languages is the only programming language which falls under the category

More information

Character Strings. String-copy Example

Character Strings. String-copy Example Character Strings No operations for string as a unit A string is just an array of char terminated by the null character \0 The null character makes it easy for programs to detect the end char s[] = "0123456789";

More information

Memory Allocation. General Questions

Memory Allocation. General Questions General Questions 1 Memory Allocation 1. Which header file should be included to use functions like malloc() and calloc()? A. memory.h B. stdlib.h C. string.h D. dos.h 2. What function should be used to

More information

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?

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? Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? The heterogeneous linked list contains different data types in its nodes and we need a link

More information

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

Operating Systems 2INC0 C course Pointer Advanced. Dr. Ir. Ion Barosan Operating Systems 2INC0 C course Pointer Advanced Dr. Ir. Ion Barosan (i.barosan@tue.nl) Containt Pointers Definition and Initilization Ponter Operators Pointer Arithmetic and Array Calling Functions by

More information

PROGRAMMAZIONE I A.A. 2017/2018

PROGRAMMAZIONE I A.A. 2017/2018 PROGRAMMAZIONE I A.A. 2017/2018 A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. DECLARING POINTERS POINTERS A pointer represents both

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

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

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

CMPE-013/L. Introduction to C Programming

CMPE-013/L. Introduction to C Programming CMPE-013/L Introduction to C Programming Bryant Wenborg Mairs Spring 2014 What we will cover in 13/L Embedded C on a microcontroller Specific issues with microcontrollers Peripheral usage Reading documentation

More information

C++ 8. Constructors and Destructors

C++ 8. Constructors and Destructors 8. Constructors and Destructors C++ 1. When an instance of a class comes into scope, the function that executed is. a) Destructors b) Constructors c) Inline d) Friend 2. When a class object goes out of

More information

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

#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0; 1. Short answer questions: (a) Compare the typical contents of a module s header file to the contents of a module s implementation file. Which of these files defines the interface between a module and

More information

Unit IV & V Previous Papers 1 mark Answers

Unit IV & V Previous Papers 1 mark Answers 1 What is pointer to structure? Pointer to structure: Unit IV & V Previous Papers 1 mark Answers The beginning address of a structure can be accessed through the use of the address (&) operator If a variable

More information

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

Pointers. Mr. Ovass Shafi (Assistant Professor) Department of Computer Applications Pointers Introduction: A variable is a named memory location that holds some value. Each variable has some address associated with it. Till now we only worked on the values stored in the variables and

More information

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

The Nifty Way to Call Hell from Heaven ANDREAS LÖSCHER AND KONSTANTINOS SAGONAS UPPSAL A UNIVERSIT Y The Nifty Way to Call Hell from Heaven ANDREAS LÖSCHER AND KONSTANTINOS SAGONAS UPPSAL A UNIVERSIT Y There is a lot of C Code out there C Erlang Source: www.langpop.com (Normalized statistic) How can we

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

Lecture 3. Variables. Variables

Lecture 3. Variables. Variables Lecture 3 Variables Variables Data processed by programs are input from keyboard by user, are read from the storage medium or are obtained by evaluating expressions. For this purpose it is necessary to

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

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

UNIT-IV. Structure is a user-defined data type in C language which allows us to combine data of different types together. UNIT-IV Unit 4 Command Argument line They are parameters/arguments supplied to the program when it is invoked. They are used to control program from outside instead of hard coding those values inside the

More information

Prepared by: Shraddha Modi

Prepared by: Shraddha Modi Prepared by: Shraddha Modi Introduction Operator: An operator is a symbol that tells the Computer to perform certain mathematical or logical manipulations. Expression: An expression is a sequence of operands

More information

AMCAT Automata Coding Sample Questions And Answers

AMCAT Automata Coding Sample Questions And Answers 1) Find the syntax error in the below code without modifying the logic. #include int main() float x = 1.1; switch (x) case 1: printf( Choice is 1 ); default: printf( Invalid choice ); return

More information