"'"' .;, b) F or ( c = l ; c <= 10,"' c++ ) X { JJ. ~. Computer Programming I COME Midterm Examination. Fall November 2016
|
|
- Lee Joseph
- 5 years ago
- Views:
Transcription
1 Group B ~. Computer Programming I COME Midterm Examination B Fall November Identify and correct the errors in each of the following statements. (Note: There may be more than one error.) {10 points) vv a) /lhile ( i <= 100 >Xl tot =+ i; ++i; i.;, b) F or ( c = l ; c <= 10,"' c++ ) X { JJ printf ( "%d\n,,x e ) ; _i c) float x,y; ~ ~ printf(' Please enter two float number: )J scanf("%d",x,y) ~ s~ ('-/.fl/'j c,?c,t_:;) 1 printf ("Difference of the numbers is %ft", &x+&y); f ~ d) The following code should compare two variables mathematically: if ( x '= y )) printf ( "Number are different" \n 11 ); else!- pr in tf ( "Numbers are the same,. \nll ); 2. The sign is also known as the operator. a) +, assignment!!, 0' remainder c) equality d) * stream manipulator "'"' ' 3. The address operator is a) % If & d) && e)! 4. Which of the following is an equality operator? a) > b) = c) >= lfl == Page 1I4
2 Group B, Computer Programming I B COME I 03 - Midterm Examination Fall November Consider the following code, assuming that xis an integer variable with an initial value of 2: if ( x = 4 ) printf(" %d", x ); What is the output? a) 2 ~ 4 c) nothing d) a syntax error is produced 6. The sign is also. known as the l)f =, assignment b) * stream manipulator ' c) &, stream insertion d) +, assignment operator. 7. Which of the following is not a valid escape sequence?, a) \a b) \ \ \~ d) \II 8. Which of the following can not be used as variable in a C program? a) student4 b) final_exam c) pointlx df sec#2 e) rad_cm 9. What is wrong with the following while loop? While (tot <= 2500) tot = tot + 30; a) Braces are required around tot = tot +30;. b) There should be a semicolon after While ( tot <= 2500 ). ~ While should be while. d) The parenthesis should be braces. 10. How many times does the following program print hello? i = O; while ( i <= 10 ) { printf( "hello" ); i +=2; } a) c) 10 d) an infinite number of times Page 2 I 4 JL/.(,
3 Group B Computer Programming I B COME 103 -Midterm Examination Fall November If x = 5 which of the following sets x to 7? dfx += 2; b) x *= 2; c) x =+ 2; d}x + 2 = x; 12. What will be the output of the following programs when executed? {10 points) #incl ude <stdio.h> int main(void) { int i j size=5 for ( i = 1 ; i <=size ; i++) { // Beginning of i loop for ( j = 1 ; j <=i ; j ++) { printf ( "*" ) ; } printf ("\n"); } //End of i loop Terrni11cvl 0 JfJreturn O;} // End of Main ~ '*'* fr r * ~ * ~ '* 'fr *- r *'* 13. What will be the output of the following programs when executed? #include <stdio.h> int main( void ) { int a=4 ' b=b; printf( "%d\t"' a ) ; printf( "%d\n", ++a printf( "%d\t", a++ if ( b >= a ) b+=a; else b-=a; ) ; ) ; printf( "%d\n", --b ); printf ( "%d", b + a++ ) ; return 0;} //End of Main lj (10 points) Page 3 I 4
4 ' ~... G roup B Computer Programming I COME Midterm Examination ~OL~ '\\O~.S - B Fall November Write a complete C program that calculates the sum of the even number start ing from 2 to a desired positive integer number. Program inputs a positive integer number then prints the summation of the even positive integer numbers starting from 1 to the desired number to the screen. {15 points) Mathematically if the entered number n then your program must calculate n For example, if the entered number is 7 then your program will print 12 to the screen. The terminal output of the program is shown below when entered number is ~ Enter a Positive lntege~!'lumbe ~ : 7 Summation of even nu.mbers from 2 to"7 is 12...s:.~e. ~ Writ e a complete C program that reads an integer number from keyboard then determines if the entered number is "even" or "positive" number and writes this information to the screen. {15 points) Example terminal output of the program shown below for two different scenarios. Enter a number: 3 Entered number is odd. Enter a number: 8 Entered number is positive.. ' ' _ se...e Write a program that asks the user to enter a positive integer number. It prints integer numbers starting from N to the 1 then prints the integer numbers from 2 to N in triangular form as shown below. The terminal output should look as below when executed and entered number is 5. (20 points) Hint: You should use two consecutive double-repetition loops to accomplish this task, the first one is decreasing and the second one is increasing order. E ~;~; a-: ~~~l;l v; ; ~;~g~ r.. ~~ ~ b;~ s ~ ';/~' i. ' '. ~. }... '"' ' 4444 ' Page 4 I 4
5 1: / FAll COME103 Midterm Exam Solution 2: // Group B 3: // Question 14) Sum of Even Numbers 4: 5: #include <stdio.h> 6: int main(void){ 7: int n,i,sum=0; // i is the counter 8: printf("enter a positive integer number:"); 9: scanf("%d",&n); 10: // Looping through 2,4,6,... up to n 11: // Note that n will not be included if it is odd but can be even too. 12: for ( i = 2 ; i <=n ; i+=2 ) sum += i; 13: // Now printing the result to the screen 14: printf( "Summation of odd numbers from 2 to %d is %d.",n,sum ); 15: return 0;} // End of Main 16: // One may also answer this question by using while repetition statement 1:/ FAll COME103 Midterm Exam Solution 2: // Group B 3: // Question 15) Odd Even Question 4: 5: #include <stdio.h> 6: int main(void){ 7: int n ; 8: printf("enter a number:"); 9: scanf("%d",&n); 10: if (n %2 == 0) printf("entered number is even."); 11: else printf("entered number is odd."); 12: return 0;} // End of Main 13: // One may also answer this question by using two simple if statements 5/5
6 1: // FAll COME103 Midterm Exam Solution 2: // Group B 3: // Question 16) Double Triangular printing 4: 5: #include <stdio.h> 6: int main(void){ 7: int n,i,j; // i and j are to be used as counter 8: printf("enter a positive integer number:"); 9: scanf("%d",&n); 10: // First Printing the Upper triangle n to 1 11: for ( i = n ; i >= 1 ; i ) {// Looping from n to 1 backward 12: for ( j = 1 ; j <= i ; j++ ) { //printing i, i times 13: printf("%d",i); 14: } // End of j repetition 15: printf("\n"); //going to the next line 16: } // End of i repetition 17: 18: // Now Printing the Lower triangle 2 to n 19: for ( i = 2 ; i <= n ; i++ ) {// Looping from 2 to n forward 20: for ( j = 1 ; j <= i ; j++ ) { //printing i, i times 21: printf("%d",i); 22: } // End of j repetition 23: printf("\n"); //going to the next line 24: } // End of i repetition 25: 26: return 0;} // End of Main 27: // One may also answer this question by using while repetition statement 6/6
Control 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 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 28, 2008 12:20 p.m. 1:50 p.m. Examiners: Jason Anderson, Tom Fairgrieve, Baochun
More informationC Programming Lecture V
C Programming Lecture V Instructor Özgür ZEYDAN http://cevre.beun.edu.tr/ Modular Programming A function in C is a small sub-program that performs a particular task, and supports the concept of modular
More informationLoops / Repetition Statements. There are three loop constructs in C. Example 2: Grade of several students. Example 1: Fixing Bad Keyboard Input
Loops / Repetition Statements Repetition s allow us to execute a multiple times Often they are referred to as loops C has three kinds of repetition s: the while loop the for loop the do loop The programmer
More informationCSE123 LECTURE 3-1. Program Design and Control Structures Repetitions (Loops) 1-1
CSE123 LECTURE 3-1 Program Design and Control Structures Repetitions (Loops) 1-1 The Essentials of Repetition Loop Group of instructions computer executes repeatedly while some condition remains true Counter-controlled
More informationDr. R. Z. Khan, Associate Professor, Department of Computer Science
ALIGARH MUSLIM UNIVERSITY Department of Computer Science Course: CSM-102: Programming & Problem Solving Using C Academic Session 2015-2016 UNIT-2: Handout-3 Topic: Control Structures (Selection & Repetition)
More informationECE 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 informationUNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:
UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 2 Solution Examiner : Ritu Chaturvedi Dated :November 27th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.
More informationC: How to Program. Week /Mar/05
1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers
More informationINTRODUCTION TO C++ PROGRAM CONTROL. Dept. of Electronic Engineering, NCHU. Original slides are from
INTRODUCTION TO C++ PROGRAM CONTROL Original slides are from http://sites.google.com/site/progntut/ Dept. of Electronic Engineering, NCHU Outline 2 Repetition Statement for while do.. while break and continue
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 informationCSE101-lec#12. Designing Structured Programs Introduction to Functions. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU
CSE101-lec#12 Designing Structured Programs Introduction to Functions Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Designing structured programs in C: Counter-controlled repetition
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 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 informationC Exercises. Ben Vandiver February 28, 2003
C Exercises Ben Vandiver February 28, 2003 1 General Information These exercises are intended for you to practice on. Since they won t be graded, they are to help you practice the types of things you will
More informationLanguage comparison. C has pointers. Java has references. C++ has pointers and references
Pointers CSE 2451 Language comparison C has pointers Java has references C++ has pointers and references Pointers Values of variables are stored in memory, at a particular location A location is identified
More informationLoops / Repetition Statements
Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for
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 informationModule 4: Decision-making and forming loops
1 Module 4: Decision-making and forming loops 1. Introduction 2. Decision making 2.1. Simple if statement 2.2. The if else Statement 2.3. Nested if Statement 3. The switch case 4. Forming loops 4.1. The
More informationUniversity of Maryland College Park Dept of Computer Science CMSC106 Fall 2013 Midterm I Key
University of Maryland College Park Dept of Computer Science CMSC106 Fall 2013 Midterm I Key Last Name (PRINT): First Name (PRINT): University Directory ID (e.g., umcpturtle) I pledge on my honor that
More information3. EXPRESSIONS. It is a sequence of operands and operators that reduce to a single value.
3. EXPRESSIONS It is a sequence of operands and operators that reduce to a single value. Operator : It is a symbolic token that represents an action to be taken. Ex: * is an multiplication operator. Operand:
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 informationFundamentals of Programming Session 7
Fundamentals of Programming Session 7 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 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 information1. 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 informationStructured Programming. Dr. Mohamed Khedr Lecture 9
Structured Programming Dr. Mohamed Khedr http://webmail.aast.edu/~khedr 1 Two Types of Loops count controlled loops repeat a specified number of times event-controlled loops some condition within the loop
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 informationCOMP1917 Computing 1 Written Exam Sample Questions
COMP1917 Computing 1 Written Exam Sample Questions Note: these sample questions are intended to provide examples of a certain style of question which did not occur in the tutorial or laboratory exercises,
More informationUnit 5. Decision Making and Looping. School of Science and Technology INTRODUCTION
INTRODUCTION Decision Making and Looping Unit 5 In the previous lessons we have learned about the programming structure, decision making procedure, how to write statements, as well as different types of
More informationCMPE Experiment 3 Selective Structures
Page1 CMPE 108 - Experiment 3 Selective Structures OBJECTIVES: Understand how to edit, compile and execute C computer codes. Understand C programming: sequential and selective structures NOTES: You should
More informationQ1 Q2 Q3 Q4 Q5 Total 1 * 7 1 * 5 20 * * Final marks Marks First Question
Page 1 of 6 Template no.: A Course Name: Computer Programming1 Course ID: Exam Duration: 2 Hours Exam Time: Exam Date: Final Exam 1'st Semester Student no. in the list: Exam pages: Student's Name: Student
More informationAN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University
AN OVERVIEW OF C, PART 3 CSE 130: Introduction to Programming in C Stony Brook University FANCIER OUTPUT FORMATTING Recall that you can insert a text field width value into a printf() format specifier:
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 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 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 informationOverview of C, Part 2. CSE 130: Introduction to Programming in C Stony Brook University
Overview of C, Part 2 CSE 130: Introduction to Programming in C Stony Brook University Integer Arithmetic in C Addition, subtraction, and multiplication work as you would expect Division (/) returns the
More informationIntroduction to Java Applications
2 Introduction to Java Applications OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java s primitive types. Basic memory concepts. To use
More informationThere are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.
Introduction In the programs that we have dealt with so far, all statements inside the main function were executed in sequence as they appeared, one after the other. This type of sequencing is adequate
More informationC Functions. 5.2 Program Modules in C
1 5 C Functions 5.2 Program Modules in C 2 Functions Modules in C Programs combine user-defined functions with library functions - C standard library has a wide variety of functions Function calls Invoking
More informationECE264 Fall 2013 Exam 1, September 24, 2013
ECE264 Fall 2013 Exam 1, September 24, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.
More informationSlides adopted from T. Ferguson Spring 2016
CSE1311 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 2016
More informationChapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming 2 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
More informationIntroduction. C provides two styles of flow control:
Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if
More informationSyntax of for loop is as follows: for (inite; terme; updatee) { block of statements executed if terme is true;
Birla Institute of Technology & Science, Pilani Computer Programming (CSF111) Lab-5 ---------------------------------------------------------------------------------------------------------------------------------------------
More informationChapter 6. Loops. Iteration Statements. C s iteration statements are used to set up loops.
Chapter 6 Loops 1 Iteration Statements C s iteration statements are used to set up loops. A loop is a statement whose job is to repeatedly execute some other statement (the loop body). In C, every loop
More informationProgramming for Electrical and Computer Engineers. Loops
Programming for Electrical and Computer Engineers Loops Dr. D. J. Jackson Lecture 6-1 Iteration Statements C s iteration statements are used to set up loops. A loop is a statement whose job is to repeatedly
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 informationMidterm Review. Short Answer. Short Answer. Practice material from the Winter 2014 midterm. Will cover some (but not all) of the questions.
Midterm Review Practice material from the Winter 2014 midterm. Will cover some (but not all) of the questions. Midterm content: Everything up to / including modules. CS 136 Spring 2018 Tutorial 7 1 List
More informationFundamentals of Programming Session 4
Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).
More informationUNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING
( Word to PDF Converter - Unregistered ) http://www.word-to-pdf-converter.net FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING INTRODUCTION TO C UNIT IV Overview of C Constants, Variables and Data Types
More informationdo, while and for Constructs
Programming Fundamentals for Engineers 0702113 4. Loops do, while and for Constructs Muntaser Abulafi Yacoub Sabatin Omar Qaraeen 1 Loops A loop is a statement whose job is to repeatedly execute some other
More informationCSE101-Lec#18. Multidimensional Arrays Application of arrays. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming
CSE101-Lec#18 Multidimensional Arrays Application of arrays Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Defining and processing 1D array 2D array Applications of arrays 1-D array A
More informationFlow Control. CSC215 Lecture
Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements
More 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 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 informationQ1 (15) Q2 (15) Q3 (15) Q4 (15) Total (60)
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Date:.FN / AN Time: 2 hrs Full marks: 60 No. of students: 643 Spring Mid Semester Exams, 2011 Dept: Comp. Sc & Engg. Sub No: CS11001 B.Tech 1 st Year (Core) Sub
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 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 informationLesson 7. Reading and Writing a.k.a. Input and Output
Lesson 7 Reading and Writing a.k.a. Input and Output Escape sequences for printf strings Source: http://en.wikipedia.org/wiki/escape_sequences_in_c Escape sequences for printf strings Why do we need escape
More informationAN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University
AN OVERVIEW OF C CSE 130: Introduction to Programming in C Stony Brook University WHY C? C is a programming lingua franca Millions of lines of C code exist Many other languages use C-like syntax C is portable
More informationJava. Programming: Chapter Objectives. Why Is Repetition Needed? Chapter 5: Control Structures II. Program Design Including Data Structures
Chapter 5: Control Structures II Java Programming: Program Design Including Data Structures Chapter Objectives Learn about repetition (looping) control structures Explore how to construct and use count-controlled,
More informationEC 413 Computer Organization
EC 413 Computer Organization C/C++ Language Review Prof. Michel A. Kinsy Programming Languages There are many programming languages available: Pascal, C, C++, Java, Ada, Perl and Python All of these languages
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 informationC: How to Program. Week /Apr/16
C: How to Program Week 8 2006/Apr/16 1 Storage class specifiers 5.11 Storage Classes Storage duration how long an object exists in memory Scope where object can be referenced in program Linkage specifies
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 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 informationSlide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng
Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide
More informationChapter 5: Control Structures
Chapter 5: Control Structures In this chapter you will learn about: Sequential structure Selection structure if if else switch Repetition Structure while do while for Continue and break statements S1 2017/18
More informationIntroduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan
Introduction to C Programming Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Outline Printing texts Adding 2 integers Comparing 2 integers C.E.,
More informationCHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad
CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad Outline 1. C++ Iterative Constructs 2. The for Repetition Structure 3. Examples Using the for Structure 4. The while Repetition Structure
More informationPDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs
PDS Lab Section 16 Autumn-2017 Tutorial 3 C Programming Constructs This flowchart shows how to find the roots of a Quadratic equation Ax 2 +Bx+C = 0 Start Input A,B,C x B 2 4AC False x If 0 True B x 2A
More informationQ1 (15) Q2 (15) Q3 (15) Q4 (15) Total (60)
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Date:.FN / AN Time: 2 hrs Full marks: 60 No. of students: 643 Spring Mid Semester Exams, 2011 Dept: Comp. Sc & Engg. Sub No: CS11001 B.Tech 1 st Year (Core) Sub
More informationUNIVERSITY OF SWAZILAND
UNIVERSITY OF SWAZILAND FACULTY OF SCIENCE DEPARTMENT OF ELECTRICAL &ELECTRONIC ENGINEERING PROGRAMMING TECHNIQUES I COURSE CODE - EE271 MAIN EXAMINATION DECEMBER 2011 DURATION OF THE EXAMINATION - 3 HOURS
More informationC introduction: part 1
What is C? C is a compiled language that gives the programmer maximum control and efficiency 1. 1 https://computer.howstuffworks.com/c1.htm 2 / 26 3 / 26 Outline Basic file structure Main function Compilation
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 informationComputer Programming: 7th Week Functions, Recursive Functions, Introduction to Pointers
Computer Programming: 7th Week Functions, Recursive Functions, Introduction to Pointers Hazırlayan Asst. Prof. Dr. Tansu Filik Introduction to Programming Languages Previously on Bil-200 Functions: Function
More informationExpression and Operator
Expression and Operator Examples: Two types: Expressions and Operators 3 + 5; x; x=0; x=x+1; printf("%d",x); Function calls The expressions formed by data and operators An expression in C usually has a
More informationFundamentals of Programming. Lecture 3: Introduction to C Programming
Fundamentals of Programming Lecture 3: Introduction to C Programming Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department Outline A Simple C
More informationUIC. C Programming Primer. Bharathidasan University
C Programming Primer UIC C Programming Primer Bharathidasan University Contents Getting Started 02 Basic Concepts. 02 Variables, Data types and Constants...03 Control Statements and Loops 05 Expressions
More informationFundamentals of Programming Session 14
Fundamentals of Programming Session 14 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 informationREPETITION CONTROL STRUCTURE LOGO
CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of
More informationArray Initialization
Array Initialization Array declarations can specify initializations for the elements of the array: int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ; initializes primes[0] to 2, primes[1] to 3, primes[2]
More informationReview. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char
Review Primitive Data Types & Variables int, long float, double boolean char String Mathematical operators: + - * / % Comparison: < > = == 1 1.3 Conditionals and Loops Introduction to Programming in
More informationLesson 6A Loops. By John B. Owen All rights reserved 2011, revised 2014
Lesson 6A Loops By John B. Owen All rights reserved 2011, revised 2014 Topic List Objectives Loop structure 4 parts Three loop styles Example of a while loop Example of a do while loop Comparison while
More informationDecision Making -Branching. Class Incharge: S. Sasirekha
Decision Making -Branching Class Incharge: S. Sasirekha Branching The C language programs presented until now follows a sequential form of execution of statements. Many times it is required to alter the
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 information3 The L oop Control Structure
3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement
More informationCMPT 102 Introduction to Scientific Computer Programming
CMPT 102 Introduction to Scientific Computer Programming Control Structures for Loops Janice Regan, CMPT 102, Sept. 2006 0 Control Structures Three methods of processing a program In sequence Branching
More informationApplied Programming and Computer Science, DD2325/appcs15 PODF, Programmering och datalogi för fysiker, DA7011
Applied Programming and Computer Science, DD2325/appcs15 PODF, Programmering och datalogi för fysiker, DA7011 Autumn 2015 Lecture 3, Simple C programming M. Eriksson (with contributions from A. Maki and
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 5 Structured Program Development Department of Computer Engineering How to develop
More informationBBM 102 Introduction to Programming II
BBM 102 Introduction to Programming II Spring 2018 C Review Instructors: Dr. Cumhur Yiğit Özcan, Dr. Ali Seydi Keçeli, Dr. Aydın Kaya TAs: Selim Yılmaz, Bahar Gezici, Cemil Zalluhoğlu Today Introduction
More informationLecture 10. Daily Puzzle
Lecture 10 Daily Puzzle Imagine there is a ditch, 10 feet wide, which is far too wide to jump. Using only eight narrow planks, each no more than 9 feet long, construct a bridge across the ditch. Daily
More informationFundamentals of Programming
Fundamentals of Programming Lecture 5 - Structured Program Development Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad How to develop a program? Requirements Problem Analysis
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 informationContent. In this chapter, you will learn:
ARRAYS & HEAP Content In this chapter, you will learn: To introduce the array data structure To understand the use of arrays To understand how to define an array, initialize an array and refer to individual
More informationWorksheet 4 Basic Input functions and Mathematical Operators
Name: Student ID: Date: Worksheet 4 Basic Input functions and Mathematical Operators Objectives After completing this worksheet, you should be able to Use an input function in C Declare variables with
More informationCalling Prewritten Functions in C
Calling Prewritten Functions in C We've already called two prewritten functions that are found in the C library stdio.h: printf, scanf. The function specifications for these two are complicated (they allow
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 information.. 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 informationCS1100 Introduction to Programming
Decisions with Variables CS1100 Introduction to Programming Selection Statements Madhu Mutyam Department of Computer Science and Engineering Indian Institute of Technology Madras Course Material SD, SB,
More information