F.E. Sem. II. Structured Programming Approach

Size: px
Start display at page:

Download "F.E. Sem. II. Structured Programming Approach"

Transcription

1 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) Floor ( ) (ii) ceil ( ) (iii) sqrt ( ) (A) Rounding is done to the nearest integer. Actual rounding is done with respect to 0.5. C provides function for either rounding up or rounding down : (i) Floor ( ) is used for rounding down. [1 mark] (ii) ceil ( ) is used for rounding up. [1 mark] (iii) sqrt ( ) is used to find the square root of the given number. [1 mark] Q.1(b) Explain how problem is defined with a help of suitable example. [4] (A) The problem is defined with respect to inputs, outputs and the steps required for processing. The input along with its type is identified. The formula required for finding the answer is also identified with all its substeps. The type of the output to be produced is also finalized. [3 marks] e.g. To find the area of circle : [1 mark] Inputs : radius of a circle Type : real Output : area Type : real Formula : PI * r * r Where PI represents 3.14 Q.1(c) Explain difference between for, while and do while loop. [3] (A) For loop is used to repeat the same set of statements multiple times. Similarly while and do while loop. When the number of iterations are known then for loop is used. Otherwise while loop is preferable. [1 mark] e.g. display first n integers [1 mark] for (i = 0; i < n; i++) printf( %d, i); Using while loop Int i = 1; while(i <= n) Printf( %d, i); I++; 1

2 : F.E. SPA In do.. while, the condition is kept at the end and the loop will be executed even if the condition is false in the beginning. [1 mark] Q.1(d) Explain difference between call by value and call by reference. [4] (A) Earlier we have seen functions and function calls. When we passed the actual arguments, their copies are created into formal arguments; this method of calling function is called Call by Value. Let s take one example. int add (int a, int b) return (a+b); void main( ) int x = 2, y = 3, z; z = add(x, y); cout << Addition = << z << endl; Now here copies of x and y are created in a and b which are used for addition. If we change anything in a and b, then the changes are not reflected back in x and y. Hence call by value does not allow to change the actual argument. But here as we just want to add a and b and don t want to change them call by value suits the scenario. Hence in case of such situations where we don t want to change the formal arguments call by value is the best option. But now look at the following example. A function swap is written using call by value to swap the values of the integer variables. When the function is called by passing the reference / address of the variables then it is called as Call by reference. Let us see one example. void swap (int *a, int *b) int temp; temp = *a; *a = *b; *b= temp; void main ( ) int x,y; 2

3 May 13 Paper Solution cout<< Enter x and y\n ; cin >> x >> y ; swap (&x, &y) ; cout<< X = << x << Y= << y; Now suppose the user enters x and y as 2 and 3 respectively then the final output will be X = 3, Y = 2 which is not possible in the absence of call by reference. [4 marks for 4 points] Q.1(e) Explain any three string standard library functions. [3] (A) String Manipulating functions 1) Strlen (String Length) [1 mark] This functions is used to find the length of the given string. The functions takes string variable or string constant as a parameter and returns int value indicating the length. The null character is not considered while calculating length. e.g. int n = strlen ( STAR ); // n = 4 char n [ ] = TESTED OK ; int n = strlen (a); // n = 9 2) Strcmp (String Compares) [1 mark] The strcmp function compares two strings identified by the argument and has a value O. if they are equal. If they are not, it has the numeric difference between the first non-matching characters in the strings. strcmp (str1, str2) Where str and str 2 can either be string variables or constants. e.g. strcmp (str1, str2) strcmp (str1, STAR ); strcmp ( MAKE, MALE ); We are generally required to compare two strings lexicographically. i.e. alphabetically. If the answer is O. then two strings are equivalent. strcmp ( A, B ); Now mismatch occurs and hence it returns difference between Ascll value of A and B ie 1. Hence negative answer confirms that string 1 is alphabetically above than string 2. Hence we can draw the following conclusion. n = stcat (str1, str2); then if n = 0 str1 and str2 are same if n < 0 str1 is alphabetically above that str2 if n > 0 str2 is alphabetically above than str1 3

4 : F.E. SPA 3) Strcpy (String Copy) [1 mark] Strcpy basically serves the purpose of assigning one string to another. As we have seen that the direct assignment of string variable is not possible. Hence str1 = str2 is invalid. But this can be done as follows : strcpy (str1, str2); It copies str2 into str1. Hence original contents of str1 (if any) are lost but that of str2 remains same. Care should be taken that the length of array st1 should be atleast equal to array str2. In strcpy, str2 can be either string variable or string constant. But str1 has to be a string variable as it stores contents of str2 after copying. i.e. str2 gets assigned to strl. e.g. strcpy (str1, str2) str2 is copied int str1. strcpy (str1, MECH ); MECH is copied into str1. strcpy ( AUTO, RUN ); is invalid. Q.1(f) Explain reference and de-reference operators with example. [3] (A) Reference operator is used to compute address of a variable which can be stored using pointer. Dereference operator is used to retrieve back the value pointed by the pointer. [2 marks] e.g. int a = 20; [1 mark] int *p = &a; // reference int z = *p; // dereference Dereference operator is also called as indirection or value at operator. Q.2(a) Explain various storage classes used in c with example. [5] (A) Storage Classes : [for each point 1 mark, for example 1 mark] C++ provides total four storage classes as follow : 1) Automatic (auto) 2) External (extern) 3) Static (static) 4) Register (register) Automatic Variables (auto) The default storage class of a local variable is automatic. Hence it is actually a local variable. The scope is within the function in which it is declared and even the lifetime is till that function or a block is active. 4

5 May 13 Paper Solution Hence these variables are created on every call to that function and destroyed when the function is terminated. So they are not able to retain their value. int a; is equivalent to auto int a; The automatic variables store garbage values till they are explicitly initialized. External Variables (extern) The global variable s scope starts from the point of declaration till the end of the program. But the functions before the global variable declaration cannot access it. For Example; void main( ) p = p+5; // Compiler error : Undefined Symbol p int p; void function1 ( ) p = 10; Compiler doesn t identify p in main as it is declared after it. Hence to avoid this we can re-declare p as extern in main. Hence no extra memory space will be allocated to p but compiler understands that p is integer type of variable that is declared somewhere else. Hence it allows main to access it. void main( ) extern int p; ---- p = p + 5; int p; void function1 ( ) p = 10; 5

6 : F.E. SPA Static Variables (static) As we have seen regarding auto (local) variables that they get destroyed as soon as the function in which they are declared is terminated. Hence local variables cannot retain their values. The solution to this is static variables. These variables are local variables that are also defined within the function but their lifetime is till the end of the program. Hence they are created at the first call to the function but do not get destroyed when the function terminated. They also retain their values till the next time function is called. void main ( ) display( ); display( ); void display( ) static int a = 5; a = a + 1; cout << a; The output of the above program is 6 7 as the changed value of a in first call is carried till the second call. If a would not be made static the output would be 6 6. Register Variables (register) The variables which are frequently required should be kept in machine s registers rather than keeping it in the memory. So the access becomes rapid and a lot of time is conserved. This can be done by making the variables storage class as register. There are only few registers available, but C doesn t provide any restriction on making variable register although he internally converts register variable to non-register once the limit is reached. register int a; It makes a as register variable, the other characteristics it possesses like normal local variable 6

7 May 13 Paper Solution Q.2(b) Write a program to calculate sum of list by passing array to a [5] function. (A) Int findsum(int x[ ], int n) [5 marks] Int s=0,i; For (i=0; i < n; i++) s = s + x[i]; return s; Void main( ) int a[20], n, i; printf( Enter no of elements ); scanf( %d, &n); for (i = 0; i < n; i++) scanf( %d, &a[i]); int sum = findsum(a, n); printf( Sum = %d, sum); Q.2(c) Write a c-program to create an array of structure to store the [10] details of almost 100 employees. And sort it according to employee ID. Employee details are as follows: (i) Employee Name (ii) Employee ID (iii) Employee Salary (A) Typedef struct [10 marks] Char name[50]; Int id, sal; employee; Void sort(employee x[ ], int n) Int I, j; For (i = 0; i < n - 1; i++) For (j = 0; j < n - 1; j++) If (x[j].id > x[j+1].id) Employee t = x[j]; 7

8 : F.E. SPA X[j] = x[j+1]; X[j+1] = t; Void main( ) Employee e[100]; Int I; For (i = 0; i < 100; i++) scanf( %s%d%d,&e[i].name, &e[i].id,&e[i].sal); sort(e, n); For (i = 0; i < n; i++) printf( %s %d %d\n,e[i].name, e[i].id,e[i].sal); Q.3(a) Write an algorithm and draw flowchart to calculate roots of [6] quadratic equation. (A) Algorithm : [3 marks] 1) start 2) accept coefficients a, b, c 3) find d=b*b - 4ac 4) if d > 0 then 5) roots are real and disitinct 6) calculate root 1 and root 2 7) go to step 14 8) if d < 0 then 9) roots are imaginary 10) calculate real and imaginary part of root1 and root2 11) go to step 14 12) print roots are real and equal 13) calculate root 14) stop 8

9 May 13 Paper Solution Flowchart : [3 marks] Start accept coefficient a, b, c d = b * b 4 + a * c No yes d > 0 r 1 = b b 4ac r 2 = b b 4ac 2 2 display r 1, r 2 Stop Q.3(b) Write a program to display pascal triangle. [6] A A B A B C A B C D A B C D E (A) Void main( ) [6 marks] Int n, I, j; Char ch= A ; Printf( Enter no of lines ); 9

10 : F.E. SPA Scanf( %d, &n); For (i = 1; i <= n; i++) Ch= A ; for (j = 1; j <= I; j++) Printf( %c, ch++); Printf( \n ); Q.3(c) Explain recursion concept. Write a program to display Fibonacci [8] series using recursion. (A) Recursion is the process of calling a function within itself. Hence recursion tries to make a parallel option to the iterative procedures. As the definition suggests, each time the function is called it will call itself again within its body hence it feels that it will result in infinite iterations. But the recursion has to be controlled properly that is after a certain iterations the function should not allowed to call itself again. [4 marks] For any program to solve with the recursion the following three prerequisites can be listed out. 1) A program should be recursive in nature then only it becomes convenient to use a recursive approach. All iterative procedures may not be converted into recursive efficiently. 2) There should be a terminating condition which when becomes false, the recursion stops that is the same function is not called further. 3) Even the care has to be taken that during the execution of the program the above-mentioned terminating condition should be reached. Otherwise again the program will go into infinite loops. Now lets take some examples for a comparative study. In recursive we get two terminating condition as : fibo(1) = 1 and fibo (2) =1 For general value of n we can use the formula as, fibo (n) = fibo (n-1) + fibo (n-2) Again a recursion can be seen clearly and as we are decrementing value of n, the terminating conditions will surely be reached. Recursive Solution [4 marks] /*********** Recursive Fibo *********/ int fibo (int n) if (n==1 n==2) 10

11 return 1; return (fibo(n-1)+fibo(n-2)); void main() int num; clrscr( ); cout<<enter a number\n"; cin>>num; cout<<"required fibo number is <<fibo(num); getch( ); May 13 Paper Solution Q.4(a) Write an algorithm to sort set of numbers in ascending order. For [6] above problem in which cases time complexity is calculated. (A) Algorithm : [4 marks] 1) start 2) accept array of n integers 3) for i= 0 to n-1 do 4) for j=0; to n-1 do 5) if x(j) > x(j+1) then 6) exchange x(j) with x(j+1) 7) print elements of the array 8) stop Time complexity is calculated for two nested for loops. Outer for loop is executed for (n 1) times. Whereas inner for loop is executed for (n 1) times. The overall execution of for loop is tabulated below : Outer for loop Inner for loop i = 0 j = 0 j = 1 j = 2 j = 3 j = n 1 i = 1 j = 0 j = 1 j = n 1 [2 marks] 11

12 : F.E. SPA i = n 1 j = 0 j = 1 j = n 1 hence total number of for loop execution is (n 1) * (n 1) n 2 hence time complexity of above for loop is T(n 2 ). Q.4(b) Write a program to display Armstrong nos between 1 to [6] (A) Int ispalin(int num) [6 marks] int r = 0, u, k = num; While(num!=0) U = num%10; R = r*10 + u; Num = num%10; if (k==r) Return 1; Else return 0; Void main( ) int I; for (i=0; i<=1000;l i++) if (ispalin(i)==1) Pritnf( %d,i) Q.4(c) Write a program to calculate matrix multiplication and transpose [8] for a matrix. (A) #include <stdio.h> [8 marks] int main( ) int m, n, p, q, c, d, k, sum = 0; int first[10][10], second[10][10], multiply[10][10]; 12

13 May 13 Paper Solution printf("enter the number of rows and columns of first matrix\n"); scanf("%d%d", &m, &n); printf("enter the elements of first matrix\n"); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < n ; d++ ) scanf("%d", &first[c][d]); printf("enter the number of rows and columns of second matrix\n"); scanf("%d%d", &p, &q); if ( n!= p ) printf("matrices with entered orders can't be multiplied with each other.\n"); else printf("enter the elements of second matrix\n"); for ( c = 0 ; c < p ; c++ ) for ( d = 0 ; d < q ; d++ ) scanf("%d", &second[c][d]); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < q ; d++ ) for ( k = 0 ; k < p ; k++ ) sum = sum + first[c][k]*second[k][d]; multiply[c][d] = sum; sum = 0; printf("product of entered matrices:-\n"); for ( c = 0 ; c < m ; c++ ) for ( d = 0 ; d < q ; d++ ) printf("%d\t", multiply[c][d]); printf("\n"); return 0; 13

14 : F.E. SPA Q.5(a) Write a output for following program: [6] # include <stdio.h> Void main ( ) int x = 10, y, z; z = y = x; y = x; z = x ; x = x x ; printf( x = %d y = %d z = %d, x, y, z);p (A) Output [6 marks] Q.5(b) WAP to calculate sum of series 1/2 + 3/4 + 5/ n terms. [6] (A) Void main( ) [6 marks] int i; Float s=0; For (i=1; i<n; i=i+2) S= s+ (float) i / i+1; Printf( %f,s); Q.5(c) Write a program to calculate matrix multiplication and transpose [8] for a matrix. (A) #include<stdio.h> [8 marks] #include<conio.h> void main() int m, n, p, i, j, a[10][10], b[10][10] ; void MatMul (int a[10][10], int b[10][10], int m, int n, int p); clrscr(); printf("enter the number of rows and columns of matrix 1:"); scanf("%d %d", &m, &n); printf("enter the values of matrix l\n"); for(i=0;i<=m1;i++) for(j=0;j<=n1;j++) 14

15 printf("enter a value:"); scanf("%d", &a[i] [j]) ; printf("the number of rows for matrix 2 will be %d\n",n); printf("enter the columns of matrix 2:"); scanf("%d", &p); printf("enter the elements of matrix 2:\n"); for (i=0;i<=n1;i++) for(j=0;j<=p1;j++) printf("enter a value:"); scanf("%d", &b[i] [j]) ; MatMul (a, b, m, n, p); getch(); void MatMul (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<=m1; i++) for(j=0;j<=p1;j++) c[i] [j]=0; for(k=0;k<=n1;k++) c[i] [j]=c[i] [j]+a[i] [k]*b[k] [j]; printf("the resultant matrix is:\n"); for(i=0;i<=m1;i++) for(j=0;j<=p1;j++) printf("%d\t", c[i] [j]) ; May 13 Paper Solution 15

16 : F.E. SPA printf("\n"); #include<stdio.h> #include<conio.h> void main() int m, n, i, j, a [10] [10]; void transpose (int a[10][10], int m, int n); clrscr(); printf("enter the number of rows and columns:"); scanf("%d %d", &m, &n); for(i=0;i<=m1;i++) for(j=0;j<=n1;j++) printf("enter a value:"); scanf("%d", &a[i][j]); printf("the original Matrix is:\n"); for(i=0;i<=m-l;i++) for(j=0;j<=n1;j++) printf("%d \t", a[i] [j] ) ; printf("\n"); transpose(a, m, n); getch(); void transpose (int a[10] [10], int m, int n) int b[10] [10], i, j; for(i=0;i<=m1;i++) for(j=0;j<=n1;j++) b[j] [i]=a[i] [j] ; 16

17 printf("the transpose of this matrix is:\n"); for (i=0;i<=n1;i++) for(j=0;j<=m1;j++) printf("%d\t", b[i][j]); printf("\n"); May 13 Paper Solution Q.6(a) Explain difference between switch statement, ladder of if else and [6] nested if else. (A) The if statement by itself will execute a single statement, or a group of statements, when the expression following if evaluates to true. It does nothing when the expression evaluates to false. Can we execute one group of statements if the expression evaluates to true and another group of statements if the expression evaluates to false? Of course! This is what is the purpose of the else statement. For example :In a company an employee is paid as under If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA = 90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the employee's salary is input through the keyboard write a program to find his gross salary. /* Calculation of gross salary */ main( ) floatbs, gs, da, hra ; printf ( "Enter basic salary " ) ; scanf ( "%f", &bs ) ; if ( bs< 1500 ) hra = bs * 10 / 100 ; da = bs * 90 / 100 ; else 17

18 : F.E. SPA hra = 500 ; da = bs * 98 / 100 ; gs = bs + hra + da ; printf ( "gross salary = Rs. %f", gs ) ; nested if-else. It is perfectly all right if we write an entire if-else construct within either the body of the if statement or the body of an else statement. This is called nesting of ifs. This is shown in the following program. /* A quick demo of nested if-else */ main( ) inti ; printf ( "Enter either 1 or 2 " ) ; if ( i == 1 ) printf ( "You would go to heaven!" ) ; else if ( i == 2 ) 18

19 printf ( "Hell was created with you in mind" ) ; else printf ( "How about mother earth!" ) ; May 13 Paper Solution LOOPS The versatility of the computer lies in its ability to perform a set of instructions repeatedly. This involves repeating some portion of the program either a specified number of times or until a particular condition is being satisfied. There are three methods by way of which we can repeat a part of a program. They are: (a) Using a for statement (b) Using a while statement (c) Using a do-while statement switch case statement 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. 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); break; /* optional */ /* you can have any number of case statements */ default : /* Optional */ statement(s); 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. 19

20 : F.E. SPA 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 through to 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. No break is needed in the default case. Example: #include<stdio.h> int main () /* local variable definition */ char grade ='B'; 20

21 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 ); May 13 Paper Solution return0; When the above code is compiled and executed, it produces the following result: Well done Your grade is B [6 marks] Q.6(b) Write a recursive program to calculate factorial of accepted number. [6] (A) #include<stdio.h> [6 marks] int fact(int); int main( ) int num,f; printf("\nenter a number: "); scanf("%d", &num); f = fact(num); printf("\nfactorial of %d is: %d",num,f); return 0; 21

22 : F.E. SPA int fact(int n) if(n==1) return 1; else return(n*fact(n-1)); Q.6(c) Write a program to validate whether accepted string is palindrome [5] or not. (A) Implementation: [5 marks] #include<stdio.h> #include<conio.h> void main() int n=0,i; char a[100],rev[100]; clrscr(); printf("enter a string:"); gets(a); while(a[n]!='\0') n++; for(i=0;i<=(n-1);i++) rev[n-i-1]=a[i]; for(i=0;i<=n-1;i++) if(a[i]!=rev[i]) break; if(i==n) printf("the string is palindrome."); else printf("the string is not palindrome."); getch(); The above program checks whether source string is equal to target string (reverse of source string itself). 22

23 May 13 Paper Solution Q.6(d) Explain how to read the contents of file and write into the file with [3] Syntax. (A) Writing to a file [3 marks] #include <stdio.h> int main() int n; FILE *fptr; fptr=fopen("c:\\program.txt","w"); if(fptr==null) printf("error!"); exit(1); printf("enter n: "); scanf("%d",&n); fprintf(fptr,"%d",n); fclose(fptr); return 0; Reading from file #include <stdio.h> int main() int n; FILE *fptr; if ((fptr=fopen("c:\\program.txt","r"))==null) printf("error! opening file"); exit(1); /* Program exits if file pointer returns NULL. */ fscanf(fptr,"%d",&n); printf("value of n=%d",n); fclose(fptr); return 0; 23

F.E. Sem. II. Structured Programming Approach

F.E. Sem. II. Structured Programming Approach 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]

More information

'C' Programming Language

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

More information

Question Bank (SPA SEM II)

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

More information

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE

PROGRAMMING 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 information

Computer Programing. for Physicists [SCPY204] Class 02: 25 Jan 2018

Computer 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 information

Questions Bank. 14) State any four advantages of using flow-chart

Questions 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 information

Subject: Fundamental of Computer Programming 2068

Subject: Fundamental of Computer Programming 2068 Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find

More information

3 The L oop Control Structure

3 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 information

Programming in C Lab

Programming in C Lab Programming in C Lab 1a. Write a program to find biggest number among given 3 numbers. ALGORITHM Step 1 : Start Start 2 : Input a, b, c Start 3 : if a > b goto step 4, otherwise goto step 5 Start 4 : if

More information

Unit 3 Decision making, Looping and Arrays

Unit 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 information

List of Programs: Programs: 1. Polynomial addition

List 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 information

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

Aryan 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 information

PROGRAMMING IN C AND C++:

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

More information

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

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

More information

Module 4: Decision-making and forming loops

Module 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 information

Multiple Choice Questions ( 1 mark)

Multiple 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

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space

More information

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M4.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 information

Q 1. Attempt any TEN of the following:

Q 1. Attempt any TEN of the following: Subject Code: 17212 Model Answer Page No: 1 / 26 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The

More information

UNIT III ARRAYS AND STRINGS

UNIT 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 information

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

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

More information

Decision Making and Branching

Decision Making and Branching INTRODUCTION Decision Making and Branching Unit 4 In the previous lessons we have learned about the programming structure, data types, declaration of variables, tokens, constants, keywords and operators

More information

Scheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C

Scheme 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 information

M1-R4: Programing and Problem Solving using C (JAN 2019)

M1-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 information

Computer Programming Unit 3

Computer 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 information

SRI 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 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 information

Informatics Ingeniería en Electrónica y Automática Industrial. Control flow

Informatics 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 information

PES 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 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 information

/* Area and circumference of a circle */ /*celsius to fahrenheit*/

/* 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 information

Branching is deciding what actions to take and Looping is deciding how many times to take a certain action.

Branching is deciding what actions to take and Looping is deciding how many times to take a certain action. 3.0 Control Statements in C Statements The statements of a C program control the flow of program execution. A statement is a command given to the computer that instructs the computer to take a specific

More information

MODULE 2: Branching and Looping

MODULE 2: Branching and Looping MODULE 2: Branching and Looping I. Statements in C are of following types: 1. Simple statements: Statements that ends with semicolon 2. Compound statements: are also called as block. Statements written

More information

BCSE1002: Computer Programming and Problem Solving LAB MANUAL

BCSE1002: 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 information

UNIT 3 FUNCTIONS AND ARRAYS

UNIT 3 FUNCTIONS AND ARRAYS UNIT 3 FUNCTIONS AND ARRAYS Functions Function definitions and Prototypes Calling Functions Accessing functions Passing arguments to a function - Storage Classes Scope rules Arrays Defining an array processing

More information

PESIT Bangalore South Campus Hosur Road (1km before Electronic City), Bengaluru Department of Basic Science and Humanities

PESIT Bangalore South Campus Hosur Road (1km before Electronic City), Bengaluru Department of Basic Science and Humanities SOLUTION OF CONTINUOUS INTERNAL EVALUATION TEST -1 Date : 27-02 2018 Marks:60 Subject & Code : Programming in C and Data Structures- 17PCD23 Name of faculty : Dr. J Surya Prasad/Mr. Naushad Basha Saudagar

More information

Write a C program using arrays and structure

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

More information

CP 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 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 information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.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 information

PESIT 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 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 information

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR 603 203 FIRST SEMESTER B.E / B.Tech., (Common to all Branches) QUESTION BANK - GE 6151 COMPUTER PROGRAMMING UNIT I - INTRODUCTION Generation and

More information

Flow of Control. Selection. if statement. True and False in C False is represented by any zero value. switch

Flow of Control. Selection. if statement. True and False in C False is represented by any zero value. switch Flow of Control True and False in C Conditional Execution Iteration Nested Code(Nested-ifs, Nested-loops) Jumps 1 True and False in C False is represented by any zero value The int expression having the

More information

Subject: PIC Chapter 2.

Subject: PIC Chapter 2. 02 Decision making 2.1 Decision making and branching if statement (if, if-, -if ladder, nested if-) Switch case statement, break statement. (14M) 2.2 Decision making and looping while, do, do-while statements

More information

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

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

More information

Unit 7. Functions. Need of User Defined Functions

Unit 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 information

Government Polytechnic Muzaffarpur.

Government 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 information

UNIT I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING

UNIT I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING SIDDARTHA INSTITUTE OF SCIENCE AND TECHNOLOGY:: PUTTUR Siddharth Nagar, Narayanavanam Road 517583 QUESTION BANK (DESCRIPTIVE) Subject with Code : PROGRAMMING FOR PROBLEM SOLVING (18CS0501) Course & Branch

More information

WAP 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

WAP 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 information

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be

More information

Subject: Computer Science

Subject: Computer Science Subject: Computer Science Topic: Data Types, Variables & Operators 1 Write a program to print HELLO WORLD on screen. 2 Write a program to display output using a single cout statement. 3 Write a program

More information

Programming and Data Structures Mid-Semester - Solutions to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring

Programming and Data Structures Mid-Semester - Solutions to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring Programming and Data Structures Mid-Semester - s to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring 2015-16 February 15, 2016 1. Tick the correct options. (a) Consider the following

More information

Unit 5. Decision Making and Looping. School of Science and Technology INTRODUCTION

Unit 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 information

PDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs

PDS 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 information

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator

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

More information

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C 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 information

DECISION CONTROL AND LOOPING STATEMENTS

DECISION 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

What is recursion. WAP to find sum of n natural numbers using recursion (5)

What 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MAHARASHTRA 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 information

UIC. C Programming Primer. Bharathidasan University

UIC. 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 information

Vidyalankar 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

Vidyalankar 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 information

REPETITION CONTROL STRUCTURE LOGO

REPETITION 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 information

Prepared by: Shraddha Modi

Prepared by: Shraddha Modi Prepared by: Shraddha Modi Introduction In looping, a sequence of statements are executed until some conditions for termination of the loop are satisfied. A program loop consist of two segments Body of

More information

CHAPTER 4 FUNCTIONS. 4.1 Introduction

CHAPTER 4 FUNCTIONS. 4.1 Introduction CHAPTER 4 FUNCTIONS 4.1 Introduction Functions are the building blocks of C++ programs. Functions are also the executable segments in a program. The starting point for the execution of a program is main

More information

mith 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 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 information

Introduction. C provides two styles of flow control:

Introduction. 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 information

Computers Programming Course 12. Iulian Năstac

Computers 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 information

MCS-011. June 2014 Solutions Manual IGNOUUSER

MCS-011. June 2014 Solutions Manual IGNOUUSER MCS-011 June 2014 Solutions Manual IGNOUUSER 1 1. (a) Write an algorithm and draw corresponding flowchart to calculate the factorial of a given number. Factorial of a number n n! = 1*2*3*4*...*n Algorithm

More information

CSE 2421: Systems I Low-Level Programming and Computer Organization. Functions. Presentation C. Predefined Functions

CSE 2421: Systems I Low-Level Programming and Computer Organization. Functions. Presentation C. Predefined Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Functions Read/Study: Reek Chapters 7 Gojko Babić 01-22-2018 Predefined Functions C comes with libraries of predefined functions E.g.:

More information

Control Statements. If Statement if statement tests a particular condition

Control Statements. If Statement if statement tests a particular condition Control Statements Control Statements Define the way of flow in which the program statements should take place. Implement decisions and repetitions. There are four types of controls in C: Bi-directional

More information

Functions. Arash Rafiey. September 26, 2017

Functions. 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 information

ECE15: 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 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 information

Introduction to Programming. Sample Question Paper. Q. 1. a). What is an algorithm? 2.5 X10

Introduction to Programming. Sample Question Paper. Q. 1. a). What is an algorithm? 2.5 X10 Introduction to Programming Sample Question Paper Note: Q.No. 1 is compulsory, attempt one question from each unit. Q. 1. a). What is an algorithm? 2.5 X10 b) What do you mean by Program? Write a small

More information

It is necessary to have a single function main in every C program, along with other functions used/defined by the programmer.

It is necessary to have a single function main in every C program, along with other functions used/defined by the programmer. Functions A number of statements grouped into a single logical unit are called a function. The use of function makes programming easier since repeated statements can be grouped into functions. Splitting

More information

Flow Control. CSC215 Lecture

Flow 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER

MAHARASHTRA 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 information

SUMMER 13 EXAMINATION Model Answer

SUMMER 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 information

UNIT 2 ARRAYS 2.0 INTRODUCTION. Structure. Page Nos.

UNIT 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 information

VARIABLE, OPERATOR AND EXPRESSION [SET 1]

VARIABLE, OPERATOR AND EXPRESSION [SET 1] VARIABLE, OPERATOR AND EXPRESSION Question 1 Write a program to print HELLO WORLD on screen. Write a program to display the following output using a single cout statement. Subject Marks Mathematics 90

More information

Pointers, Dynamic Data, and Reference Types

Pointers, Dynamic Data, and Reference Types Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple

More information

Bil 104 Intiroduction To Scientific And Engineering Computing. Lecture 7

Bil 104 Intiroduction To Scientific And Engineering Computing. Lecture 7 Strings and Clases BIL104E: Introduction to Scientific and Engineering Computing Lecture 7 Manipulating Strings Scope and Storage Classes in C Strings Declaring a string The length of a string Copying

More information

FUNCTIONS OMPAL SINGH

FUNCTIONS 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 information

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

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

More information

Loops / Repetition Statements

Loops / 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 information

PDS Class Test 2. Room Sections No of students

PDS 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 information

I2204 ImperativeProgramming Semester: 1 Academic Year: 2018/2019 Credits: 5 Dr Antoun Yaacoub

I2204 ImperativeProgramming Semester: 1 Academic Year: 2018/2019 Credits: 5 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree I2204 ImperativeProgramming Semester: 1 Academic Year: 2018/2019 Credits: 5 Dr Antoun Yaacoub I2204- Imperative Programming Schedule 08h00-09h40

More information

Chapter 3: Arrays and More C Functionality

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

More information

Model Viva Questions for Programming in C lab

Model 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 information

Module 6: Array in C

Module 6: Array in C 1 Table of Content 1. Introduction 2. Basics of array 3. Types of Array 4. Declaring Arrays 5. Initializing an array 6. Processing an array 7. Summary Learning objectives 1. To understand the concept of

More information

MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI

MAHALAKSHMI 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 information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis

More information

CHAPTER 9 FLOW OF CONTROL

CHAPTER 9 FLOW OF CONTROL CHAPTER 9 FLOW OF CONTROL FLOW CONTROL In a program statement may be executed sequentially, selectively or iteratively. Every program language provides constructs to support sequence, selection or iteration.

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA 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 information

SELECTION STATEMENTS:

SELECTION STATEMENTS: UNIT-2 STATEMENTS A statement is a part of your program that can be executed. That is, a statement specifies an action. Statements generally contain expressions and end with a semicolon. Statements that

More information

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++ CHAPTER 9 C++ 1. WRITE ABOUT THE BINARY OPERATORS USED IN C++? ARITHMETIC OPERATORS: Arithmetic operators perform simple arithmetic operations like addition, subtraction, multiplication, division etc.,

More information

Classification s of Data Structures

Classification 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 information

United 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 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 information

1. FIBONACCI SERIES. Write a C++ program to generate the Fibonacci for n terms. To write a C++ program to generate the Fibonacci for n terms.

1. FIBONACCI SERIES. Write a C++ program to generate the Fibonacci for n terms. To write a C++ program to generate the Fibonacci for n terms. PROBLEM: 1. FIBONACCI SERIES Write a C++ program to generate the Fibonacci for n terms. AIM: To write a C++ program to generate the Fibonacci for n terms. PROGRAM CODING: #include #include

More information

Unit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?

Unit 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 information

Lab Manual B.Tech 1 st Year

Lab 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 information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

(i) Describe in detail about the classification of computers with their features and limitations(10)

(i) Describe in detail about the classification of computers with their features and limitations(10) UNIT I - INTRODUCTION Generation and Classification of Computers- Basic Organization of a Computer Number System Binary Decimal Conversion Problems. Need for logical analysis and thinking Algorithm Pseudo

More information