Essar Placement Paper

Size: px
Start display at page:

Download "Essar Placement Paper"

Transcription

1 Essar Placement Paper Question 1 The fourth proportional to 5, 8, 15 is: A. 18 B. 24 C. 19 D. 20 Let the fourth proportional to 5, 8, 15 be x. Then, 5 : 8 : 15 : x 5x = (8 x 15) x=(8*15)/5=24 Question 2 If 40% of a number is equal to two-third of another number, what is the ratio of first number to the second number? A. 2 : 5 B. 3 : 7 C. 5 : 3 D. 7 : 3 Ans. C Let 40% of A=2/3 B Then,40 A/100=2B/3 => 2A/5=2B/3 => A/B-[2/3-5/2]=5/3p A : B = 5 : 3. Question 3 The salaries A, B, C are in the ratio 2 : 3 : 5. If the increments of 15%, 10% and 20% are allowed respectively in their salaries, then what will be new ratio of their salaries?

2 A. 3 : 3 : 10 B. 10 : 11 : 20 C. 23:33:60 D. 32 :43:53 Ans. C Let A = 2k, B = 3k and C = 5k. A's new salary = 115/ 100 of 2k =[115/ 100 x 2k]= 23k/ 10 B's new salary = 110/ 100 of 3k = [110/ 100x 3k] = 33k/ 10 C's new salary = 120/ 100 of 5k = [120/ 100 x 5k] = 6k New ratio = 23k : 33k : 6k = 23 : 33 : 60 Question 4 A bag contains 6 black and 8 white balls. One ball is drawn at random. What is the probability that the ball drawn is white? A. 3/4 B. 4/7 C. 1/8 D. 3/7 Let number of balls = (6 + 8) = 14. Number of white balls = 8. P (drawing a white ball)=8/14=4/7 Question 5 One card is drawn at random from a pack of 52 cards. What is the probability that the card drawn is a face card? A. 1/13 B. 3/13 C. 1/4

3 D. 9/5 Clearly, there are 52 cards, out of which there are 12 face cards. P (getting a face card)=12/52=3/13 Question 6 Two cards are drawn together from a pack of 52 cards. The probability that one is a spade and one is a heart, is: A. 3 /20 B. 29/ 34 C. 47/ 100 D. 13 /102 Ans. D Let S be the sample space. Then, n(s) = 52C2 = 52 * 51/ (2*1)= Let E = event of getting 1 spade and 1 heart. n(e) = number of ways of choosing 1 spade out of 13 and 1 heart out of 13 = (13C1 x 13C1) = (13 x 13) = 169. P(E) =n (E)/n(S) = 169/ 1326= 13/102 Question 7 A bag contains 4 white, 5 red and 6 blue balls. Three balls are drawn at random from the bag. The probability that all of them are red, is: A. 1/ 22 B. 3/ 22 C. 2/ 91 D. 2/ 81

4 Ans. C Let S be the sample space. Then, n(s)= number of ways of drawing 3 balls out of 15 = 15C3 = (15 x 14 x 13)/ (3 x 2 x 1) = 455. Let E = event of getting all the 3 red balls. n(e) = 5C3 = 5C2 = (5 x 4)/ (2 x 1)= 10. P(E) = n(e) / n(s)= 10/ 455 = 2/ 91 Question 8 A card is drawn from a pack of 52 cards. The probability of getting a queen of club or a king of heart is: A. 1 /13 B. 2 /13 C. 1 /26 D. 1 /52 Ans. C Here, n(s) = 52. Let E = event of getting a queen of club or a king of heart. Then, n(e) = 2. P(E) =n(e)/ n(s)= 2/ 52= 1/ 26 Question 9 Two number are in the ratio 3 : 5. If 9 is subtracted from each, the new numbers are in the ratio 12 : 23. The smaller number is: A. 27 B. 33 C. 49 D. 55

5 Let the numbers be 3x and 5x. Then,(3x-9)/(5x-9)=12/13 23(3x - 9) = 12(5x - 9) 9x = 99 x = 11. The smaller number = (3 x 11) = 33. Question 10 In a bag, there are coins of 25 p, 10 p and 5 p in the ratio of 1 : 2 : 3. If there is Rs. 30 in all, how many 5 p coins are there? A. 50 B. 100 C. 150 D. 200 Ans. C Let the number of 25 p, 10 p and 5 p coins be x, 2x, 3x respectively. Then, sum of their values=rs[(25x/100)+(10*2x)/100+(5*3x)/100]=rs 60x/100 60x/100=30 =>x=(30*100)/60=50 Hence, the number of 5 p coins = (3 x 50) = 150. Question 11 B2CD,, BCD4, B5CD, BC6D A. B2C2D B. BC3D C. B2C3D D. BCD7

6 Because the letters are the same, concentrate on the number series, which is a simple 2, 3, 4, 5, 6 series, and follows each letter in order. Question 12 DEF, DEF2, DE2F2,, D2E2F3 A. DEF3 B. D3EF3 C. D2E3F D. D2E2F2 Ans. D In this series, the letters remain the same: DEF. The subscript numbers follow this series: 111, 112, 122, 222, 223, 233, 333,... Question women can complete a work in 7 days and 10 children take 14 days to complete the work. How many days will 5 women and 10 children take to complete the work? A. 3 B. 5 C. 7 D. Cannot be determined Ans. C

7 1 woman's 1 day's work=1/70 1 child's 1 day's work =1/140 (5 women + 10 children)'s day's work =5/70 +10/140=1/14 +1/14=1/7 5 women and 10 children will complete the work in 7 days. Question 14 A alone can do a piece of work in 6 days and B alone in 8 days. A and B undertook to do it for Rs With the help of C, they completed the work in 3 days. How much is to be paid to C? A. Rs. 375 B. Rs. 400 C. Rs. 600 D. Rs. 800 C's 1 day's work = 1/3 - [1/6 + 1/8]= 1/3-7/24= 1/24 A's wages : B's wages : C's wages = 1/6: 1/8: 1/24= 4 : 3 : 1. C's share (for 3 days) = Rs.[3 x 1/24 x 3200] = Rs Question 15 The product of two numbers is 9375 and the quotient, when the larger one is divided by the smaller, is 15. The sum of the numbers is: A. 380 B. 395 C. 400 D. 425 Ans. C Let the numbers be x and y. Then, xy = 9375 and x/y=15 Xy/(x/y)=9375/15 y2 = 625. y = 25. x = 15y = (15 x 25) = 375. Sum of the numbers = x + y = = 400.

8 Question 16 The length of a rectangle is halved, while its breadth is tripled. What is the percentage change in area? A. 25% increase B. 50% increase C. 50% decrease D. 75% decrease Let original length = x and original breadth = y. Original area = xy. New length =x/2 New breadth = 3y. New area=[(x/2)*3y]=(3/2)xy Increase % =[(1/2)xy*(1/xy)*100]%=50% Question 17 The difference between the length and breadth of a rectangle is 23 m. If its perimeter is 206 m, then its area is: A m2 B m2 C m2 D m2 Ans. D We have: (l - b) = 23 and 2(l + b) = 206 or (l + b) = 103. Solving the two equations, we get: l = 63 and b = 40. Area = (l x b) = (63 x 40) m2 = 2520 m2.

9 Question 18 In a certain school, 20% of students are below 8 years of age. The number of students above 8 years of age is 2/3 of the number of students of 8 years age which is 48. What is the total number of students in the school? A. 72 B. 80 C. 120 D. 100 Ans. D Question 19 Point out the error in the program? struct emp char name[20]; float sal; ; struct emp e[10]; int i; for(i=0; i<=9; i++) scanf("%s %f", e[i].name, &e[i].sal); A. Error: invalid structure member B. Error: Floating point formats not linked C. No error

10 D. None of above At run time it will show an error then program will be terminated. Sample output: Turbo C (Windwos) Sample scanf : floating point formats not linked Abnormal program termination Question 20 Point out the error in the program? struct emp char name[20]; float sal; ; struct emp e[10]; int i; for(i=0; i<=9; i++) scanf("%s %f", e[i].name, &e[i].sal); A. Error: invalid structure member B. Error: Floating point formats not linked C. No error D. None of above At run time it will show an error then program will be terminated. Sample output: Turbo C (Windwos) c:\>myprogram Sample scanf : floating point formats not linked Abnormal program termination

11 Question 21 What will be the output of the program? char p[] = "%d\n"; p[1] = 'c'; printf(p, 65); A. A B. a C. c D. 65 Ans. A Step 1: char p[] = "%d\n"; The variable p is declared as an array of characters and initialized with string "%d" Step 2: p[1] = 'c'; Here, we overwrite the second element of array p by 'c'. So array p becomes "%c". Step 3: printf(p, 65); becomes printf("%c", 65); Therefore it prints the ASCII value of 65. The output is 'A'. Question 22 What will be the output of the program?

12 char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); A. Hello B. World C. Hello World D. WorldHello Ans. C Step 1: char str1[20] = "Hello", str2[20] = " World"; The variable str1and str2 is declared as an array of characters and initialized with value "Hello" and " World" respectively. Step 2: printf("%s\n", strcpy(str2, strcat(str1, str2))); => strcat(str1, str2)) it append the string str2 to str1. The result will be stored in str1. Therefore str1 contains "Hello World". => strcpy(str2, "Hello World") it copies the "Hello World" to the variablestr2. Hence it prints "Hello World". Question 23 Point out the error in the program int i; #if A printf("enter any number:"); scanf("%d", &i); #elif B printf("the number is odd"); A. Error: unexpected end of file because there is no matching #endif B. The number is odd

13 C. Garbage values D. None of above Ans. A The conditional macro #if must have an #endif. In this program there is no#endif statement written. Question 24 Point out the error in the program #define SI(p, n, r) float si; si=p*n*r/100; float p=2500, r=3.5; int n=3; SI(p, n, r); SI(1500, 2, 2.5); A B. Nothing will print C. Error: Multiple declaration of si D. Garbage values Ans. C The macro #define SI(p, n, r) float si; si=p*n*r/100; contains the error. To remove this error, we have to modify this macro to #define SI(p,n,r) p*n*r/100

14 Question 25 What will be the output of the program? float d=2.25; printf("%e,", d); printf("%f,", d); printf("%g,", d); printf("%lf", d); A. 2.2, 2.50, 2.50, 2.5 B. 2.2e, 2.25f, 2.00, 2.25 C e+000, , 2.25, D. error Ans. C printf("%e,", d); Here '%e' specifies the "Scientific Notation" format. So, it prints the 2.25 as e+000. printf("%f,", d); Here '%f' specifies the "Decimal Floating Point" format. So, it prints the 2.25 as printf("%g,", d); Here '%g' "Use the shorter of %e or %f". So, it prints the 2.25 as printf("%lf,", d); Here '%lf' specifies the "Long Double" format. So, it prints the 2.25 as Question 26 What will be the output of the program?

15 float n=1.54; printf("%f, %f\n", ceil(n), floor(n)); A , B , C , D , Ans. A ceil(x) round up the given value. It finds the smallest integer not < x. floor(x) round down the given value. It finds the smallest integer not > x. printf("%f, %f\n", ceil(n), floor(n)); In this line ceil(1.54) round up the 1.54 to 2 and floor(1.54) round down the 1.54 to 1. In the printf("%f, %f\n", ceil(n), floor(n)); statement, the format specifier "%f %f" tells output to be float value. Hence it prints and Question 27 What will be the output of the program? float a=0.7; if(a < 0.7f) printf("c\n"); else printf("c++\n"); A. C B. C++

16 C. Compiler error D. Non of above if(a < 0.7f) here a is a float variable and 0.7f is a float constant. The float variable a is not less than 0.7f float constant. But both are equal. Hence the ifcondition is failed and it goes to else it prints 'C++' Question 28 What will be the output of the program? float f=43.20; printf("%e, ", f); printf("%f, ", f); printf("%g", f); A e+01, , 43.2 B. 4.3, 43.22, C. 4.3e, 43.20f, D. Error Ans. A printf("%e, ", f); Here '%e' specifies the "Scientific Notation" format. So, it prints the as e+01. printf("%f, ", f); Here '%f' specifies the "Decimal Floating Point" format. So, it prints

17 the as printf("%g, ", f); Here '%g' "Use the shorter of %e or %f". So, it prints the as Question 29 If the size of an integer is 4 bytes, What will be the output of the program? printf("%d\n", strlen("123456")); A. 6 B. 12 C. 7 D. 2 Ans. A The function strlen returns the number of characters int the given string. Therefore, strlen("123456") contains 6 characters. The output of the program is "6". Question 30 What will be the output of the program?

18 int arr[5], i=0; while(i<5) arr[i]=++i; for(i=0; i<5; i++) printf("%d, ", arr[i]); A. 1, 2, 3, 4, 5, B. Garbage value, 1, 2, 3, 4, C. 0, 1, 2, 3, 4, D. 2, 3, 4, 5, 6, Since C is a compiler dependent language, it may give different outputs at different platforms. We have given the TurboC Compiler (Windows) output. Please try the above programs in Windows (Turbo-C Compiler) and Linux (GCC Compiler), you will understand the difference better.

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:

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: 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: ( )1 /13 ( )2 /13 ( )1 /26 ( )1 /52 Here, n(s) = 52. Let E = event of getting

More information

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

Huawei Test 5. Explanation: P.W. of Rs. 12,880 due 8 months hence=rs. [ (12880*100)/(100+(18*(8/12)))] Huawei Test 5 1 A man wants to sell his scooter. There are two offers, one at Rs. 12,000 cash and the other a credit of Rs. 12,880 to be paid after 8 months, money being at 18% per annum. Which is the

More information

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

Arrays. Example: Run the below program, it will crash in Windows (TurboC Compiler) 1 Arrays General Questions 1. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? A. The element will be set to 0. B. The compiler would

More information

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

Huawei Test 2. 1 Two dice are thrown simultaneously. What is the probability of getting two numbers whose product is even? Huawei Test 2 1 Two dice are thrown simultaneously. What is the probability of getting two numbers whose product is even? ( )1/ 2 ( )3/4 ( )3/8 ( )5/16 Explanation: In a simultaneous throw of two dice,

More information

Data types, variables, constants

Data types, variables, constants Data types, variables, constants Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic in C 2.6 Decision

More information

Write a C program using arrays and structure

Write a C program using arrays and structure 03 Arrays and Structutes 3.1 Arrays Declaration and initialization of one dimensional, two dimensional and character arrays, accessing array elements. (10M) 3.2 Declaration and initialization of string

More information

COMP 2001/2401 Test #1 [out of 80 marks]

COMP 2001/2401 Test #1 [out of 80 marks] COMP 2001/2401 Test #1 [out of 80 marks] Duration: 90 minutes Authorized Memoranda: NONE Note: for all questions, you must show your work! Name: Student#: 1. What exact shell command would you use to:

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

Question Bank (SPA SEM II)

Question Bank (SPA SEM II) Question Bank (SPA SEM II) 1. Storage classes in C (Refer notes Page No 52) 2. Difference between function declaration and function definition (This question is solved in the note book). But solution is

More information

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants Data types, variables, constants Outline.1 Introduction. Text.3 Memory Concepts.4 Naming Convention of Variables.5 Arithmetic in C.6 Type Conversion Definition: Computer Program A Computer program is a

More information

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

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size]; Arrays An array is a collection of two or more adjacent memory cells, called array elements. Array is derived data type that is used to represent collection of data items. C Array is a collection of data

More information

Integer Representation. Variables. Real Representation. Integer Overflow/Underflow

Integer Representation. Variables. Real Representation. Integer Overflow/Underflow Variables Integer Representation Variables are used to store a value. The value a variable holds may change over its lifetime. At any point in time a variable stores one value (except quantum computers!)

More information

Structured programming

Structured programming Exercises 2 Version 1.0, 22 September, 2016 Table of Contents 1. Simple C program structure................................................... 1 2. C Functions..................................................................

More information

16.216: ECE Application Programming Fall 2013

16.216: ECE Application Programming Fall 2013 16.216: ECE Application Programming Fall 2013 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

Arrays Arrays and pointers Loops and performance Array comparison Strings. John Edgar 2

Arrays Arrays and pointers Loops and performance Array comparison Strings. John Edgar 2 CMPT 125 Arrays Arrays and pointers Loops and performance Array comparison Strings John Edgar 2 Python a sequence of data access elements with [index] index from [0] to [len-1] dynamic length heterogeneous

More information

Introduction to Programming

Introduction to Programming Introduction to Programming Lecture 5: Interaction Interaction Produce output Get input values 2 Interaction Produce output Get input values 3 Printing Printing messages printf("this is message \n"); Printing

More information

Chapter 5. Section 5.4 The Common String Library Functions. CS 50 Hathairat Rattanasook

Chapter 5. Section 5.4 The Common String Library Functions. CS 50 Hathairat Rattanasook Chapter 5 Section 5.4 The Common String Library Functions CS 50 Hathairat Rattanasook Library Functions We already discussed the library function fgets() Library functions are available: to find the length

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

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out COMP1917: Computing 1 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. COMP1917 15s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write down a proposed solution Break

More information

The Hyderabad Public School, Begumpet, Hyderabad, A.P

The Hyderabad Public School, Begumpet, Hyderabad, A.P The Hyderabad Public School, Begumpet, Hyderabad, A.P. 500 016 2012-13 Department of Computer Science Class 8 Worksheet 3 1) How many times will the following statement execute? ( ) int a=5; while(a>6)

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

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out REGZ9280: Global Education Short Course - Engineering 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. REGZ9280 14s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write

More information

1. The keyword main in C language is used for

1. The keyword main in C language is used for 1. The keyword main in C language is used for a. an user defined function *b. the first function to be executed in the program c. an user defined variable 2. The role of a C compiler is to translate a.

More information

MA 511: Computer Programming Lecture 3: Partha Sarathi Mandal

MA 511: Computer Programming Lecture 3: Partha Sarathi Mandal MA 511: Computer Programming Lecture 3: http://www.iitg.ernet.in/psm/indexing_ma511/y10/index.html Partha Sarathi Mandal psm@iitg.ernet.ac.in Dept. of Mathematics, IIT Guwahati Semester 1, 2010-11 Last

More information

LOOPS. 1- Write a program that prompts user to enter an integer N and determines and prints the sum of cubes from 5 to N (i.e. sum of 5 3 to N 3 ).

LOOPS. 1- Write a program that prompts user to enter an integer N and determines and prints the sum of cubes from 5 to N (i.e. sum of 5 3 to N 3 ). LOOPS 1- Write a program that prompts user to enter an integer N and determines and prints the sum of cubes from 5 to N (i.e. sum of 5 3 to N 3 ). 2-Give the result of the following program: #include

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

Single Dimension Arrays

Single Dimension Arrays ARRAYS Single Dimension Arrays Array Notion of an array Homogeneous collection of variables of same type. Group of consecutive memory locations. Linear and indexed data structure. To refer to an element,

More information

Library Functions. General Questions

Library Functions. General Questions 1 Library Functions General Questions 1. What will the function rewind() do? A. Reposition the file pointer to a character reverse. B. Reposition the file pointer stream to end of file. C. Reposition the

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

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

Structured programming. Exercises 3

Structured programming. Exercises 3 Exercises 3 Table of Contents 1. Reminder from lectures...................................................... 1 1.1. Relational operators..................................................... 1 1.2. Logical

More information

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions Announcements Thursday Extras: CS Commons on Thursdays @ 4:00 pm but none next week No office hours next week Monday or Tuesday Reflections: when to use if/switch statements for/while statements Floating-point

More information

Programming and Data Structures

Programming and Data Structures Programming and Data Structures Teacher: Sudeshna Sarkar sudeshna@cse.iitkgp.ernet.in Department of Computer Science and Engineering Indian Institute of Technology Kharagpur #include int main()

More information

The University of Calgary. ENCM 339 Programming Fundamentals Fall 2016

The University of Calgary. ENCM 339 Programming Fundamentals Fall 2016 The University of Calgary ENCM 339 Programming Fundamentals Fall 2016 Instructors: S. Norman, and M. Moussavi Wednesday, November 2 7:00 to 9:00 PM The First Letter of your Last Name:! Please Print your

More information

'C' Programming Language

'C' Programming Language F.Y. Diploma : Sem. II [DE/EJ/ET/EN/EX] 'C' Programming Language Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define pointer. Write syntax

More information

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10 16.216: ECE Application Programming Spring 2015 Exam 1 February 23, 2015 Name: ID #: For this exam, you may use only one 8.5 x 11 double-sided page of notes. All electronic devices (e.g., calculators,

More information

Lab Session # 1 Introduction to C Language. ALQUDS University Department of Computer Engineering

Lab Session # 1 Introduction to C Language. ALQUDS University Department of Computer Engineering 2013/2014 Programming Fundamentals for Engineers Lab Lab Session # 1 Introduction to C Language ALQUDS University Department of Computer Engineering Objective: Our objective for today s lab session is

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

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

Pointers, Arrays, and Strings. CS449 Spring 2016

Pointers, Arrays, and Strings. CS449 Spring 2016 Pointers, Arrays, and Strings CS449 Spring 2016 Pointers Pointers are important. Pointers are fun! Pointers Every variable in your program has a memory location. This location can be accessed using & operator.

More information

School of Electrical Engineering & Computer Science Oregon State University. CS Recitation 3 Spring 2012

School of Electrical Engineering & Computer Science Oregon State University. CS Recitation 3 Spring 2012 School of Electrical Engineering & Computer Science Oregon State University CS 261 - Recitation 3 Spring 2012 Bitwise Operators AND (&), OR ( ), XOR(^), Complement (~) In all our examples sizeof(int) =

More information

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output

More information

SHARDA UNIVERSITY SCHOOL OF ENGINEERING & TECHNOLOGY Mid Term Examination, (Odd Term, ) SOLUTION

SHARDA UNIVERSITY SCHOOL OF ENGINEERING & TECHNOLOGY Mid Term Examination, (Odd Term, ) SOLUTION SHARDA UNIVERSITY SCHOOL OF ENGINEERING & TECHNOLOGY Mid Term Examination, (Odd Term, 2016-17) SOLUTION Program: B. Tech. Branch: All Term:I Subject: Logic Building and Problem Solving Using C Paper Code:

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

Approximately a Final Exam CPSC 206

Approximately a Final Exam CPSC 206 Approximately a Final Exam CPSC 206 Sometime in History based on Kelley & Pohl Last name, First Name Last 4 digits of ID Write your section number: All parts of this exam are required unless plainly and

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

Q1: Multiple choice / 20 Q2: Arrays / 40 Q3: Functions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Q1: Multiple choice / 20 Q2: Arrays / 40 Q3: Functions / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10 EECE.2160: ECE Application Programming Spring 2017 Exam 2 March 29, 2017 Name: Section (circle 1): 201 (Dr. Li, MWF 8-8:50) 202 (Dr. Geiger, MWF 12-12:50) For this exam, you may use only one 8.5 x 11 double-sided

More information

PROGRAMMING IN C AND C++:

PROGRAMMING IN C AND C++: PROGRAMMING IN C AND C++: Week 1 1. Introductions 2. Using Dos commands, make a directory: C:\users\YearOfJoining\Sectionx\USERNAME\CS101 3. Getting started with Visual C++. 4. Write a program to print

More information

ECE 15 Fall 15 Midterm Solutions

ECE 15 Fall 15 Midterm Solutions ECE 15 Fall 15 Midterm Solutions This is a closed-book exam: no notes, books, calculators, cellphones, or friends are allowed. In problems 2 4, you can assume that the uers s input is correct. If you need

More information

C Programming. The C Preprocessor and Some Advanced Topics. Learn More about #define. Define a macro name Create function-like macros.

C Programming. The C Preprocessor and Some Advanced Topics. Learn More about #define. Define a macro name Create function-like macros. C Programming The C Preprocessor and Some Advanced Topics June 03, 2005 Learn More about #define Define a macro name Create function-like macros to avoid the time might be longer #define SUM(i, j) i+j

More information

3. Types of Algorithmic and Program Instructions

3. Types of Algorithmic and Program Instructions 3. Types of Algorithmic and Program Instructions Objectives 1. Introduce programming language concepts of variables, constants and their data types 2. Introduce types of algorithmic and program instructions

More information

Basic Assignment and Arithmetic Operators

Basic Assignment and Arithmetic Operators C Programming 1 Basic Assignment and Arithmetic Operators C Programming 2 Assignment Operator = int count ; count = 10 ; The first line declares the variable count. In the second line an assignment operator

More information

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS DEPARTMENT OF SCIENCE AND HUMANITIES EVEN SEMESTER FEB 2017

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS DEPARTMENT OF SCIENCE AND HUMANITIES EVEN SEMESTER FEB 2017 P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS DEPARTMENT OF SCIENCE AND HUMANITIES ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) EVEN SEMESTER FEB 07 FACULTY: Dr.J Surya Prasad/Ms. Saritha/Mr.

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

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 6 - Array and String Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Array Generic declaration: typename variablename[size]; typename is

More information

CGS 3460 Summer 07 Midterm Exam

CGS 3460 Summer 07 Midterm Exam Short Answer 3 Points Each 1. What would the unix command gcc somefile.c -o someotherfile.exe do? 2. Name two basic data types in C. 3. A pointer data type holds what piece of information? 4. This key

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 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

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

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach C Fundamentals & Formatted Input/Output adopted from KNK C Programming : A Modern Approach C Fundamentals 2 Program: Printing a Pun The file name doesn t matter, but the.c extension is often required.

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

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Decide if the given number is a solution to the given equation. ) p + 3p - 2 = 62; 8 ) A)

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

EECE.2160: ECE Application Programming Spring 2018

EECE.2160: ECE Application Programming Spring 2018 EECE.2160: ECE Application Programming Spring 2018 1. (46 points) C input/output; operators Exam 1 Solution a. (13 points) Show the output of the short program below exactly as it will appear on the screen.

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

Principles of C and Memory Management

Principles of C and Memory Management COMP281 Lecture 9 Principles of C and Memory Management Dr Lei Shi Last Lecture Today Pointer to Array Pointer Arithmetic Pointer with Functions struct Storage classes typedef union String struct struct

More information

Grade Distribution. Exam 1 Exam 2. Exams 1 & 2. # of Students. Total: 17. Total: 17. Total: 17

Grade Distribution. Exam 1 Exam 2. Exams 1 & 2. # of Students. Total: 17. Total: 17. Total: 17 Grade Distribution Exam 1 Exam 2 Score # of Students Score # of Students 16 4 14 6 12 4 10 2 8 1 Total: 17 Exams 1 & 2 14 2 12 4 10 5 8 5 4 1 Total: 17 Score # of Students 28 2 26 5 24 1 22 4 20 3 18 2

More information

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

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. .. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. A Simple Program. simple.c: Basics of C /* CPE 101 Fall 2008 */ /* Alex Dekhtyar */ /* A simple program */ /* This is a comment!

More information

Programming & Data Structure: CS Section - 1/A DO NOT POWER ON THE MACHINE

Programming & Data Structure: CS Section - 1/A DO NOT POWER ON THE MACHINE DS Tutorial: III (CS 11001): Section 1 Dept. of CS&Engg., IIT Kharagpur 1 Tutorial Programming & Data Structure: CS 11001 Section - 1/A DO NOT POWER ON THE MACHINE Department of Computer Science and Engineering

More information

ET156 Introduction to C Programming

ET156 Introduction to C Programming ET156 Introduction to C Programming g Unit 22 C Language Elements, Input/output functions, ARITHMETIC EXPRESSIONS AND LIBRARY FUNCTIONS Instructor : Stan Kong Email : skong@itt tech.edutech.edu General

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 7 Array and String Department of Computer Engineering Outline Array String Department

More information

Chapter 3: Arrays and More C Functionality

Chapter 3: Arrays and More C Functionality Chapter 3: Arrays and More C Functionality Objectives: (a) Describe how an array is stored in memory. (b) Define a string, and describe how strings are stored. (c) Describe the implications of reading

More information

AROUND THE WORLD OF C

AROUND THE WORLD OF C CHAPTER AROUND THE WORLD OF C 1 1.1 WELCOME TO C LANGUAGE We want to make you reasonably comfortable with C language. Get ready for an exciting tour. The problem we would consider to introduce C language

More information

CPS 101 Introduction to Computational Science

CPS 101 Introduction to Computational Science CPS 101 Introduction to Computational Science Wensheng Shen Department of Computational Science SUNY Brockport Chapter 10: Program in C Why C language: C is the language which can be used for both system

More information

Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below:

Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below: Q1. Explain the structure of a C program Structure of the C program is shown below: Preprocessor Directives Global Declarations Int main (void) Local Declarations Statements Other functions as required

More information

Tech Mahindra Placement Paper 1. C-Test Paper. 1. #include. * What is wrong in the following problem. main() { int i,j; j = 10;

Tech Mahindra Placement Paper 1. C-Test Paper. 1. #include. * What is wrong in the following problem. main() { int i,j; j = 10; Tech Mahindra Placement Paper 1 C-Test Paper 1. #include * What is wrong in the following problem int i,j; j = 10; i = j++ - j++; printf("%d %d", i,j); ans: 0, 12 2.#include * What is the output of the

More information

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That 1. Introduction You have seen situations in which the way numbers are stored in a computer affects a program. For example, in the

More information

Additional Questions

Additional Questions Additional Questions 1. Explain the structure of a C program with a neat block diagram. 2. Give the formatted output of the following program : float a=125.5180; char c='a'; printf("%5d, %03c, %-8.2f ",sizeof(a),c,a);

More information

Engineering 12 - Spring, 1998

Engineering 12 - Spring, 1998 Engineering 12 - Spring, 1998 1. (15 points) Rewrite the following program so that it uses a while loop in place of the for loop. (Note that a part of the new program is already shown at the bottom of

More information

Summer Review for Students entering Algebra

Summer Review for Students entering Algebra Class: Date: Summer Review for Students entering Algebra 08 Multiple Choice Identify the choice that best completes the statement or answers the question. SHOW ALL WORK ON THIS PAPER OR ON ADDITIONAL PAPER..

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 10: Arrays Readings: Chapter 9 Introduction Group of same type of variables that have same

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

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) FACULTY: Ms. Saritha P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) SUBJECT / CODE: Programming in C and Data Structures- 15PCD13 What is token?

More information

EECE.2160: ECE Application Programming Fall 2017

EECE.2160: ECE Application Programming Fall 2017 EECE.2160: ECE Application Programming Fall 2017 1. (46 points) C input/output; operators Exam 1 Solution a. (13 points) Show the output of the short program below exactly as it will appear on the screen.

More information

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3). cs3157: another C lecture (mon-21-feb-2005) C pre-processor (1). today: C pre-processor command-line arguments more on data types and operators: booleans in C logical and bitwise operators type conversion

More information

These are reserved words of the C language. For example int, float, if, else, for, while etc.

These are reserved words of the C language. For example int, float, if, else, for, while etc. Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.

More information

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10 EECE.2160: ECE Application Programming Spring 2016 Exam 1 February 19, 2016 Name: Section (circle 1): 201 (8-8:50, P. Li) 202 (12-12:50, M. Geiger) For this exam, you may use only one 8.5 x 11 double-sided

More information

Variables, Data Types, and Arithmetic Expressions Learning Objectives:

Variables, Data Types, and Arithmetic Expressions Learning Objectives: Variables, Data Types, and Arithmetic Expressions Learning Objectives: Printing more than one variable in one printf() Printing formatting characters in printf Declaring and initializing variables A couple

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

16.216: ECE Application Programming Fall 2015 Exam 1 Solution

16.216: ECE Application Programming Fall 2015 Exam 1 Solution 16.216: ECE Application Programming Fall 2015 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution

EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution EECE.2160: ECE Application Programming Spring 2016 Exam 1 Solution 1. (20 points, 5 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling

More information

CS16 Exam #1 7/17/ Minutes 100 Points total

CS16 Exam #1 7/17/ Minutes 100 Points total CS16 Exam #1 7/17/2012 75 Minutes 100 Points total Name: 1. (10 pts) Write the definition of a C function that takes two integers `a` and `b` as input parameters. The function returns an integer holding

More information

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ. C BOOTCAMP DAY 2 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Pointers 2 Pointers Pointers are an address in memory Includes variable addresses,

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 4 Input & Output Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline printf scanf putchar getchar getch getche Input and Output in

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

Pointers and Structure. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Pointers and Structure. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Pointers and Structure Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island 1 Pointer Variables Each variable in a C program occupies space in

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables

More information

Week 3 More Formatted Input/Output; Arithmetic and Assignment Operators

Week 3 More Formatted Input/Output; Arithmetic and Assignment Operators Week 3 More Formatted Input/Output; Arithmetic and Assignment Operators Formatted Input and Output The printf function The scanf function Arithmetic and Assignment Operators Simple Assignment Side Effect

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

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi CE 43 - Fall 97 Lecture 4 Input and Output Department of Computer Engineering Outline printf

More information