Wednesday, October 1, 2014

2012-13 (ODD SEM)

b.Tech.

(Semester –I) odd semester Theory Examination, 2012-13

COMPUTER PROGRAMMING

 
Section – A

1.      Attempt all parts:                                                                             (2 X 10 = 20)

(a)    In C-programming what are keywords? What restrictions apply to their use?
(b)   Distinguish between the following pairs:
(i)     main() and void main(void)
(ii)   int main() and void main()

(c)    Differenciate between getchar and scanf functions. In response to the input statement

scanf(“%4d%*%d”,&year,&code,&count);

the following data is keyed in 19883745, what values does the computer assign to the variables year, code, count?
(d)   The following is a segment of a program:
x=1;
y=1;
if(n>0)
  x=x+1;
  y=y+1;
printf(“%d%d”,x,y);

                  What will be the values of x and y if n assumes a value of (i) 1 and (ii) 0?
(e)    How can we use for loops when the numbers of iteration are not known?
(f)    What is an array? Also give its important properties.
(g)   What is meant by the following terms:
(i)     Nested structures
(ii)   Array of structures
(h)   What is the full form and significance of EOF?
(i)     Name the four types of variable storage classes.
(j)     Distinguish between #ifdef and #if directives.

SECTION – B
 
2.      Attempt any three parts:                                                                (10 X 3 = 30)

a)       
(i)     What do you mean by flow chart? Draw a flow chart to find whether the given year is a leap year or not.
(ii)   Convert the following:
1)            (110101110)2>= ( )10
2)            (162)8 >= ( )2
3)            (87)10>= ( )16
4)            (A9B)16>= ( )2
5)            (43)10>= ( )2

b)      Describe the four basic data types. What is an unsigned integer constant? What is a variable? How do variables and symbolic name differ? What is initialization and why is it important?

c)       
(i)     Write a program in ‘C’ to read an integer number from keyword, add 1 to it if the number read is even, again add 1 to it if the number is less than 20, otherwise keep the number unchanged and print the final result.
(ii)   Write a program in ‘C’ to generate the following pattern:
5
54
543
5432
54321

d)     Describe structure. Differentiate between structure and array. Define a structure data type called time_struct containing three member’s integer hour, integer minute and integer second. Write a program in ‘C’ that would assign values to the individual members and display the time in the following form:
16:40:52

e)      Explain the following with example:
(i)     Conditional compilation and passing values to compiler.
(ii)   Five basic operating system commands in Linux.

Section – C


Q3. Attempt any two parts:                                                                              (5 X 2 = 10)

(a)    What is an algorithm? What is pseudo-code? Write an algorithm in pseudo code to find total number of even integers from given set of 100 integers.
(b)   Define the term software and hardware. Briefly explain system software and application software with at least one example of each.
(c)    Define the following terms and give at least one example of each:
(i)     Compiler
(ii)   Linker
(iii) Operating system
(iv) Editor
(v)   Procedural programming

Q4. Attempt any two parts:                                                                              (5 X 2 = 10)
(a)    Explain the function of modulus operator. Write a program in ‘C’ that will read a real number from the keyboard and print the following output in one line:

Smallest integer not                The given                    Largest integer not greater
Less than the number              number                        than the number

(b)   Develop a top-down modular program in ‘C’ that will perform the following task:
(i)     Read two integer arrays with 10 unsorted elements in each
(ii)   Sort each array in ascending order
Use functions for carrying out each of the above tasks. The main function should have only function calls in it.

(c)    A function to divide two floating point numbers is a s follows:
Divide (float x, float y)
{
                        return (x/y);
}

What will be the value of the following function calls?
(i)                 Divide(10,2)
(ii)               Divide(9,2)
(iii)             Divide(4.5,1.5)
(iv)             Divide(2.0,3.0)
(v)               Divide(4,5)

Q5. Attempt any two parts:                                                                              (5 X 2 = 10)

(a)    Write a program in ‘C’ that fills a five-by-five matrix as follows:
·         Upperleft triangle with +1s
·         Lower right triangle with -1s
·         Right to left diagonal with zeros
Display the contents of the matrix using not more than two printf statements.

(b)   Differentiate between do-while and while loop. Given a number write a program in ‘C’ using while loop to reverse the digits of the number. For example, the number 12345 should be outputted as 54321.

Q6. Attempt any two parts:                                                                              (5 X 2 = 10)

(a)    What is a pointer? What are they required? With reference to pointer define the work of & operator? Write a program in ‘C’ using pointers to swap two numbers.
(b)   Describe the use and limitations of the functions getc() and putc(). Write a program in ‘C’ to read data from the keyboard, write it to a file called INPUT, again read the same data from INPUT file, and display it on the screen.
 
Q7. Attempt any two parts:                                                                              (5 X 2 = 10)

(a)    What is a string? Write a program in ‘C’ that allows the user to enter a string and perform the following operations on it:
(i)                 Count number of characters in string
(ii)               Remove spaces in string
(iii)             Count number of words in it

(b)   Explain the role of the C preprocessor. What is macro and what precautions one should take when using macros with arguments? What are the advantages of using macro definitions in a program? Give one example of using macro in a program.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.