Programming in C and Data Structures - Jun 2015

First Year Engineering (C Cycle) (Semester 2) Visveswaraya Technological University Solved Question Papers eBook

1 (a) What are the data types? Mention the different data types supported by C language, giving an example...

Answer: Data types refers to an extensive system used to declaring variables. The different data types supported by C are: Integer data types, Data type Description Requiredmemeory in bytes Rang...

To view full answersGET A SUBSCRIPTION

1 (b) Write a C program which takes as input p,t,r compute the simple interest and display the result.

Answer: # include<stdio.h> #include<conio.h> void main() { intp, r, t; float s; printf(" Enter the values:\n"); printf("p = amount invested \n"); scanf("%d",&p); printf("r = rate of interest\n "); scanf(&...

To view full answersGET A SUBSCRIPTION

1 (c) What is an operator ? List and explain various types of operations

Answer: An operator is a symbol that tells the compiler to perform specific mathematical or logical operations. The various operators supported by c are: Arithmetic operators Relational operators Logical operators Assignment operators Unary operators Conditional operators Bit...

To view full answersGET A SUBSCRIPTION

2 (a) What is a token? What are different types of token available in C language? Explain

Answer: Each and every individualunit in a C Program is known as tokens in C.The lexical elements of the c language are characters and white spaces that are grouped together into tokens. Example: int, main , void etc. The different types of token available in c are:&...

To view full answersGET A SUBSCRIPTION

2 (b) Write C expressions corresponding to the following (Assume all quantities are of same type) i)...

Answer: ...

To view full answersGET A SUBSCRIPTION

2 (c) What is the value of 'x' in following code segments? Justify your answer: i) inta,b; float x; ...

Answer: First: int a, b; float x; a = 4; b = 5; x = b/a; Since, a and b are integer so result of b/a also integer.Hence value of x is 1. Second: int a, b; float x; a = 4; b = 5; x = (float) b/a; Since, a and b are integer so result of b/a also integer....

To view full answersGET A SUBSCRIPTION

3 (a) What are different types of conditional decision making statements? Explain each with examples

Answer: The different types of conditional decision making statements are: if statement if else statement else if statement switch statement 1.if statements:it is the simplest decision making statement. If statement is used to execute some code, if a condition i...

To view full answersGET A SUBSCRIPTION

3 (b) Write a C program to simulate simple calculator that perform arithmetic operations using switch...

Answer: #include<stdio.h> #include<conio.h> void main() { int n1, n2, op; printf("Enter the value for n1 and n2\n"); scanf( "%d %d", &n1, &n2); printf("Enter the option\n"); prinft( "Calculator\n 1. Addition \n 2...

To view full answersGET A SUBSCRIPTION

4 (a) Explain with examples formatted input output statements in C.

Answer: Formatted Output: The printf Function:this function can be used to display any combination of numerical values, single characters and strings. Example: printf( "My roll number is%d\n", rollno); printf statement consists of two parts:...

To view full answersGET A SUBSCRIPTION

4 (b) List four differences between while loop and do-while loop along with syntax and example

Answer: while loop do while loop 1)It is entry controlled loop 1)It is exit controlled loop 2)There is no need of the semicolon 2)Always remember the semicolon ; as it may result in syntax error ...

To view full answersGET A SUBSCRIPTION

4 (c) Design and devlop a C program to reverse a given four digit integer and check whether it is a...

Answer: #include<stdio.h> #include<conio.h> void main() { int n, rem, rev=0 ,temp; printf (" enter the numbers\n"); scanf("%d",&n); temp = n; while (temp!=0) { rem = temp%10; rev= rev*10+rem; temp = temp/10; } pri...

To view full answersGET A SUBSCRIPTION

5 (a) What is an array? Explain different methods of initialization of single dimensional arrays

Answer: Array is a collection of items of same data types that will be referred as single name .C langauage supports one dimensional and multi dimensionalarray.We now that a variable can hold one value at a time so if we want to store many elements at a time in memory we have to use as variab...

To view full answersGET A SUBSCRIPTION

5 (b) Write a C program to read N integer into A and to i) Find the sum odd numbers ii) Find the sum if...

Answer: Algorithm:- Start Take the number of integers as input from the user. Make an array which can store the speified number of integers. Initialize two counters which will store the sum of even numbers and odd numbers respectively. Set them to 0. Allow the user to input an eleme...

To view full answersGET A SUBSCRIPTION

5 (c) Hoe string is declared and initialized? Explain any FOUR string manipulator function with example

Answer: The general form of declaring string variables is: char string_name [size] The size determines the number of characters in the string Example: char country[20]; char name[30]; here, sring country can have 20 characters and name can have 30 characters. ...

To view full answersGET A SUBSCRIPTION

6 (a) Explain function cell, function definition and function prototype with example to each

Answer: Function Definition: It contains the function name with parameter list and the type specification of the value return by the function and the functional body. The return_data_type represents the type of data we want to return upon completion of the function or void if ...

To view full answersGET A SUBSCRIPTION

6 (b) What are actual parameter and formal parameters? Illustrate with example

Actual parameters are parameters as they appear in function calls. Formal parameters are parameters as they appear in function declarations. A parameter cannot be both a formal and an actual parameter, but both formal parameters and actual parameters can be either value parameters or variable...

To view full answersGET A SUBSCRIPTION

6 (c) What is recursion? Write a C program to compute the factors of given number 'n' using recursion

Answer: A function can be called within itself or a function can call itself is know as recusive function and this technique is called Recursion. #include<stdio.h> #include<conio.hintfact(int); void main() { int n, answer; clrscr(); printf( "Enter the n...

To view full answersGET A SUBSCRIPTION

7 (a) How structure is different from an array? Explain declaration of a structure with an example

Answer: Structure is different from an array as followss: Like arrays, structures are single, named items which on closer examination have internal fields which can holds values. Array is a derived data type where as structure is a programmer defined data type. Unlike array, the members...

To view full answersGET A SUBSCRIPTION

7 (b) Explain with an example, how to create a structure using 'typedef'.

Answer: The C programming language provides a keyword calledtypedef, which you can use to give a type a new name. Following is an example to define a termBYTEfor one-byte numbers: typedef unsigned char BYTE; After this type definitions, the identifier BYTE can be used as...

To view full answersGET A SUBSCRIPTION

7 (c) Write a C program to input the following details of 'N' student using structure: Roll No: integer,...

Answer: #include <stdio.hstructstud{char name[20]; int roll; float marks; char grade; }; int main(void) { int n; scanf("%d", &n); &n...

To view full answersGET A SUBSCRIPTION

8 (a) Explain following file operations along with syntax and examples: i) fopen ii) fclose iii) fscanf()...

Answer: A file is a collection of related data, that is records. C supports 2 types of files: Binary file: It is efficient for large amount of numeric data. Text file: It stores text and numbers as one character per byte. File operations: i) fopen: Opening a file e...

To view full answersGET A SUBSCRIPTION

8 (b) Write a C program to read the contents from the file called abc.txt, count the number of characters,...

Answer: C program to read the contents from the file called abc.txt, count the number of characters, number of lines and number of while spaces and output the same. The following programme is compiled in Dev C++ Compiler. #include<stdio.h> #include<conio.h> #include<stdlib....

To view full answersGET A SUBSCRIPTION

9 (a) Define point variable. Explain with an example, the declaration and initialization of pointer...

Answer: Defination: A variable that stores a address of another variable is known as pointer variable or we can say a variable that can point to another variable is called as a pointer variable. Syntax Delaration: int *p; int *a; Initialisation: The...

To view full answersGET A SUBSCRIPTION

9 (b) Explain following C function along with syntax and example to each: i) malloc() ii) calloc() iii)...

Answer: 1.Malloc() function malloc()function is used for allocating block of memory at runtime. This function reserves a block of memory of given size and returns a pointer of type void. This means that we can assign it to any type of pointer using typecasting. If it fails to lo...

To view full answersGET A SUBSCRIPTION

9 (c) Develop a C program to read two number and function to swap these number using pointers

Answer: A variable that stores a address of another variable is known as pointer variable or we can say a variable that can point to another variable is called as a pointer variable. Source Code: #include <stdio.h> void swap(int *a, int *b) //Function Declaration { nb...