SECTION A TRUE / FALSE QUESTIONS (10 MARKS) (INSTRUCTION: Please answer all 10 questions)
|
|
- Marianna Nelson
- 5 years ago
- Views:
Transcription
1 SECTION A TRUE / FALSE QUESTIONS ( MARKS) (INSTRUCTION: Please answer all questions) 1) In pre-test loop, the condition is tested first, before executing the body of the loop. ) The while loop can be used to test if the input data is invalid and repeat until valid data is entered. 3) In do-while loop, the body of the loop will never execute if the test condition is false. 4) A program will fall through a switch..case section if it missing the break statement in each case. 5) The following array declaration will results in characters being stored in an array as shown. char subject[ ]= C Program ; //declaration Memory layout: C P r o g r a m [0] [1] [] [3] [4] [5] [6] [7] 6) The output of the following program segment is odd[1]=3. 1 int odd[6]=1,3,5,7,9; printf( odd[1]=%d,odd[1]); 7) Given a function prototype as follows. void test(int, char); The test function can be called by the following statement. test(); ) A function with return type can return only a result to the calling statement. 9) All user-defined functions can only pass the parameters by value. ) An array can store different data types. 1
2 SECTION B STRUCTURED QUESTIONS (60 MARKS) (INSTRUCTION: Please answer all questions) QUESTION 1 [5 MARKS] Rewrite the following if-else if statement using a switch statement. if (choice == 1) printf( Alpha ); else if (choice == choice == 3) printf( Beta ); else if (choice == 4) printf( Gamma ); else printf( Other ); QUESTION [6 MARKS] a) Mirza has RM0 at the start. If he saves RM50 per month, how much he has saved after 4 months? Complete the program by adding a while loop to solve the problem. (4 Marks) #include <stdio.h> int main () int count, saving=0; count=1;
3 printf("total saving after 4 months is RM%d", saving); b) Write a for loop to print the output,, 6, 4, and 0 in descending order. ( Marks) QUESTION 3 [6 MARKS] Given below is an executable program to calculate the power (watts) with initialled values of amp and ohm #include <stdio.h> #include <math.h> double amp =.0, ohm = 0.5, power; void int main(void) printf( Calculate the power: \n ); printf( amp = %.f, ohm = %.f\n, amp, ohm); power = pow(amp,)*ohm; printf( The power is %.f watts\n, power); return 0; Rewrite the program so that it will contain the following functions by including the new prototype function, function definition and function call. Function information()that execute the lines 9 and of the program. Function calculation()that execute the lines 1 and 13 of the program. 3
4 QUESTION 4 [14 MARKS] a) Trace the following program and give the output. (4 marks) #include <stdio.h> void addition (int, int); int num1=3, num=0; int main () int num1=, num=3; printf ("num1 = %d num = %d \n", num1, num); addition (num1, num); printf ("num1 = %d num = %d \n", num1, num); addition (num1, num); return 0; void addition( int a, int b) printf ("%d + %d = %d\n", a,b, a+b); num1++; num++; 4
5 b) The following program reads the first and last number in a list. It then finds the number of even, odd and multiple three numbers in the list (including the first and the last number). For example if the first number is 1 and the last number is. The total number of odd is 5 (1, 3, 5, 7, 9), even number is also 5 (, 4, 6,, ) and multiple 3 is 3 (3, 6, 9). 1 #include <stdio.h> 3 int main() 4 5 int first_num, last_num, x, count_even=0, count_odd=0; 6 float total_odd=0.0, total_even=0.0; 7 int no_of_multiple_3=0; bool flag; 9 scanf( "%d %d", &first_num, &last_num); 11 for (x=first_num; x<=last_num; x++) flag=check_even_odd(x); 16 if (flag) 17 1 count_odd+=1; 19 total_odd+=x; 0 1 Else 3 count_even+=1; 4 total_even+=x; 5 6 no_of_multiple_3 +=multiple_three(x); 7 printf ("Total of odd number is %.1f\n",total_odd); 9 printf ("Total of even number is %.1f\n",total_even); 30 printf ("Total of multiple three is %d\n", no_of_multiple_3); 31 return 0; 3 i) Write a complete function definition for check_even_odd()function. The purpose of this function is to check whether the number is odd or even. (5 marks) 5
6 ii) Write a complete function definition for multiple_three()function. The purpose of this function is to check whether the number is multiple three or not. (5 marks) QUESTION 5 [ MARKS] Given the definition of a function named trouble() as below. 1 void trouble(int *p, int y) 3 int x; 4 x=; 5 *p=*x-y; 6 y+=x; 7 Determine whether each of the following calls to the function trouble() is valid. If it is, write the output printed by the code segment. Otherwise, give the reason why the call is invalid. i) int x=5, y=; trouble (&x, y); printf("x = %d, y = %d \n", x,y); ii) iii) int y=3; trouble (&y,) printf("y = %d \n", y); int p=1; trouble(1, &p); printf("p = %d \n", p); 6
7 iv) int x=; trouble(&x, x+); printf("x = %d, \n", x); QUESTION 6 [11 MARKS] a) The following program generates a sequence of four integers based on the first two integers entered by user. The order of the sequence generated is depending on the order of the user input #include <stdio.h> #define SIZE 4 int main() int num[size],x,y,j;//declaration variables scanf("%d%d",&x,&y); //get input x, y from user num[0]=x; num[1]=y; for(inti=0;i<size;i++) if (num[i]<num[i+1]) j=i; num[j+]=num[j+1]+(num[j+1]-num[j]); else num[i+]=num[i+1]-(num[i]-num[i+1]); for (inti=0; i<size;i++) printf("%d ",num[i]); i) State the output of the program given the following set of input: (4 marks) x y output
8 ii) Modify the statements in line 3 where necessary so that each number in the array element is increased by 1. ( marks) b) The following program should compare array of integer, num1[] and num[]. If any element in array num1[] is found in array num[], a message is displayed as shown in the expected output below. The program sum up elements in array num1[] that is found in array num[]. The result is assign to numtotal and is displayed as shown. Complete the program with suitable statements. (5 marks) Expected output: #include <stdio.h> #define SIZE 3 int main() int num1[size]=,3,5, num[size]=1,,3; int numtotal=0; printf("num Total=%d\n",numtotal);
9 QUESTION 7 [ Marks] 1) Define and initialize a two dimensional array named num[][]in the source code given to store below matrix. Write a complete program that used array num[][] to produce output as in Figure 1. The program should include a function / prototype declaration at line 4. The calculate() function receives array num[][] and return the total element of the below matrix The matrix elements Total elements of the matrix = 7 Figure 1: Output #include <stdio.h> #include <conio.h> int calculate(int a[][4]); //prototype declaration int main() return 0; 9
10 SECTION C STRUCTURED QUESTIONS (30 MARKS) (INSTRUCTION: Please answer all questions) QUESTION 1 [ MARKS] Write a program that will calculate area for plane shapes. User will be prompted with a menu to choose the shape they want to calculate. The program prompts user for input data required for the calculation such as base, height and width. The program then display area of the shapes and prompt the user whether they want to continue or exit. The program will only stop if the user chooses to exit by entering N. Sample output is shown below: Area Calculator for Plane Shapes Choose the shape below by entering the number: 1. Triangle. Rectangle 3. Square 4. Circle Enter your choice:1 Please enter the following information: Base: 4 Height: The area of triangle is 16 Do you want to continue(y/n)? N Thank you for using the calculator. Formula for area calculation: Shapes Parameters Area Formula Triangle b = base, h = height ½ b h Rectangle w = width, h = height w h Square a = length of side a Circle pie = 3.14, r = radius pie radius
11 Answer: 11
12 QUESTION [0 MARKS] The Maju Jaya Mart is a convenience store company that has five store located in Skudai. At the end of each year, the management of the company wants to know the performance of their company. They have decided to use a computer program to help them in analyzing the company s sales. You, as a freelance programmer have been appointed to develop the program using C language. The requirements of the program are as follow: Input: The program should read in sales data from a text file. The format of the input file is as follows: The first column is for the store branch code, second column is the sales of the first quarter, third column is for second quarter, and so forth. Figure shows an example of input file named sales015.txt containing sales data for the year 015. Output: The program should print out a report into a text file named report.txt. The report should include: o The grand total of sales, over all stores sales throughout the year. o The highest sales. Print the store code and the highest sales. o The total sales for each quarter. Figure 3 shows an example report file for the sales data of the year 015. Arrays: The program should use array(s) to store the sales data. Functions: The program should have the following function: grandtotal(). This function should return the grand total of sales over all stores throughout the year. It should accept array (representing sales) as its parameters. quartertotal(). This function should accept arrays and the index of a column in the array (representing a quarter) as its parameters. The function should return the total sales for the specified quarter. highestsale(). This function should accept arrays (representing sales) as one of its parameters. It should determine the indices of row and column of a cell in the array which has the highest sales. 1
13 Write a complete C program based on the requirements given above Figure : An example of input file, sales015.txt Grand total of sales over all stores: RM 100 The highest quarter sales: Store Code: 01 Quarter : 3 Sales: RM 9600 Total sales by quarter: Quarter Sales Quarter 1 RM 300 Quarter RM 0300 Quarter 3 RM 3000 Quarter 4 RM Figure 3: The output file for the sales data in Figure 13
14 Answer: End of Question GOOD LUCK! 14
CSE 142 Wi01 Midterm 2 page 1 of 6
CSE 142 Wi01 Midterm 2 page 1 of 6 Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the space provided on these pages. Keep your answers short and to the point.
More informationThe 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 informationQuestion 2. [5 points] Given the following symbolic constant definition
CS 101, Spring 2012 Mar 20th Exam 2 Name: Question 1. [5 points] Determine which of the following function calls are valid for a function with the prototype: void drawrect(int width, int height); Assume
More informationC Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function
More informationCOP 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 informationCOP 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 informationLAB 6 FUNCTIONS I School of Computer and Communication Engineering
LAB 6 FUNCTIONS I School of Computer and Communication Engineering 1 Universiti Malaysia Perlis 1. OBJECTIVES: 1.1 To apply functions as building blocks of programs. 1.2 To write C programs using functions.
More informationNote: unless otherwise stated, the questions are with reference to the C Programming Language. You may use extra sheets if need be.
CS 156 : COMPUTER SYSTEM CONCEPTS TEST 1 (C PROGRAMMING PART) FEBRUARY 6, 2001 Student s Name: MAXIMUM MARK: 100 Time allowed: 45 minutes Note: unless otherwise stated, the questions are with reference
More informationProgramming Language A
Programming Language A Takako Nemoto (JAIST) 22 October Takako Nemoto (JAIST) 22 October 1 / 28 From Homework 2 Homework 2 1 Write a program calculate something with at least two integer-valued inputs,
More informationComputer Programming. Decision Making (2) Loops
Computer Programming Decision Making (2) Loops Topics The Conditional Execution of C Statements (review) Making a Decision (review) If Statement (review) Switch-case Repeating Statements while loop Examples
More informationWARM UP LESSONS BARE BASICS
WARM UP LESSONS BARE BASICS CONTENTS Common primitive data types for variables... 2 About standard input / output... 2 More on standard output in C standard... 3 Practice Exercise... 6 About Math Expressions
More informationLAB 6 FUNCTION PART 1 School of Computer and Communication Engineering Universiti Malaysia Perlis
Laboratory Module [Updated October 2017] LAB 6 FUNCTION PART 1 School of Computer and Communication Engineering Universiti Malaysia Perlis 1 OBJECTIVES 1. To differentiate between predefined function and
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationStructured programming
Exercises 6 Version 1.0, 25 October, 2016 Table of Contents 1. Arrays []................................................................... 1 1.1. Declaring arrays.........................................................
More informationLab 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 informationFunctions. 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 informationLOOPS. 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 informationPROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE
PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE 1. Write a C program to perform addition, subtraction, multiplication and division of two numbers. # include # include int a, b,sum,
More informationEngineering program development 6. Edited by Péter Vass
Engineering program development 6 Edited by Péter Vass Variables When we define a variable with its identifier (name) and type in the source code, it will result the reservation of some memory space for
More informationC++ Final Exam 2017/2018
1) All of the following are examples of integral data types EXCEPT. o A Double o B Char o C Short o D Int 2) After the execution of the following code, what will be the value of numb if the input value
More informationMultiple Choice Questions ( 1 mark)
Multiple Choice Questions ( 1 mark) Unit-1 1. is a step by step approach to solve any problem.. a) Process b) Programming Language c) Algorithm d) Compiler 2. The process of walking through a program s
More informationPrinciples of Programming. Chapter 6: Arrays
Chapter 6: Arrays In this chapter, you will learn about Introduction to Array Array declaration Array initialization Assigning values to array elements Reading values from array elements Simple Searching
More information1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.
1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format
More informationName SECTION: 12:45 2:20. True or False (12 Points)
Name SECION: 12:45 2:20 rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables
More information3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)
Structures Programming in C++ Sequential Branching Repeating Loops (Repetition) 2 1 Loops Repetition is referred to the ability of repeating a statement or a set of statements as many times this is necessary.
More informationFlow Chart. The diagrammatic representation shows a solution to a given problem.
low Charts low Chart A flowchart is a type of diagram that represents an algorithm or process, showing the steps as various symbols, and their order by connecting them with arrows. he diagrammatic representation
More information16.216: ECE Application Programming Fall 2011
16.216: ECE Application Programming Fall 2011 Exam 1 Solution 1. (24 points, 6 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationSubject: 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 informationExpressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators
Expressions 1 Expressions n Variables and constants linked with operators Arithmetic expressions n Uses arithmetic operators n Can evaluate to any value Logical expressions n Uses relational and logical
More informationQuestion 2. [2 points] Which of the following is a correct statement to obtain user input? (Assume that fleems is an int variable.
CS 101, Spring 2016 Feb 23rd Exam 1 Name: Question 1. [2 points] Write a statement(s) to declare a variable named num students that will be used to store the number of students and set the value of the
More informationDept. of CSE, IIT KGP
Control Flow: Looping CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of Repeated Execution Loop: Group of
More informationCOP 2000 Introduction to Computer Programming Mid-Term Exam Review
he exam format will be different from the online quizzes. It will be written on the test paper with questions similar to those shown on the following pages. he exam will be closed book, but students can
More informationLaboratory 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 informationLecture 16. Daily Puzzle. Functions II they re back and they re not happy. If it is raining at midnight - will we have sunny weather in 72 hours?
Lecture 16 Functions II they re back and they re not happy Daily Puzzle If it is raining at midnight - will we have sunny weather in 72 hours? function prototypes For the sake of logical clarity, the main()
More informationCPE 112 Spring 2015 Exam III (100 pts) April 8, True or False (12 Points)
Name rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables retain their value
More informationComputer Programming 5th Week loops (do-while, for), Arrays, array operations, C libraries
Computer Programming 5th Week loops (do-while, for), Arrays, array operations, C libraries Hazırlayan Asst. Prof. Dr. Tansu Filik Computer Programming Previously on Bil 200 Low-Level I/O getchar, putchar,
More informationNote: If only one statement is to be followed by the if or else condition then there is no need of parenthesis.
Birla Institute of Technology & Science, Pilani Computer Programming (CSF111) Lab-4 ---------------------------------------------------------------------------------------------------------------------------------
More informationUNIVERSITY OF WINDSOR Fall 2006 QUIZ # 1. Examiner:Ritu Chaturvedi Dated : Oct 3rd, Student Name: Student Number:
UNIVERSITY OF WINDSOR 60-106-01 Fall 2006 QUIZ # 1 Examiner:Ritu Chaturvedi Dated : Oct 3rd, 2006. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) Examination Period is : 1 hour Answer
More informationQuestion 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 informationESC101N: 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 informationQuestion 2. [2 points] True False By default, structures are passed-by-reference.
CS 101, Spring 2016 May 5th Exam 4 Name: For Questions 1 5, circle True or False. Question 1. [2 points] True False A structure is a user-defined data type. Question 2. [2 points] True False By default,
More informationIECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.
Subject code - CCP01 Chapt Chapter 1 INTRODUCTION TO C 1. A group of software developed for certain purpose are referred as ---- a. Program b. Variable c. Software d. Data 2. Software is classified into
More informationn Group of statements that are executed repeatedly while some condition remains true
Looping 1 Loops n Group of statements that are executed repeatedly while some condition remains true n Each execution of the group of statements is called an iteration of the loop 2 Example counter 1,
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationControl Structure: Loop
Control Structure: Loop Knowledge: Understand the various concepts of loop control structure Skill: Be able to develop a program involving loop control structure 1 Loop Structure Condition is tested first
More informationAssoc. Prof. Dr. Tansu FİLİK
Assoc. Prof. Dr. Tansu FİLİK Previously on Bil 200 Low-Level I/O getchar, putchar, getc, putc Control Structures if-else, switch-case, loops (while, dowhile, for loops) for loop (generic) A disturbingly
More information16.216: ECE Application Programming Fall 2011
16.216: ECE Application Programming Fall 2011 Exam 2 Solution 1. (24 points, 6 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationCC112 Structured Programming
Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer Engineering Department CC112 Structured Programming Lecture 3 1 LECTURE 3 Input / output operations
More informationCS 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 informationCOMP 208 Computers in Engineering
COMP 208 Computers in Engineering Lecture 14 Jun Wang School of Computer Science McGill University Fall 2007 COMP 208 - Lecture 14 1 Review: basics of C C is case sensitive 2 types of comments: /* */,
More informationTEST 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 informationAROUND 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 informationEECE.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 informationH192 Midterm 1 Review. Tom Zajdel
H192 Midterm 1 Review Tom Zajdel Declaring variables Need to specify a type when declaring a variable. Can declare multiple variables in one line. int x, y, z; float a, b, c; Can also initialize in same
More informationAMCAT 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 informationECE 15 Fall 16 Midterm Solutions
ECE 15 Fall 16 Midterm Solutions This is a closed-book exam: no notes, books, calculators, cellphones, or friends are allowed. In problems 4 6, you can assume that the user s input is correct. If you need
More informationQuiz1 Fall 2007 October 2 nd, UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated :October 2nd, 2007.
UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 1 Solution Examiner:Ritu Chaturvedi Dated :October 2nd, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationScheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C
Sample Test Paper-I Marks : 25 Time:1 Hrs. Q1. Attempt any THREE 09 Marks a) State four relational operators with meaning. b) State the use of break statement. c) What is constant? Give any two examples.
More informationALGORITHM 2-1 Solution for Exercise 4
Chapter 2 Recursion Exercises 1. a. 3 * 4 = 12 b. (2 * (2 * fun1(0) + 7) + 7) = (2 * (2 * (3 * 0) + 7) + 7) = 21 c. (2 * (2 * fun1(2) + 7) + 7) = (2 * (2 * (3 * 2) + 7) + 7) = 45 2. a. 3 b. (fun2(2, 6)
More informationCOP 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 informationMidterm Examination (MTA)
M105: Introduction to Programming with Java Midterm Examination (MTA) Spring 2013 / 2014 Question One: [6 marks] Choose the correct answer and write it on the external answer booklet. 1. Compilers and
More informationConsider 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 informationStructured programming
Exercises 2 Version 1.0, 22 September, 2016 Table of Contents 1. Simple C program structure................................................... 1 2. C Functions..................................................................
More informationQ1: C input/output; operators / 46 Q2: Conditional statements / 34 Q3: While and do-while loops / 20 TOTAL SCORE / 100 Q4: EXTRA CREDIT / 10
EECE.2160: ECE Application Programming Fall 2017 Exam 1 October 4, 2017 Name: Lecture time (circle 1): 8-8:50 (Sec. 201) 12-12:50 (Sec. 203) 1-1:50 (Sec. 202) For this exam, you may use only one 8.5 x
More informationUNIT - I. Introduction to C Programming. BY A. Vijay Bharath
UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been
More informationArithmetic Expressions in C
Arithmetic Expressions in C Arithmetic Expressions consist of numeric literals, arithmetic operators, and numeric variables. They simplify to a single value, when evaluated. Here is an example of an arithmetic
More informationECE15: Introduction to Computer Programming Using the C Language. Lecture Unit 4: Flow of Control
ECE15: Introduction to Computer Programming Using the C Language Lecture Unit 4: Flow of Control Outline of this Lecture Examples of Statements in C Conditional Statements The if-else Conditional Statement
More informationDetail from C Propaganda Poster // Reddit user TheBall BBM 101. Introduction to Programming I. Lecture #11 C Iterations, Functions, Multi-D Arrays
Detail from C Propaganda Poster // Reddit user TheBall BBM 101 Introduction to Programming I Lecture #11 C Iterations, Functions, Multi-D Arrays Erkut Erdem, Aykut Erdem & Aydın Kaya // Fall 2017 Last
More informationLecture 9 - C Functions
ECET 264 C Programming Language with Applications Lecture 9 C Functions Paul I. Lin Professor of Electrical & Computer Engineering Technology http://www.etcs.ipfw.edu/~lin Lecture 9- Prof. Paul I. Lin
More informationC Program Development and Debugging under Unix SEEM 3460
C Program Development and Debugging under Unix SEEM 3460 1 C Basic Elements SEEM 3460 2 C - Basic Types Type (32 bit) Smallest Value Largest Value short int -32,768(-2 15 ) 32,767(2 15-1) unsigned short
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationUnit 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 informationCS16 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 informationLecture 2. Examples of Software. Programming and Data Structure. Programming Languages. Operating Systems. Sudeshna Sarkar
Examples of Software Programming and Data Structure Lecture 2 Sudeshna Sarkar Read an integer and determine if it is a prime number. A Palindrome recognizer Read in airline route information as a matrix
More informationSAMPLE MIDTERM SOLUTION
CMPT 102 SAMPLE MIDTERM SOLUTION PART 1 (40 points): SHORT ANSWER QUESTIONS 1. (8 points) Which of the following identifiers are invalid? Why? int my_book while loop FOR butter iff sentinel Calc-mean MeanOf45
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Midterm Examination October 20, 2011 6:15 p.m. 8:00 p.m. (105 minutes) Examiners: J. Anderson, T. Fairgrieve,
More informationPointers and scanf() Steven R. Bagley
Pointers and scanf() Steven R. Bagley Recap Programs are a series of statements Defined in functions Can call functions to alter program flow if statement can determine whether code gets run Loops can
More informationPROGRAMS. EXCELLENT ACADEMY OF ENGINEERING. Telephone: / NORMAL PROGRAM
PROGRAMS NORMAL PROGRAM 1. Wap to display months in words where month in number is input. 2. Wap to print Fibonacci series till n elements. 3. Wap to reverse 4 digit numbers. 4. Wap to accept a number
More informationSample Examination. Family Name:... Other Names:... Signature:... Student Number:...
Family Name:... Other Names:... Signature:... Student Number:... THE UNIVERSITY OF NEW SOUTH WALES SCHOOL OF COMPUTER SCIENCE AND ENGINEERING Sample Examination COMP1917 Computing 1 EXAM DURATION: 2 HOURS
More informationDecision Making and Loops
Decision Making and Loops Goals of this section Continue looking at decision structures - switch control structures -if-else-if control structures Introduce looping -while loop -do-while loop -simple for
More informationIntroduction to Computing Lecture 07: Repetition and Loop Statements (Part II)
Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II) Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical & Electronics Engineering nukhet.ozbek@ege.edu.tr Topics
More informationPrecedence and Associativity Table. % specifiers in ANSI C: String Control Codes:
CMPE108, Homework-2 (C Fundamentals, Expressions, and Selection Structure.) Student Nr:... Name,Surname:...:... CMPE108 Group:... Signature... Please print this homework, and solve all questions on the
More informationFundamentals of Computer Programming Using C
CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar Faculty Name: Ami D. Trivedi Class: FYBCA Subject: US01CBCA01 (Fundamentals of Computer Programming Using C) *UNIT 3 (Structured Programming, Library Functions
More informationLab Exam 1 D [1 mark] Give an example of a sample input which would make the function
Grade: / 20 Lab Exam 1 D500 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return 0? Answer: Anything that is not a floating point number such as 4.567 or
More informationSlides adopted from T. Ferguson Spring 2016
CSE3 Introduction to Programming for Science & Engineering Students Mostafa Parchami, Ph.D. Dept. of Comp. Science and Eng., Univ. of Texas at Arlington, USA Slides adopted from T. Ferguson Spring 06 Pointers
More informationUNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number:
UNIVERSITY OF WINDSOR 60-106-01 Winter 2007 QUIZ # 1 Solution Examiner:Ritu Chaturvedi Dated : Feb 7 th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.
More informationDay05 A. Young W. Lim Sat. Young W. Lim Day05 A Sat 1 / 14
Day05 A Young W. Lim 2017-10-07 Sat Young W. Lim Day05 A 2017-10-07 Sat 1 / 14 Outline 1 Based on 2 Structured Programming (2) Conditions and Loops Conditional Statements Loop Statements Type Cast Young
More informationSolutions to Chapter 8
Solutions to Chapter 8 Review Questions 1. a. True 3. b. False 5. b. False 7. c. index 9. d. ary[0] = x; 11. e. sorting 13. e. sequential 15. a. A two-dimensional array can be thought of as an array of
More informationComputer Science & Engineering 150A Problem Solving Using Computers
Computer Science & Engineering 150A Problem Solving Using Computers Lecture 06 - Stephen Scott Adapted from Christopher M. Bourke 1 / 30 Fall 2009 Chapter 8 8.1 Declaring and 8.2 Array Subscripts 8.3 Using
More informationComputers in Engineering. Moving From Fortran to C Part 2 Michael A. Hawker
Computers in Engineering COMP 208 Moving From Fortran to C Part 2 Michael A. Hawker Roots of a Quadratic in C #include #include void main() { float a, b, c; float d; float root1, root2;
More informationOutline Arrays Examples of array usage Passing arrays to functions 2D arrays Strings Searching arrays Next Time. C Arrays.
CS 2060 Week 5 1 Arrays Arrays Initializing arrays 2 Examples of array usage 3 Passing arrays to functions 4 2D arrays 2D arrays 5 Strings Using character arrays to store and manipulate strings 6 Searching
More informationFundamentals of Programming Session 12
Fundamentals of Programming Session 12 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2014 These slides have been created using Deitel s slides Sharif University of Technology Outlines
More informationComputers in Engineering COMP 208. Roots of a Quadratic in C 10/25/2007. Moving From Fortran to C Part 2 Michael A. Hawker
Computers in Engineering COMP 208 Moving From Fortran to C Part 2 Michael A. Hawker Roots of a Quadratic in C #include #include void main() { float a, b, c; floatd; float root1, root2;
More informationRecap. 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 informationMaterials covered in this lecture are: A. Completing Ch. 2 Objectives: Example of 6 steps (RCMACT) for solving a problem.
60-140-1 Lecture for Thursday, Sept. 18, 2014. *** Dear 60-140-1 class, I am posting this lecture I would have given tomorrow, Thursday, Sept. 18, 2014 so you can read and continue with learning the course
More information16.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 informationDO NOW Geometry Regents Lomac Date. due. 3D: Area, Dissection, and Cavalieri
DO NOW Geometry Regents Lomac 2014-2015 Date. due. 3D: Area, Dissection, and Cavalieri (DN) ON BACK OF PACKET Name Per LO: I can define area, find area, and explain dissection and Cavalieri s Principle
More informationM1-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 informationLab Exam 1 D [1 mark] Give an example of a sample input which would make the function
CMPT 127 Spring 2019 Grade: / 20 First name: Last name: Student Number: Lab Exam 1 D400 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return -1? Answer:
More information