F.E. Sem. II. Structured Programming Approach
|
|
- Bertram Ward
- 6 years ago
- Views:
Transcription
1 F.E. Sem. II Structured Programming Approach Time : 3 Hrs.] Mumbai University Examination Paper Solution - May 14 [Marks : 80 Q.1(a) What do you mean by algorithm? Which points you should consider [4] while developing the algorithm. (A) Algorithm is a blueprint of a program. It can be considered as a stepwise procedure to solve a particular problem in finite number of steps. [4 marks] Following point s should be considered while developing an algorithm 1) Sequence : The sequence of the algorithm and as that of program should be same. 2) Correctness : The algorithm is said to be correct if its program correctly solve a problem. 3) Condition : There may be some conditional statements whose execution id depending on a particular condition. 4) Iteration : There may be some iterative statements whose execution will get repeated till there condition is true. 5) Termination : Each algorithm should get terminated correctly. Q.1(b) Determine the type of triangle, given its sides. (i.e. isosceles, [4] scalene, equilateral). Is the above problem definition is complete? if not, make this problem definition complete. (A) The problem definition is not complete. [4 marks] Problem definition : 1) Input : (a) No. of inputs - 03 (b) Type of inputs - integers 2) Output : (a) No. of output - 01 (b) Type of output - message 3) Process : Firstly, we need to accept 3 sides of a triangle and we need to check first whether the triangle can be drawn or not. If the triangle can be drawn then only we can classify it into isosceles, equilateral and scalene triangle. 1
2 : F.E. SPA 1. Start 2. Input sides are a, b, c respectively 3. if ((a + b > c && a + c > b && b + c > a) && (a > 0 && b > 0 && c > 0)) define s as perimeter value s = (a + b + c) / 2.0; define area area = sqrt((s * (s - a) * (s - b) * (s - c))); if (a == b && b == c) print message " It is Equilateral Triangle. " print Area of Equilateral Triangle. 4. else if (a == b b == c a == c) Print the message : Isosceles Triangle. Print Area of an Isosceles Triangle 5. else print the message : Scalene Triangle. Print "Area of Scalene Triangle Else print the message "Triangle formation not possible" 6. STOP Q.1(c) State any 2 library function in string.h along with its uses. [4] (A) [Library function 2 marks each] strcat() : This function concatenates one string at the end of other string. Example : char x[50] = hello ; char y[50] = all ; strcat(x,y) ; //this will make x = helloall Strcmp : This function compares one string with other string. The syntax is int z = strcmp(x,y); //here x and y are strings to be compared. 2
3 strcmp function will return Value > 0 if x >y (ie if first string is greater than second) Value < 0 if x <y (ie if first string is smaller than second) Value = 0 if x = y (ie if first string is equal to second) Example : char x[50] = abcd ; char y[50] = abc ; int z = strcmp(x,y); Here z > 0 as string x is larger than string y. strlen() : This function returns length of the string. Example : char x[50] = hello ; //x is array of 50 characters len = strlen(x); //here value of len = 5 as hello contains 5 characters May 14 Paper Solution Q.1(d) What do you mean by auto and extern storage class? Explain with [4] example. (A) A storage class defines the scope (visibility) and life time of variables and/or functions within a C Program. There are following storage classes which can be used in a C Program auto register static extern (a) auto - Storage Class auto is the default storage class for all local variables. int Count; auto int Month; [2 marks] The example above defines two variables with the same storage class. auto can only be used within functions, i.e. local variables. (b) extern - Storage Class [2 marks] extern is used to give a reference of a global variable that is visible to ALL the program files. When you use 'extern' the variable cannot be initalized as all it does is point the variable name at a storage location that has been previously defined. 3
4 : F.E. SPA When you have multiple files and you define a global variable or function which will be used in other files also, then extern will be used in another file to give reference of defined variable or function. Just for understanding extern is used to decalre a global variable or function in another files. File 1: main.c int count=5; main() write_extern(); File 2: write.c void write_extern(void); extern int count; void write_extern(void) printf("count is %i\n", count); Here extern keyword is being used to declare count in another file. Now compile these two files as follows gcc main.c write.c -o write This fill produce write program which can be executed to produce result. Count in 'main.c' will have a value of 5. If main.c changes the value of count - write.c will see the new value Q.1(e) Explain switch control statement with the help of example. [4] (A) A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case. [4 marks] Syntax: The syntax for a switch statement in C programming language is as follows: switch(expression) case constant-expression : statement(s); break; /* optional */ case constant-expression : statement(s); 4
5 break; /* optional */ /* you can have any number of case statements */ default : /* Optional */ statement(s); May 14 Paper Solution The following rules apply to a switch statement: The expression used in a switch statement must have an integral or enumerated type, or be of a class type in which the class has a single conversion function to an integral or enumerated type. You can have any number of case statements within a switch. Each case is followed by the value to be compared to and a colon. The constant-expression for a case must be the same data type as the variable in the switch, and it must be a constant or a literal. When the variable being switched on is equal to a case, the statements following that case will execute until a break statement is reached. When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the switch statement. Not every case needs to contain a break. If no break appears, the flow of control will fall throughto subsequent cases until a break is reached. A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. Nobreak is needed in the default case. 5
6 : F.E. SPA Example: #include<stdio.h> int main () /* local variable definition */ char grade ='B'; switch(grade) case'a': printf("excellent!\n"); break; case'b': case'c': printf("well done\n"); break; case'd': printf("you passed\n"); break; case'f': printf("better try again\n"); break; default: printf("invalid grade\n"); printf("your grade is %c\n", grade ); return0; When the above code is compiled and executed, it produces the following result: Well done Your grade is B Q.2(a) Write a program in C to delete all the occurrences of given number [10] from an ARRAY. For example, suppose ARRAY A = 2, 5, 3, 9, 2, 2, 3 and given no is 2 then after deletion ARRAY should have A = 5, 3, 9, 3 (A) #include<stdio.h> [10 marks] 6
7 int a[100],i,j,k,n; clrscr( ); printf("\nenter n"); scanf("%d",&n); for(i=0;i<n;i++) printf("\nenter number="); scanf("%d",&a[i]); for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(a[i]==a[j]) for(k=j;k<n;k++) a[k]=a[k+1]; n--; printf("\nnew array is=\n"); for(i=0;i<n;i++) printf("\t%d",a[i]); getch(); May 14 Paper Solution Q.2(b) Write a program to check whether the given number is palindrome [10] or not. i.e if no is it is palindrome. (A) #include<stdio.h> [10 marks] int rev(int b) int rev=0,u; while(b>0) 7
8 : F.E. SPA u=b%10; rev=rev*10+u; b=b/10; return rev; int ispalin(int a) int palin; palin=rev(a); if(palin==a) return 1; else return 0; int n,res; clrscr( ); printf("enter the no\n"); scanf("%d",&n); res=ispalin(n); if(res==1) printf("number is palindrome\n"); else printf("number is not a palinidrome\n"); Q.3(a) What do you mean by Recursion? Write a program which will accept [10] two numbers, n and r and calculate value of nc r = n! / r! (n r)!. Program should make use of recursion. (A) A function that calls itself is known as recursive function and this technique is known as recursion in C programming. Program : #include<stdio.h> int fact(int b) [10 marks] 8
9 int i,fact=1; for(i=1;i<=b;i++) fact=fact*i; return fact; int n,r,x,y,z,ncr,npr; clrscr( ); printf("enter the n,r\n"); scanf("%d%d",&n,&r); x=fact(n); y=fact(r); z=fact(n-r); ncr=x/y*z; npr=x/z; printf("%d C %d is %d\n",n,r,ncr); printf("%d P %d is %d\n",n,r,npr); May 14 Paper Solution Q.3(b) Write a program to sort given nos in Ascending order. [10] (A) [10 marks] #include<stdio.h> int a[10],i,j,n,temp; clrscr( ); printf("enter the value of n\n"); scanf("%d",&n); printf("enter the element of an Array\n"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("before sorting\n"); for(i=0;i<n;i++) 9
10 : F.E. SPA printf("%d ",a[i]); for(i=1;i<n;i++) for(j=0;j<n;j++) if(a[j]>a[j+1]) temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; printf("\nafter sorting\n"); for(i=0;i<n;i++) printf("%d ",a[i]); Q.4(a) A Hospital needs to maintain details of patients. Details to be [10] maintained are, First name, Middle name, Surname, Date of Birth, Disease. Write a C program which will print the list of all patients with given disease. (A) #include<stdio.h> [10 marks] struct patient char fname[20],mname[20],surname[20],dob[20],disease[20]; ; void main() struct patient p[100]; char d[20]; int i, n; printf( Enter number of patients ); scanf( %d, &n); for(i=0; i < n; i++) 10
11 May 14 Paper Solution printf( \nenter first name, middle name, last name, date of birth and disease ); scanf( %s%s%s%s%s, p[i].fname, p[i].mname, p[i].lname, p[i].surname, p[i].dob, p[i].disease); printf( \nenter disease to be searched ); scanf( %s, d); for(i = 0; i < n; i++) if(strcmp(p[i].disease,d) == 0) printf( \n%s%s%s, p[i].fname, p[i].mname, p[i].surname) Q.4(b) Write a program which will accept a 2 dimensional square matrix [10] and find out transpose of it. Program should not make use of another matrix. (A) #include<stdio.h> [10 marks] int a[10][10], n, i, j, t; clrscr( ); printf("\nenter n"); scanf("%d", &n); for(i = 0; i < n; i++) for(j = 0; j < n; j++) printf("\nenter elements="); scanf("%d", &a[i][j]); for(i = 0; i < n; i++) for(j = i + 1; j < n; j++) 11
12 : F.E. SPA t = a[i][j]; a[i][j] = a[j][i]; a[j][i] = t; for(i = 0; i < n; i++) for(j = 0; j < n; j++) printf("%d", a[i][j]); printf("\n"); Q.5(a) Write a program to generate following patterns. (i) 1 (ii) * 2 3 * * * * * * * * (A) (i) Program #include<stdio.h> int i, j, n, a; clrscr( ); printf("enter the no. of rows"); scanf("%d", &n); a = 1; for(i = 1; i <= n; i++) for(j = 1; j <= i; j++) printf("%d", a); a++; printf("\n"); [10] [5 marks] 12
13 May 14 Paper Solution (ii) Program #include<stdio.h> int i, j; for(i = 1; i < 3; i++) for(j = 1; j <= 3 - I; j++) printf( ); for(j = 1; j <= i; j++) printf( * ); printf( \n ); for(i = 2; i >= 1; i--) for(j = 1; j <= 3 - I; j++) printf( ); for(j = 1; j <= i; j++) printf( * ); printf( \n ); [5 marks] Q.5(b) Write a C program to multiply 2 matrices after checking compatibility. Your program should make use of function to accept element of matrix, display matrix, and multiply matrix. [10] 13
14 : F.E. SPA (A) #include<stdio.h> [10 marks] int m, n, p, i, j, a[10][10], b[10][10]; void mul(int a[10][10], int b[10][10], int m, int n, int p); printf( Enter number of rows and columns of matrix 1 ); scanf( %d%d, &m, &n); printf( Enter the values of matrix1 ); for(i = 0, i < m; i++) for(j = 0; j < n; j++) printf( \nenter value= ); scanf( %d,&a[i][j]); printf( \nthe number of rows of matrix 2 is=%d, n); printf( \nenter number of columns of matrix 2 ); scanf( %d,&p); printf( Enter the values of matrix2 ); for(i = 0, i < n; i++) for(j = 0; j < p; j++) printf( \nenter value= ); scanf( %d, &b[i][j]); mul(a, b, m, n, p); void mul(int a[10][10], int b[10][10], int m, int n, int p) int i, j, k, c[10][10]; for(i = 0; i < m; i++) for(j = 0; j < p; j++) c[i][j] = 0; 14
15 for(k = 0; k < n; k++) c[i][j]+ = a[i][k]*b[k][j]; printf( \nthe resultant matrix \n ); for(i = 0; i < m; i++) for(j = 0; j < p; j++) printf( %d, c[i][j]); printf( \n ); May 14 Paper Solution Q.6(a) Write a program to calculate summation of series. [10] 1/2 3/4 + 5/6 7/8 +. upto n terms. (A) #include<stdio.h> [10 marks] int n, i, z = 1, a = 1, b = 2; float s=0.0; printf( \nenter n ); scanf( %d, &n); for(i = 1; i <= n; i++) s = s + (a/b)*z; a = a + 2; b = b + 2; z = -z; printf( \nsummation=%f,s); Q.6(b) What do you mean by FILE? What are the different functions available to read data from file? Specify the different modes in which file can be opened along with syntax. [10] 15
16 : F.E. SPA (A) Abstractly, a file is a collection of bytes stored on a secondary storage device, which is generally a disk of some kind. The collection of bytes may be interpreted, for example, as characters, words, lines, paragraphs and pages from a textual document; fields and records belonging to a database; or pixels from a graphical image. The meaning attached to a particular file is determined entirely by the data structures and operations used by a program to process the file. [10 marks] Different functions to read file : fgetc( ) The fgetc( ) function reads a character from the input file referenced by fp. The return value is the character read, or in case of any error it returns EOF. fgets( ) The functions fgets( ) reads up to n - 1 characters from the input stream referenced by fp. It copies the read string into the buffer buf, appending a null character to terminate the string. If this function encounters a newline character '\n' or the end of the file EOF before they have read the maximum number of characters, then it returns only the characters read up to that point including new line character. fscanf( ) You can also use fscanf function to read strings from a file but it stops reading after the first space character encounters. Different modes in which file can be read : Mode Description r Opens an existing text file for reading purpose. w Opens a text file for writing, if it does not exist then a new file is created. Here your program will start writing content from the beginning of the file. a Opens a text file for writing in appending mode, if it does not exist then a new file is created. Here your program will start appending content in the existing file content. r+ Opens a text file for reading and writing. w+ Opens a text file for reading and writing both. It first truncate the file to zero length if it exists otherwise create the file if it does not exist. a+ Opens a text file for reading and writing both. It creates the file if it does not exist. The reading will start from the beginning but writing can only be appended. 16
F.E. Sem. II. Structured Programming Approach
F.E. Sem. II Structured Programming Approach Time : 3 Hrs.] Mumbai University Examination Paper Solution - May 13 [Marks : 80 Q.1(a) Explain the purpose of following standard library functions : [3] (i)
More information'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 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 informationCP FAQS Q-1) Define flowchart and explain Various symbols of flowchart Q-2) Explain basic structure of c language Documentation section :
CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart ANS. Flowchart:- A diagrametic reperesentation of program is known as flowchart Symbols Q-2) Explain basic structure of c language
More informationQ 1. Attempt any TEN of the following:
Subject Code: 17212 Model Answer Page No: 1 / 26 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The
More informationComputer 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 informationComputer Programing. for Physicists [SCPY204] Class 02: 25 Jan 2018
Computer Programing Class 02: 25 Jan 2018 [SCPY204] for Physicists Content: Data, Data type, program control, condition and loop, function and recursion, variable and scope Instructor: Puwis Amatyakul
More informationWrite 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 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 informationColumns A[0] A[0][0] = 20 A[0][1] = 30
UNIT Arrays and Strings Part A (mark questions). What is an array? (or) Define array. An array is a collection of same data type elements All elements are stored in continuous locations Array index always
More informationUnit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?
1 What is an array? Explain with Example. What are the advantages of using an array? An array is a fixed-size sequenced collection of elements of the same data type. An array is derived data type. The
More informationBCSE1002: Computer Programming and Problem Solving LAB MANUAL
LABMANUAL BCSE1002: Computer Programming and Problem Solving LAB MANUAL L T P Course Type Semester Offered Academic Year 2018-2019 Slot Class Room Faculty Details: Name Website link Designation School
More informationHISTORY OF C LANGUAGE. Facts about C. Why Use C?
1 HISTORY OF C LANGUAGE C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Introduction to arrays 1 What are Arrays? Arrays are our first example of structured data. Think of a book with pages numbered 1,2,...,400.
More informationClassification s of Data Structures
Linear Data Structures using Sequential organization Classification s of Data Structures Types of Data Structures Arrays Declaration of arrays type arrayname [ arraysize ]; Ex-double balance[10]; Arrays
More informationAryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9
Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths
More informationF.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C
F.Y. Diploma : Sem. II [CO/CD/CM/CW/IF] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1 (a) List any four relational operators.
More informationGovernment Polytechnic Muzaffarpur.
Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking
More informationUnit 3 Decision making, Looping and Arrays
Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.
More informationInformatics Ingeniería en Electrónica y Automática Industrial. Control flow
Informatics Ingeniería en Electrónica y Automática Industrial Control flow V1.1 Autores Control Flow Statements in C language Introduction if-else switch while for do-while break continue return goto 2
More informationQuestions Bank. 14) State any four advantages of using flow-chart
Questions Bank Sub:PIC(22228) Course Code:-EJ-2I ----------------------------------------------------------------------------------------------- Chapter:-1 (Overview of C Programming)(10 Marks) 1) State
More informationArrays. Arrays are of 3 types One dimensional array Two dimensional array Multidimensional array
Arrays Array is a collection of similar data types sharing same name or Array is a collection of related data items. Array is a derived data type. Char, float, int etc are fundamental data types used in
More informationUNIT III ARRAYS AND STRINGS
UNIT III ARRAYS AND STRINGS Arrays Initialization Declaration One dimensional and Two dimensional arrays. String- String operations String Arrays. Simple programs- sorting- searching matrix operations.
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 informationWAP 10. WAP 11. WAP 12. WAP 13. WAP 14. WAP 15. WAP 16. WAP 1. : 17. WAP 18. WAP 19. WAP 20. WAP 21. WAP 22. WAP 23. WAP & 24. WAP
Contents 1. WAP to accept the value from the user and exchange the values.... 2 2. WAP to check whether the number is even or odd.... 2 3. WAP to Check Odd or Even Using Conditional Operator... 3 4. WAP
More informationComputers Programming Course 12. Iulian Năstac
Computers Programming Course 12 Iulian Năstac Recap from previous course Strings in C The character string is one of the most widely used applications that involves vectors. A string in C is an array of
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationmith College Computer Science CSC231 C Tutorials Fall 2017 Introduction to C Dominique Thiébaut
mith College Computer Science CSC231 C Tutorials Fall 2017 Introduction to C Dominique Thiébaut dthiebaut@smith.edu mith College Computer Science Learning C in 4 Hours! D. Thiebaut Dominique Thiébaut dthiebaut@smith.edu
More informationPDS Class Test 2. Room Sections No of students
PDS Class Test 2 Date: October 27, 2016 Time: 7pm to 8pm Marks: 20 (Weightage 50%) Room Sections No of students V1 Section 8 (All) Section 9 (AE,AG,BT,CE, CH,CS,CY,EC,EE,EX) V2 Section 9 (Rest, if not
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 informationUNIT 2 ARRAYS 2.0 INTRODUCTION. Structure. Page Nos.
UNIT 2 ARRAYS Arrays Structure Page Nos. 2.0 Introduction 23 2.1 Objectives 24 2.2 Arrays and Pointers 24 2.3 Sparse Matrices 25 2.4 Polynomials 28 2.5 Representation of Arrays 30 2.5.1 Row Major Representation
More informationVidyalankar F.Y. Diploma : Sem. II [CD/CM/CO/CW/DE/ED/EE/EI/EJ/EN/EP/ET/EV/EX/IC/IE/IF/IS/IU/MU] Programming in C
F.Y. Diploma : Sem. II [CD/CM/CO/CW/DE/ED/EE/EI/EJ/EN/EP/ET/EV/EX/IC/IE/IF/IS/IU/MU] Programming in C Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 100 Q.1 Attempt any TEN of the following : [20]
More informationC programming basics T3-1 -
C programming basics T3-1 - Outline 1. Introduction 2. Basic concepts 3. Functions 4. Data types 5. Control structures 6. Arrays and pointers 7. File management T3-2 - 3.1: Introduction T3-3 - Review of
More informationPESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities
INTERNAL ASSESSMENT TEST-3 Date : 12-05-2016 Marks: 40 Subject & Code : Programming in C and data structures (15PCD23) Sec : F,G,H,I,J,K Name of faculty :Dr J Surya Prasad/Mr.Sreenath M V/Ms.Monika/ Time
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 informationF.E. Sem - 2 CBCGS SPA MAY 17
F.E. Sem 2 CBCGS SPA MAY 17 Q.1.a.) Convert 0010 0100 0010 1101 from base 2 to decimal. Convert 134 from base 10 to hexadecimal. Write steps for conversion. Ans: Binary to decimal: The steps to be followed
More informationWeek 8 Lecture 3. Finishing up C
Lecture 3 Finishing up C Conditional Operator 2 Conditional Operator Syntax Value ? : If condition is true, expression1, otherwise expresion2 Example 0 > x? x : -x
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 information1. Simple if statement. 2. if else statement. 3. Nested if else statement. 4. else if ladder 1. Simple if statement
UNIT- II: Control Flow: Statements and Blocks, if, switch statements, Loops: while, do-while, for, break and continue, go to and Labels. Arrays and Strings: Introduction, One- dimensional arrays, Declaring
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities
PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities Continuous Internal Evaluation Test 2 Date: 0-10- 2017 Marks: 0 Subject &
More informationLab Manual B.Tech 1 st Year
Lab Manual B.Tech 1 st Year Fundamentals & Computer Programming Lab Dev Bhoomi Institute of Technology Dehradun www.dbit.ac.in Affiliated to Uttrakhand Technical University, Dehradun www.uktech.in CONTENTS
More informationC-LANGUAGE CURRICULAM
C-LANGUAGE CURRICULAM Duration: 2 Months. 1. Introducing C 1.1 History of C Origin Standardization C-Based Languages 1.2 Strengths and Weaknesses Of C Strengths Weaknesses Effective Use of C 2. C Fundamentals
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 information/* Area and circumference of a circle */ /*celsius to fahrenheit*/
/* Area and circumference of a circle */ #include #include #define pi 3.14 int radius; float area, circum; printf("\nenter radius of the circle : "); scanf("%d",&radius); area = pi
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 informationB.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University
Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are
More informationSample Paper - II Subject Computer Science
Sample Paper - II Subject Computer Science Max Marks 70 Duration 3 hrs Note:- All questions are compulsory Q1) a) What is significance of My Computer? 2 b) Explain different types of operating systems.
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 informationMAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-I PART-A 1. What is
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
Subject Code: 17212 Model Answer Page No: 1/28 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model
More informationSRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I
SRI VIDYA COLLEGE OF ENGINEERING & TECHNOLOGY, VIRUDHUNAGAR Department of CSE & IT Internal Test I Year & Sem: I B.E (CSE) & II Date of Exam: 21/02/2015 Subject Code & Name: CS6202 & Programming & Data
More informationTo store the total marks of 100 students an array will be declared as follows,
Chapter 4 ARRAYS LEARNING OBJECTIVES After going through this chapter the reader will be able to declare and use one-dimensional and two-dimensional arrays initialize arrays use subscripts to access individual
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( Mid Semester ) SEMESTER ( Autumn ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming
More informationPES INSTITUTE OF TECHNOLOGY (BSC) I MCA, First IA Test, November 2015 Programming Using C (13MCA11) Solution Set Faculty: Jeny Jijo
PES INSTITUTE OF TECHNOLOGY (BSC) I MCA, First IA Test, November 2015 Programming Using C (13MCA11) Solution Set Faculty: Jeny Jijo 1. (a)what is an algorithm? Draw a flowchart to print N terms of Fibonacci
More informationmith College Computer Science CSC231 C Tutorials Fall 2017 Introduction to C Dominique Thiébaut
mith College Computer Science CSC231 C Tutorials Fall 2017 Introduction to C Dominique Thiébaut dthiebaut@smith.edu mith College Computer Science Learning C in 4 Hours! D. Thiebaut Dominique Thiébaut dthiebaut@smith.edu
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationCGS 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 informationModel Viva Questions for Programming in C lab
Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous
More informationM4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE
M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be
More informationWhat is recursion. WAP to find sum of n natural numbers using recursion (5)
DEC 2014 Q1 a What is recursion. WAP to find sum of n natural numbers using recursion (5) Recursion is a phenomenon in which a function calls itself. A function which calls itself is called recursive function.
More informationonly in the space provided. Do the rough work in the space provided for it. The question paper has total 12 pages.
Instructions: Answer all five questions. Total marks = 10 x 2 + 4 x 10 = 60. Time = 2hrs. Write your answer only in the space provided. Do the rough work in the space provided for it. The question paper
More informationARRAYS(II Unit Part II)
ARRAYS(II Unit Part II) Array: An array is a collection of two or more adjacent cells of similar type. Each cell in an array is called as array element. Each array should be identified with a meaningful
More informationBİL200 TUTORIAL-EXERCISES Objective:
Objective: The purpose of this tutorial is learning the usage of -preprocessors -header files -printf(), scanf(), gets() functions -logic operators and conditional cases A preprocessor is a program that
More informationQ1. Multiple Choice Questions
Rayat Shikshan Sanstha s S. M. Joshi College, Hadapsar Pune-28 F.Y.B.C.A(Science) Basic C Programing QUESTION BANK Q1. Multiple Choice Questions 1. Diagramatic or symbolic representation of an algorithm
More informationStructured programming
Exercises 6 Version 1.0, 25 October, 2016 Table of Contents 1. Arrays []................................................................... 1 1.1. Declaring arrays.........................................................
More informationLABORATORY MANUAL. (CSE-103F) FCPC Lab
LABORATORY MANUAL (CSE-103F) FCPC Lab Department of Computer Science & Engineering BRCM College of Engineering & Technology Bahal, Haryana Aim: Main aim of this course is to understand and solve logical
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 informationVidyalankar. F.E. Sem. II Structured Programming Approach Prelim Question Paper Solution
1. (a) 1. (b) 1. (c) F.E. Sem. II Structured Programming Approach C provides a variety of stroage class specifiers that can be used to declare explicitly the scope and lifetime of variables. The concepts
More informationFile I/O. Arash Rafiey. November 7, 2017
November 7, 2017 Files File is a place on disk where a group of related data is stored. Files File is a place on disk where a group of related data is stored. C provides various functions to handle files
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 informationITC213: 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 informationSubject: 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 informationDECISION CONTROL AND LOOPING STATEMENTS
DECISION CONTROL AND LOOPING STATEMENTS DECISION CONTROL STATEMENTS Decision control statements are used to alter the flow of a sequence of instructions. These statements help to jump from one part of
More information// CSE/CE/IT 124 JULY 2015, 2.a. algorithm to inverse the digits of a given integer. Step 1: Start Step 2: Read: NUMBER Step 3: r=0,rev=0
// CSE/CE/IT 124 JULY 2015, 2a algorithm to inverse the digits of a given integer Step 1: Start Step 2: Read: NUMBER Step 3: r=0,rev=0 Step 4: repeat until NUMBER > 0 r=number%10; rev=rev*10+r; NUMBER=NUMBER/10;
More informationBITS PILANI, DUBAI CAMPUS DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI FIRST SEMESTER
BITS PILANI, DUBAI CAMPUS DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI FIRST SEMESTER 2017-2018 COURSE : COMPUTER PROGRAMMING (CS F111) COMPONENT : Tutorial#4 (SOLUTION) DATE : 09-NOV-2017 Answer 1(a). #include
More informationCS1100 Introduction to Programming
CS1100 Introduction to Programming Arrays Madhu Mutyam Department of Computer Science and Engineering Indian Institute of Technology Madras Course Material SD, SB, PSK, NSN, DK, TAG CS&E, IIT M 1 An Array
More informationUNIT 6. STRUCTURED DATA TYPES PART 1: ARRAYS
UNIT 6. STRUCTURED DATA TYPES PART 1: ARRAYS Programming Year 2017-2018 Industrial Technology Engineering Paula de Toledo Contents 1. Structured data types vs simple data types 2. Arrays (vectors and matrices)
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationSUMMER 13 EXAMINATION Model Answer
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationBangalore South Campus
USN: 1 P E PESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities INTERNAL ASSESSMENT TEST 3 Date: 22/11/2017 Time:11:30am- 1.00 pm
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 8 Array typical problems, Search, Sorting Department of Computer Engineering Outline
More informationList of Programs: Programs: 1. Polynomial addition
List of Programs: 1. Polynomial addition 2. Common operations on vectors in c 3. Matrix operation: multiplication, transpose 4. Basic Unit conversion 5. Number conversion: Decimal to binary 6. Number conversion:
More informationDepartment 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 informationQUIZ: loops. Write a program that prints the integers from -7 to 15 (inclusive) using: for loop while loop do...while loop
QUIZ: loops Write a program that prints the integers from -7 to 15 (inclusive) using: for loop while loop do...while loop QUIZ: loops Write a program that prints the integers from -7 to 15 using: for
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 informationFUNCTIONS OMPAL SINGH
FUNCTIONS 1 INTRODUCTION C enables its programmers to break up a program into segments commonly known as functions, each of which can be written more or less independently of the others. Every function
More informationTypes of Data Structures
DATA STRUCTURES material prepared by: MUKESH BOHRA Follow me on FB : http://www.facebook.com/mukesh.sirji4u The logical or mathematical model of data is called a data structure. In other words, a data
More information20 Dynamic allocation of memory: malloc and calloc
20 Dynamic allocation of memory: malloc and calloc As noted in the last lecture, several new functions will be used in this section. strlen (string.h), the length of a string. fgets(buffer, max length,
More information8. Characters, Strings and Files
REGZ9280: Global Education Short Course - Engineering 8. Characters, Strings and Files Reading: Moffat, Chapter 7, 11 REGZ9280 14s2 8. Characters and Arrays 1 ASCII The ASCII table gives a correspondence
More informationComputer Programming Unit v
READING AND WRITING CHARACTERS We can read and write a character on screen using printf() and scanf() function but this is not applicable in all situations. In C programming language some function are
More informationStructured Programming. Functions and Structured Programming. Functions. Variables
Structured Programming Functions and Structured Programming Structured programming is a problem-solving strategy and a programming methodology. The construction of a program should embody topdown design
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 17 EXAMINATION Subject Name: Data Structure Using C Model Answer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as
More informationArrays, Strings, & Pointers
Arrays, Strings, & Pointers Alexander Nelson August 31, 2018 University of Arkansas - Department of Computer Science and Computer Engineering Arrays, Strings, & Pointers Arrays, Strings, & Pointers are
More informationC Concepts - I/O. Lecture 19 COP 3014 Fall November 29, 2017
C Concepts - I/O Lecture 19 COP 3014 Fall 2017 November 29, 2017 C vs. C++: Some important differences C has been around since around 1970 (or before) C++ was based on the C language While C is not actually
More informationComputer Programming Unit 3
POINTERS INTRODUCTION Pointers are important in c-language. Some tasks are performed more easily with pointers such as dynamic memory allocation, cannot be performed without using pointers. So it s very
More informationSingle 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 informationComputers Programming Course 11. Iulian Năstac
Computers Programming Course 11 Iulian Năstac Recap from previous course Cap. Matrices (Arrays) Matrix representation is a method used by a computer language to store matrices of different dimension in
More informationAPS105. Collecting Elements 10/20/2013. Declaring an Array in C. How to collect elements of the same type? Arrays. General form: Example:
Collecting Elements How to collect elements of the same type? Eg:., marks on assignments: APS105 Arrays Textbook Chapters 6.1-6.3 Assn# 1 2 3 4 5 6 Mark 87 89 77 96 87 79 Eg: a solution in math: x 1, x
More informationUnited States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017
United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017 1. Do a page check: you should have 8 pages including this cover sheet. 2. You have 50 minutes
More informationScheme of valuations-test 3 PART 1
Scheme of valuations-test 3 PART 1 1 a What is string? Explain with example how to pass string to a function. Ans A string constant is a one-dimensional array of characters terminated by a null ( \0 )
More information