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

Size: px
Start display at page:

Download "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"

Transcription

1 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] Q.1(a) Explain with the example the use of Break statement. [2] (A) The break statement in C programming language has the following two usage : 1. When the break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop. 2. It can be used to terminate the case in the switch statement If one is using nested loops, the break statement will stop the execution of the innermost loop and start executing the next line of code after the block. Syntax break; Example : #include <stdio.h> int main() int a = 10; while(a<20) printf( value of a: %d \n, a) a++; if(a > 15) break; return 0; Q.1(b) List and explain types of qualifiers. [2] (A) C type qualifiers : the keywords which are used to modify the properties of a variable are called type qualifiers. Types of C-type qualifiers : There are two types of qualifiers available in C language. They are : (i) const (ii) volatile (i) const keyword : Constants are also like normal variables. But, only difference is, their values cant be modified by the program once they are defined. They refer to fixed values. They are also called as literals. 1

2 F.Y. Diploma Programming in C They may belong to any of the data type. Syntax const datatype variablename; Or const datatype *variablename (ii) volatile keyword : when a variable is defined as volatile, the program may not change the value of the variable explicitly. But, these variable values might keep on changing without any explicit assignments by the program. These types of qualifiers are called volatile. For ex, if global variable s address is passed to clock routine of the operating system to store the system time, the value in this address keep on changing without any assignment by the program. These variables are named as volatile variable. Syntax volatile datatype variablename Or Volatile datatype *variablename Q.1(c) What is an array? How to declare one-dimensional and two dimensional array. [2] (A) C Programming/Arrays. Arrays in C act to store related data under a single variable name with an index, also known as a subscript. It is easiest to think of an array as simply a list or ordered grouping for variables of the same type. Declaration of One Dimensional Array: Syntax: data_type array_name[width]; Example: int roll[8]; In this example, an array of integer type is declared and named it as roll which can store roll numbers of 8 students. C Array Assignment and Initialization: We can assign value to an array at the time of declaration or during runtime. Syntax: data_type array_name[size]=list of values; Example: int arr[5]=1,2,3,4,5; int arr[]=1,2,3,4,5; Declaration of Two Dimensional Array: Syntax: data_type array_name[rows][cols]; Example: int number[3][4]; In this example, an array of integer type is declared and named it as number which can store numbers in 3 rows and 4 columns format. So total 12 numbers are stored. C Array Assignment and Initialization: We can assign value to an array at the time of declaration or during runtime. Syntax: data_type array_name[rows][cols]=list of values; Example: int number[3][4]= 1,2,3,4, 5,6,7,8, 2

3 int number[][]= ; 9,10,11,12 ; 1,2,3,4, 5,6,7,8, 9,10,11,12 Prelim Question Paper Solution Q.1(d) Distinguish between call-by-value and call-by-reference. [2] (A) Call by Value Call by Reference This is the usual method to call a function In this method, the address of the variable in which only the value of the variable is is passed as an argument. passed as an argument. Any alternation in the value of the Any alternation in the value of the argument passed is local to the function argument passed is accepted in the calling and is not accepted in the calling program. program. Memory location occupied by formal and Memory location occupied by formal and actual arguments is different. actual arguments is same and there is a saving of memory location. Since a new location is created, this Since the existing memory location is used method is slow. through its address, this method is fast. There is no possibility of wrong data There is a possibility of wrong data manipulation since the arguments are manipulation since the addresses are used directly used in an application. in an expression. A good skill of programming is required here. Q.1(e) Write a C program to find the factorial of an entered number using recursion. [2] (A) #include <stdio.h> #include <conio.h> void main() int no, factorial; int fact (int no); clrscr(); printf( Enter a number ); scanf( %d, &no); factorial = fact(no); printf( the factorial of a %d is %d, no, factorial); int fact(no1) int c, fact=1; for(c=1; c<=no1; c++); fact = fact * c; return fact; 3

4 F.Y. Diploma Programming in C Q.1(f) Find the output of the following. void main() int i=1; clrscr(); for(;;) printf("%d ",i); getch(); (A) void main() int i=1; clrscr(); for(;;) printf("%d ",i); getch(); Ans : Output infinite Q.1(g) Write the syntax of whi le and do..while statements. [2] (A) Syntax - while while(condition) Statement; Syntax do while do Statements while (condition) Q.1(h) What is a storage class? Enlist storage classes available in C. [2] (A) A storage class defines the scope and life time of variables and/or functions withing a C program. There are following storage classes which can be used in a C program. auto register static extern [2] 4

5 Prelim Question Paper Solution Q.1(i) What is a meaning of Prototype of a function? [2] (A) Prototype of a function : Declaration of function is known as prototype of a function. Prototype of a function means (1) What is return type of function? (2) What parameters are we passing? For example prototype of print function is: int print(int a, int b); i.e. its return type is int data type, its first parameter is an integer variable and second parameter is also an integer variable. Q.1(j) Find out the error if any, in the program. #include<stdio.h> int main() int i=1; switch(i) case 1: printf("\radioactive cats have 18 half-lives"); break; case 1*2+4: printf("\bottle for rent -inquire within"); break; return 0; (A) #include<stdio.h> int main() int i=1; switch(i) case 1: printf("\radioactive cats have 18 half-lives"); break; case 1*2+4: printf("\bottle for rent -inquire within"); break; return 0; Ans : No error Q.1(k) What will be output when you will execute following c code? #include<stdio.h> void main() int a=100; if(a>10) printf("m.s. Dhoni"); else if(a>20) printf("m.e.k Hussey"); else if(a>30) printf("a.b. de villiers"); 5 [2] [2]

6 F.Y. Diploma Programming in C (A) 6 #include<stdio.h> void main() int a=100; if(a>10) printf("m.s. Dhoni"); else if(a>20) printf("m.e.k Hussey"); else if(a>30) printf("a.b. de villiers"); Ans : M.S.Dhoni Q.1(l) Write a C program to find whether the given year is a leap or not. [2] (A) #include <stdio.h> #include<conio.h> void main() int year; clrscr(); printf( Enter any year ); scanf( %d, &year); if((year%4= =0 && year %100!=0) (year%100= =0 && year%400= =0) printf( Leap year ); else printf( Not a leap year ); getch(); Q.2 Attempt any FOUR of the following : [16] Q.2(a) Write a program for exchanging values of two variables using call by reference. [4] (A) #include <stdio.h> #include <conio.h> void main() int a,b; void swap(int *p1, int *p2) clrscr(); printf( Enter two numbers ); scanf( %d %d, &a, &b); printf( The values of a and b in the main function before calling the swap function are %d and %d \n, a,b); swap(&a,&b); printf( The values of a and b in the main function after calling the swap function are %d and %d \n, a,b); getch(); void swap(int *p1, int *p2)

7 Prelim Question Paper Solution int temp; temp = *p1; *p1 = *p2; *p2 = temp; printf( The values of a and b in the swap function after swapping are %d and %d \n, *p1, *p2); Q.2(b) Explain the use of bitwise operator. [4] (A) Consider A = B = Operator Description Example & Binary AND operator copies a bit to (A & B) will give 12 which is the result if it exists in both operands. Binary OR operator copies a bit if it exists in either operand (A B) will give 61 which is ^ Binary XOR operator copies the (A ^ B) will give 49 which is bit if it is set in one operand but not both. ~ Binary Ones Complement operator (~A) will giove -61 which is is unary and has the effect of in 2 s complement form due to a signed flipping bits. binary number. Q.2(c) Explain break and continue statements with an example of each. [4] (A) continue statement : The continue statement in C programming language forces the next iteration of the loop to take place, skipping any code in between. For the for loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while and do while,continue statement causes the program control to pass the conditional test. Example #include<stdio.h> int main() int a = 10; do if(a= =15) a = a + 1; continue; printf( value of a : %d \n, a); a++; while(a<20); 7

8 F.Y. Diploma Programming in C return 0; 8 Output : value of a : 10 value of a : 11 value of a : 12 value of a : 13 value of a : 14 value of a : 16 value of a : 17 value of a : 18 value of a : 19 Q.2(d) Explain relational operators supported by C. Write a C program illustrating [4] its use. (A) Operator Description Example = = Checks if the values of two operands are equal or not, if yes, then (A = = B) the condition returns true.!= Checks if the values of two operands are equal or not, if values (A!= B) are not equal, then the condition returns true. > Checks if the value of the left operand is greater than the value of (A > B) the right operand, if yes, then the condition returns true. < Checks if the value of the left operand is less than the value of the (A < B) right operand, if yes, then the condition returns true. >= Checks if the value of the left operand is greater than or equal to the (A >= B) value of the right operand, if yes, then the condition returns true. <= Checks if the value of the left operand is less than or equal to the value of the right operand, if yes, then the condition returns true. (A <= B) Example - #include<stdio.h> int a=21; int b=10; int c; if(a == b) printf( a is equal to b ); else printf( a is not equal to b ); if (a < b) printf( a is less than b ); else

9 printf( a is not less than b ); if (a > b) printf( a is greater than b ); else printf( a is not greater than b ); a=5; b=20; if(a <= b) printf( a is either less than or equal to b ); if(b >= a) printf( b is either greater than or equal to a ); Prelim Question Paper Solution Q.2(e) What is operators precedence and associativity? [4] (A) Operator precedence determines the grouping of terms in an expression. This affects how an expression is evaluated. Certain operators have higher precedence than others; for exthe multiplication operator had higher precedence than the addition operator. For example x = * 2; here x is assigned 13, not 20 because operator * has higher precedence than +. Category Operator Associativity Postfix () [] -> Left to right Unary + -! ~ (type)* &sizeof Right to left Multiplicative */ % Left to right Additive + - Left to right Shift << >> Left to right Relational <<= >>= Left to right Equality ==!= Left to right Bitwise AND & Left to right Bitwise XOR ^ Left to right Bitwise OR Left to right Logical AND && Left to right Logical OR Right to left Conditional?: Right to left Assignment = += -= *= %= >>= <<= &= ^= = Left to right Q.2(f) Write a C program to accept a float number and display its integer part. [4] (A) #include<stdio.h> #include<conio.h> void main() int a; 9

10 F.Y. Diploma Programming in C float b; clrscr(); printf( enter any float number ); scanf( %f, &b); a = (int) b; printf( the integer part of the number is %d, a); getch(); Q.3 Attempt any FOUR of the following : [16] Q.3(a) Explain global and local variable. Write C program to explain global and [4] local variable. (A) Local variables these are the variables declared inside a function in which they are to be utilized. They are created when the function is called and destroyed automatically when the function is exited, hence the name automatic. Automatic variables are therefore private or local to the function in which they are declared. They are also referred to as local or internal variables. A variable declared inside a function without storage class is by default an automatic variable. e.g main() int number;.... We may also use the keyword auto to declare automatic variables explicitly. main auto int number;.. The value of automatic variables can not be changed in other function in the program. We may declare and use the same variable in different functions in the same program. e.g main() int m = 1000; function2(); printf( %d \n, m); function1() int m = 10; printf( %d\n, m); 10

11 function2() int m=1000; function1(); printf( %d\n, m); Output Prelim Question Paper Solution Global variables : Variables that are active throughout the entire program are known as global or external variables. They can be accessed by any function in the program. They are declared outside a function. e.g. int number; float length = 7.5; main() Function1() Function2() The variable numbers and length are available for use in all the three functions e.g int x; main() x=10; printf( x=%d\n, x); printf( x=%d\n, fun1()); printf( x=%d\n, fun2()); printf( x=%d\n, fun3()); fun1() x=x+10; 11

12 F.Y. Diploma Programming in C return(x); 12 fun2() int x; x=1; return(x); fun3() x=x+10; return(x); Output: x=10; x=20 x=1 x=30 Q.3(b) What is the difference between pre-increment and post-increment operators? [4] Explain with the help of an example. (A) As the name says Pre increment means increment first than operate. Post increment means operate than increment. eg for x=7 a=++x x will increase first than a=x will operate while for a=x++ a will be equal x(7) and after than x value will be 8. #include<stdio.h> main() int x = 7; int a; a = ++x; printf( the value of a = %d, a); Output : The value of a = 8 #include<stdio.h> main() int x = 7; int a;

13 Prelim Question Paper Solution a = x++; printf( the value of a = %d, a); The value of a = 7 Q.3(c) Write a C program to calculate the value of following series. 1 + ½ + 1/3 + ¼ + 1/5. + 1/n (A) #include <stdio.h> #include<conio.h> void main() int i,n; float sum=0.0; clrscr(); printf( enter a number ); scanf( %d, &n); for(i=1; i<=n; i++) sum=sum+0.1/i; printf( The value of the series is : %f,sum); getch() Q.3(d) Explain declaration and initialization of string variable with example. [4] (A) A group of characters can be stored inn a character array. Character arrays are many a times called strings. A string constant is a one dimensional array of characters terminated by a null ( \0 ). For example : Char name[] = R, O, N, N, Y, \0 ; The terminating null is important, nbecause it is the only way the functions that work with a string can know where the string ends. In fact, a string not terminated by a \ \0 is not really a string, but merely a collection of characters. The string used above can also be initialized as : Char name[] = RONNY ; In this, declaration \0 is not necessary. C inserts the null character automatically. Q.3(e) Describe the string functions strlen() and strcpy() with an example of each. [4] (A) strlen() this function returns length of the string. strcpy this function is used for copying one char array into another. #include<stdio.h> main() char x[50] = hello, char y[50]; int len = 0; len = strlen(x) printf( The length is %d, len); strcpy(y,x); [4] 13

14 F.Y. Diploma Programming in C Q.3(f) Write a program to print first 10 prime numbers. [4] (A) #include<stdio.h> #include<conio.h> main() int count, n, no=1,div,rem,flag=0; clrscr(); for(count=0;count<=10;count++) for(div=2;div<no; div++) rem = no % div; if(rem == 0) flag = 1; break; if(flag= =0) count++; printf( %d, no) Q.4 Attempt any FOUR of the following : [16] Q.4(a) What is a function? Explain the need of function with example. [4] (A) A function is a self-contained block of statements that perform a coherent task of some kind. Every c program can be thought of as a collection of these functions. Need : 1. Writing functions avoids rewriting the same code over and over. Suppose u have a section of code in your program that calculates area of a triangle. If later in the program you want to calculate the area of a different triangle, you wont like it if you required to write the same instructions all over again. Instead, you would prefer to jump to a section of code that calculates area and then jump back to the place from where you left off. This section of code is nothing but a function. 2. Using functions it becomes easier to write programs and keep track of what they are doing. If the operation of a program can be divided into separate activities, and each activity placed in a different function, then each could be written and checked more or less independently. Separating the code into modular functions also makes the program easier to design and understand. 3. Q.4(b) Explain any two storage classes and their characteristics. [4] (A) There are following storage classes which can be used in a C Program. auto register static extern 14

15 Prelim Question Paper Solution (i) auto auto is the default storage class for all local variables. int Count; auto int Month; The example above defines two variables with the same starage class. auto can only be used within functions. i.e. local variables. (ii) register register is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the register size9usually one word) and cannot have the unary & operator applied to it. (as it does not have the memory location) Register int miles; Register should only be used for variables that require quick access such as counters. It should also be noted that defining register does not mean that the variable will be stored in a register. It means that it MIGHT be stored in a register depending on hardware and implementation restrictions. Q.4(c) How to define Structure? How to access structure members? Explain it with [4] the help of an example. (A) Defining structure : To define a structure, you must use the struct statement. The struct statement defines the new data type, with more than one member for your program. The format of struct statement is this : struct [structure tag] Member definiation; Member definiation; [one or more structure variables] Example : struct Books char title[50]; char author[50]; char subject[100]; int book_id; book; Accessing structure memners : To access the structure members, member access operator (.) is used. struct keyword is used to define a variable of a structure type. Example struct Books 15

16 F.Y. Diploma Programming in C 16 char title[50]; char author[50]; char subject[100]; int book_id; book; int main() struct Books Book1; strcpy (Book1.title, C Programming ); strcpy(book1.author, Neha ali )l strcpy(book1.subject, C Programming Tutorial ); Book1.id = 3446; /* print book1 info */ printf( Book1 title:, Book1.title); printf( Book1 author:, Book1.author); printf( Book1 subject:, Book1.subject); printf( Book1 book id:, Book1.book_id); return 0; Q.4(d) What is an array? State types of array. Write any one statement to initialize array of 5 elements. (A) An array is a collection of values of same data type. Types of array 1. One dimensional array 2. Two dimensional array 3. Multidimensional array To initialize array of 5 elements in one line int marks[5] = 55,66,77,88,99; Q.4(e) Write a program to find Transpose of any (3 * 3) matrix. [4] (A) #include<stdio,h> #inlcude<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<m-1;i++) for(j=0;j<=n-1;j++) printf( Enter a value ); scanf( %d, &a[i][j]); [4]

17 Prelim Question Paper Solution printf( Then original matrix is ); for(i=0;i<m-1;i++) for(j=0;j<=n-1;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<=m-1;i++) for(j=0;j<=n-1;j++) b[i][j] = a[i][j]; printf( the transpose of this matrix is : \n ); for (i=0;i<=m-1;i++) for(j=0;j<=n-1;j++) printf( %d\t, b[i][j]; Q.4(f) Write a program to accept a string and display the length of it without using standard library functions. (A) #include<stdio,h> #include<conio.h> void main() char a[100]; int len=0; clrscr(); printf( Enter any string ); gets(a); while(a[len]!= \0 ) len ++; printf( the length of the string is %d, len); [4] 17

18 F.Y. Diploma Programming in C Q.5 Attempt any FOUR of the following : [16] Q.5(a) What will be output of following c code? [4] #include<stdio.h> int main() int i=1; for(i=0;i=-1;i=1) printf("%d ",i); if(i!=1) break; return 0; (A) 1 Q.5(b) Explain Static variable with the help of an example. [4] (A) Q.5(c) Write a C program to convert lower case to upper case. [4] (A) #include<stdio.h> int main() char str[20]; int i; printf("enter any string: "); scanf("%s",str); printf("the string is: %s",str); for(i=0;i<=strlen(str);i++) if(str[i]>=97&&str[i]<=122) 18

19 Prelim Question Paper Solution str[i]=str[i]-32; printf("\nthe string in lowercase is: %s",str); return 0; Q.5(d) Write the meaning of declaration: int * ptr; [4] (A) main() int i = 3; printf( \n address of i = %u, &i); printf( \n Value of i = %d, i); The o/p Address of i = Value of i = 3 In the first printf statement & is used which is C s Address of operator. The expression &i returns the address of the variable i. which in this case happens to be Since this number represents an address, there is no question of a sign being associated with it. Hence it is printed out using %u, which is a format specifier for printing an unsigned integer. The other pointer operator available in C is *, called value at address operator. It gives the value stored at a particular address. The value at address operator is also called as indirection operator. Q.5(e) Write a program for addition of two 3 * 3 matrix. [4] (A) #include<stdio.h> #incluse<conio.h> void main() int m,n,i,j,a[3][3],b[3][3],c[3][3]; printf( Enter the number of rows and columns: ); scanf( %d %d, &m, &n); printf( Enter the elements of Matrix 1\n ); for(i=0;i<=m-1;i++) for(j=0;j<=n-1;j++) printf( enter a value: ); scanf( %d, &a[i][j]); printf( Enter the elements of Matrix 2\n ); for(i=0;i<=m-1;i++) for(j=0;j<=n-1;j++) 19

20 F.Y. Diploma Programming in C printf( enter a value: ); scanf( %d, &b[i][j]); for(i=0;i<=m-1;i++) for(j=0;j<=n-1;j++) c[i][j] = a[i][j] + b[i][j]; printf( the sum of two matrices is :\n ); for(i=0;i<=m-1;i++) for(j=0;j<=n-1;j++) printf( %d \t, c[i][j]; printf( \n ); getch(); Q.5(f) Write a C program to find GCD/LCM of given number. [4] (A) #include<stdio.h> #include<conio.h> void main() int n01, no2, gcd; int GCD(int no1, int no2); clrscr(); printf( Enter two numbers ); scanf( %d%d, &no1, &no2); gcd=gcd(no1, no2); if(gcd==1) printf( GCD doesn t exist ); else printf( GCD = %d, gcd); getch(); int GCD(int no1, int no2) int gcd; if(no1<no2) gcd=no1; else gcd=no2; while(no1%gcd!= 0 noo2%gcd!=0) 20

21 Prelim Question Paper Solution gcd--; return gcd; Q.6 Attempt any FOUR of the following : [16] Q.6(a) Explain with examples different pointer arithmetic operations. [4] (A) Only limited number of arithmetic operations can be performed on pointers. These operations are : Increment and decrement An integer quantity can be added to or subtracted from a pointer variable int *pw; pw++; pw+3; Addition and subtraction One pointer variable can be subtracted from another. It makes sense only if both points tp elements in the same array. int *pw, *pv, A[100]; pv = & A[51]; pw = &A[75]; printf( %d, pw-pv); printf( %d, pv-pw); Comparison Two pinter variables can be compared if they point to objects to the same type. Int *pw, *pv Pw < pv ; pw >=pv; pw<=pv; pw==pv; pw!=pv Pw==NULL char c[4]; if(pw < c).; Gives a warning Pw < (int *) c passes (char *) pw < c also passes Assignment e.g. x=3 the value 3 is assigned to variable x. Q.6(b) How pointers are declared, initialized and accessed? [4] (A) **** How to Declare a Pointer? A pointer is declared as : <pointer type> *<pointer-name> In the above declaration : 1. pointer-type : It specifies the type of pointer. It can be int,char, float etc. This type specifies the type of variable whose address this pointer can store. 2. pointer-name : It can be any name specified by the user. Professionally, there are some coding styles which every code follows. The pointer names commonly start with p or end with ptr An example of a pointer declaration can be : char *chptr; In the above declaration, char signifies the pointer type, chptr is the name of the pointer while the asterisk * signifies that chptr is a pointer variable. 21

22 F.Y. Diploma Programming in C How to initialize a Pointer? A pointer is initialized in the following way : <pointer declaration(except semicolon)> = <address of a variable> OR <pointer declaration> <name-of-pointer> = <address of a variable> Note that the type of variable above should be same as the pointer type.(though this is not a strict rule but for beginners this should be kept in mind). For example : char ch = 'c'; char *chptr = &ch; //initialize OR char ch = 'c'; char *chptr; chptr = &ch //initialize In the code above, we declared a character variable ch which stores the value c. Now, we declared a character pointer chptr and initialized it with the address of variable ch. How to Use a Pointer? A pointer can be used in two contexts. Context 1: For accessing the address of the variable whose memory address the pointer stores. Again consider the following code : char ch = 'c'; char *chptr = &ch; Now, whenever we refer the name chptr in the code after the above two lines, then compiler would try to fetch the value contained by this pointer variable, which is the address of the variable (ch) to which the pointer points. i.e. the value given by chptr would be equal to &ch. For example : char *ptr = chptr; The value held by chptr (which in this case is the address of the variable ch ) is assigned to the new pointer ptr. Context 2: For accessing the value of the variable whose memory address the pointer stores. Continuing with the piece of code used above : char ch = 'c'; char t; char *chptr = &ch; t = *chptr; 22

23 Prelim Question Paper Solution Q.6(c) Predict the output. [4] (A) Compiler error : Cannot modify a constant value. Explanation : p is a pointer to a constant integer. But we tried to change the value of the constant integer. Q.6(d) Write a program to accept 5 integer numbers and display them using Array. [4] (A) #include<stdio.h> #include<conio.h> main() int no[5]; int i; printf( Enter any 5 numbers ); for(i=0;i<5;i++) scanf( %d, &a[i]); printf( the entered numbers are ); for(i=0;i<5;i++) printf( %d \t, a[i]); Q.6(e) Define Pointer. Describe &(ampersand) and * (asterisk) operators in pointers. [4] (A) # include <stdio.h> void fun(int x) x = 30; int main() int y = 20; fun(y); printf("%d", y); return 0; Ans : 20 Q.6(f) Write a C Program to Add Two Distances (in inch-feet) System Using Structures [4] (A) Source code to add two distance using structure #include <stdio.h> struct Distance 23

24 F.Y. Diploma Programming in C int feet; float inch; d1,d2,sum; int main() printf("enter information for 1st distance\n"); printf("enter feet: "); scanf("%d",&d1.feet); printf("enter inch: "); scanf("%f",&d1.inch); printf("\nenter information for 2nd distance\n"); printf("enter feet: "); scanf("%d",&d2.feet); printf("enter inch: "); scanf("%f",&d2.inch); sum.feet=d1.feet+d2.feet; sum.inch=d1.inch+d2.inch; /* If inch is greater than 12, changing it to feet. */ if (sum.inch>12.0) sum.inch=sum.inch-12.0; ++sum.feet; printf("\nsum of distances=%d\'-%.1f\"",sum.feet,sum.inch); return 0; Output Enter information for 1st distance Enter feet: 12 Enter inch: 3.45 Enter information for 1st distance Enter feet: 12 Enter inch: 9.2 Sum of distances=25'-0.6" 24

'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

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

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

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

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

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

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

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

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

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

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

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

Operators and Expressions:

Operators and Expressions: Operators and Expressions: Operators and expression using numeric and relational operators, mixed operands, type conversion, logical operators, bit operations, assignment operator, operator precedence

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

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

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

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

CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their

More information

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

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

Computers Programming Course 6. Iulian Năstac

Computers Programming Course 6. Iulian Năstac Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap

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

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

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

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please

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

Computers Programming Course 7. Iulian Năstac

Computers Programming Course 7. Iulian Năstac Computers Programming Course 7 Iulian Năstac Recap from previous course Operators in C Programming languages typically support a set of operators, which differ in the calling of syntax and/or the argument

More information

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered )   FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING ( Word to PDF Converter - Unregistered ) http://www.word-to-pdf-converter.net FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING INTRODUCTION TO C UNIT IV Overview of C Constants, Variables and Data Types

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

Unit 8. Structures and Unions. School of Science and Technology INTRODUCTION

Unit 8. Structures and Unions. School of Science and Technology INTRODUCTION INTRODUCTION Structures and Unions Unit 8 In the previous unit 7 we have studied about C functions and their declarations, definitions, initializations. Also we have learned importance of local and global

More information

UNIT 3 OPERATORS. [Marks- 12]

UNIT 3 OPERATORS. [Marks- 12] 1 UNIT 3 OPERATORS [Marks- 12] SYLLABUS 2 INTRODUCTION C supports a rich set of operators such as +, -, *,,

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

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

C-LANGUAGE CURRICULAM

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

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ... Why Pointers Pointers They provide the means by which functions can modify arguments in the calling function. They support dynamic memory allocation. They provide support for dynamic data structures, such

More information

Computer programming UNIT IV UNIT IV. GPCET,Dept of CSE, P Kiran Rao

Computer programming UNIT IV UNIT IV. GPCET,Dept of CSE, P Kiran Rao UNIT IV COMMAND LINE ARGUMENTS Computer programming UNIT IV It is possible to pass some values from the command line to C programs when they are executed. These values are called command line arguments

More information

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed C Overview C OVERVIEW Goals speed portability allow access to features of the architecture speed C fast executables allows high-level structure without losing access to machine features many popular languages

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

High Performance Programming Programming in C part 1

High Performance Programming Programming in C part 1 High Performance Programming Programming in C part 1 Anastasia Kruchinina Uppsala University, Sweden April 18, 2017 HPP 1 / 53 C is designed on a way to provide a full control of the computer. C is the

More information

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

First of all, it is a variable, just like other variables you studied

First of all, it is a variable, just like other variables you studied Pointers: Basics What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the address (rather than the value)

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

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

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More 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 INTERNAL ASSESSMENT TEST 1 SOLUTION PART 1 1 a Define algorithm. Write an algorithm to find sum and average of three numbers. 4 An Algorithm is a step by step procedure to solve a given problem in finite

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

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

More information

POINTERS - Pointer is a variable that holds a memory address of another variable of same type. - It supports dynamic allocation routines. - It can improve the efficiency of certain routines. C++ Memory

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

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

Dept. of CSE, IIT KGP

Dept. of CSE, IIT KGP Control Flow: Looping CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of Repeated Execution Loop: Group of

More information

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR. VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS

COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR.  VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS COMPUTER SCIENCE HIGHER SECONDARY FIRST YEAR VOLUME II - CHAPTER 10 PROBLEM SOLVING TECHNIQUES AND C PROGRAMMING 1,2,3 & 5 MARKS S.LAWRENCE CHRISTOPHER, M.C.A., B.Ed., LECTURER IN COMPUTER SCIENCE PONDICHERRY

More information

Department of Computer Applications

Department of Computer Applications Sheikh Ul Alam Memorial Degree College Mr. Ovass Shafi. (Assistant Professor) C Language An Overview (History of C) C programming languages is the only programming language which falls under the category

More information

C library = Header files + Reserved words + main method

C library = Header files + Reserved words + main method DAY 1: What are Libraries and Header files in C. Suppose you need to see an Atlas of a country in your college. What do you need to do? You will first go to the Library of your college and then to the

More information

Pointer in C SHARDA UNIVERSITY. Presented By: Pushpendra K. Rajput Assistant Professor

Pointer in C SHARDA UNIVERSITY. Presented By: Pushpendra K. Rajput Assistant Professor Pointer in C Presented By: Pushpendra K. Rajput Assistant Professor 1 Introduction The Pointer is a Variable which holds the Address of the other Variable in same memory. Such as Arrays, structures, and

More information

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 13 [Marks : 80 Q.1(a) Explain the purpose of following standard library functions : [3] (i)

More information

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer:

Chapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer: Chapter-11 POINTERS Introduction: Pointers are a powerful concept in C++ and have the following advantages. i. It is possible to write efficient programs. ii. Memory is utilized properly. iii. Dynamically

More information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Class Teacher: Pralay Mitra Department of Computer Science and Engineering Indian Institute of Technology Kharagpur An Example: Random

More information

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators

More information

ARRAYS(II Unit Part II)

ARRAYS(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 information

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples: Unit IV Pointers and Polymorphism in C++ Concepts of Pointer: A pointer is a variable that holds a memory address of another variable where a value lives. A pointer is declared using the * operator before

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

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure C Overview Basic C Program Structure C OVERVIEW BASIC C PROGRAM STRUCTURE Goals The function main( )is found in every C program and is where every C program begins speed execution portability C uses braces

More information

Learning C Language. For BEGINNERS. Remember! Practice will make you perfect!!! :D. The 6 th week / May 24 th, Su-Jin Oh

Learning C Language. For BEGINNERS. Remember! Practice will make you perfect!!! :D. The 6 th week / May 24 th, Su-Jin Oh Remember! Practice will make you perfect!!! :D Learning C Language For BEGINNERS The 6 th week / May 24 th, 26 Su-Jin Oh sujinohkor@gmail.com 1 Index Basics Operator Precedence Table and ASCII Code Table

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

Object Oriented Pragramming (22316)

Object Oriented Pragramming (22316) Chapter 1 Principles of Object Oriented Programming (14 Marks) Q1. Give Characteristics of object oriented programming? Or Give features of object oriented programming? Ans: 1. Emphasis (focus) is on data

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

Language comparison. C has pointers. Java has references. C++ has pointers and references

Language comparison. C has pointers. Java has references. C++ has pointers and references Pointers CSE 2451 Language comparison C has pointers Java has references C++ has pointers and references Pointers Values of variables are stored in memory, at a particular location A location is identified

More information

& Technology. G) Functions. void. Argument2, Example: (Argument1, Syllabus for 1. 1 What. has a unique. 2) Function name. passed to.

& Technology. G) Functions. void. Argument2, Example: (Argument1, Syllabus for 1. 1 What. has a unique. 2) Function name. passed to. Computer Programming and Utilization (CPU) 110003 G) Functions 1 What is user defined function? Explain with example. Define the syntax of function in C. A function is a block of code that performs a specific

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

15 FUNCTIONS IN C 15.1 INTRODUCTION

15 FUNCTIONS IN C 15.1 INTRODUCTION 15 FUNCTIONS IN C 15.1 INTRODUCTION In the earlier lessons we have already seen that C supports the use of library functions, which are used to carry out a number of commonly used operations or calculations.

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

C Programming Multiple. Choice

C Programming Multiple. Choice C Programming Multiple Choice Questions 1.) Developer of C language is. a.) Dennis Richie c.) Bill Gates b.) Ken Thompson d.) Peter Norton 2.) C language developed in. a.) 1970 c.) 1976 b.) 1972 d.) 1980

More information

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

n Group of statements that are executed repeatedly while some condition remains true

n Group of statements that are executed repeatedly while some condition remains true Looping 1 Loops n Group of statements that are executed repeatedly while some condition remains true n Each execution of the group of statements is called an iteration of the loop 2 Example counter 1,

More 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

Arrays and Pointers. CSE 2031 Fall November 11, 2013

Arrays and Pointers. CSE 2031 Fall November 11, 2013 Arrays and Pointers CSE 2031 Fall 2013 November 11, 2013 1 Arrays l Grouping of data of the same type. l Loops commonly used for manipulation. l Programmers set array sizes explicitly. 2 Arrays: Example

More information

Basics of Programming

Basics of Programming Unit 2 Basics of Programming Problem Analysis When we are going to develop any solution to the problem, we must fully understand the nature of the problem and what we want the program to do. Without the

More information

Maltepe University Computer Engineering Department. BİL 133 Algoritma ve Programlama. Chapter 8: Arrays and pointers

Maltepe University Computer Engineering Department. BİL 133 Algoritma ve Programlama. Chapter 8: Arrays and pointers Maltepe University Computer Engineering Department BİL 133 Algoritma ve Programlama Chapter 8: Arrays and pointers Basics int * ptr1, * ptr2; int a[10]; ptr1 = &a[2]; ptr2 = a; // equivalent to ptr2 =

More information

COMPUTER APPLICATION

COMPUTER APPLICATION Total No. of Printed Pages 16 HS/XII/A.Sc.Com/CAP/14 2 0 1 4 COMPUTER APPLICATION ( Science / Arts / Commerce ) ( Theory ) Full Marks : 70 Time : 3 hours The figures in the margin indicate full marks for

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

C Programming Class I

C Programming Class I C Programming Class I Generation of C Language Introduction to C 1. In 1967, Martin Richards developed a language called BCPL (Basic Combined Programming Language) 2. In 1970, Ken Thompson created a language

More information

We do not teach programming

We do not teach programming We do not teach programming We do not teach C Take a course Read a book The C Programming Language, Kernighan, Richie Georgios Georgiadis Negin F.Nejad This is a brief tutorial on C s traps and pitfalls

More information

Programming and Data Structures

Programming and Data Structures Programming and Data Structures Document Prepared By: Dr. Subhankar Joardar (H.O.D.) Mrs. Gitika Maity (Asst.Prof.) Mrs. Patrali Pradhan (Asst.Prof.) Mrs. Sunanda Jana (Asst.Prof.) Mrs. Rajrupa Metia (Asst.Prof.)

More information

Sample Paper Class XI Subject Computer Sience UNIT TEST II

Sample Paper Class XI Subject Computer Sience UNIT TEST II Sample Paper Class XI Subject Computer Sience UNIT TEST II (General OOP concept, Getting Started With C++, Data Handling and Programming Paradigm) TIME: 1.30 Hrs Max Marks: 40 ALL QUESTIONS ARE COMPULSURY.

More information

INDORE INDIRA SCHOOL OF CAREER STUDIES C LANGUAGE Class B.Sc. - IIND Sem

INDORE INDIRA SCHOOL OF CAREER STUDIES C LANGUAGE Class B.Sc. - IIND Sem UNIT- I ALGORITHM: An algorithm is a finite sequence of instructions, a logic and explicit step-by-step procedure for solving a problem starting from a known beginning. OR A sequential solution of any

More information

Pointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017

Pointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017 Pointers (part 1) EECS 2031 25 September 2017 1 What are pointers? We have seen pointers before. scanf( %f, &inches );! 2 1 Example char c; c = getchar(); printf( %c, c); char c; char *p; c = getchar();

More information

Multi-Dimensional arrays

Multi-Dimensional arrays Multi-Dimensional arrays An array having more then one dimension is known as multi dimensional arrays. Two dimensional array is also an example of multi dimensional array. One can specify as many dimensions

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

UNIT III (PART-II) & UNIT IV(PART-I)

UNIT III (PART-II) & UNIT IV(PART-I) UNIT III (PART-II) & UNIT IV(PART-I) Function: it is defined as self contained block of code to perform a task. Functions can be categorized to system-defined functions and user-defined functions. System

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

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide

More information

DELHI PUBLIC SCHOOL TAPI

DELHI PUBLIC SCHOOL TAPI Loops Chapter-1 There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed

More information