2007 SRM University B.Tech Electronics and Communications Engineering SYLLABUS / QUESTION BANK FOR COMPUTER PROGRAMMING Question paper
DEPARTMENT OF COMPUTER APPLICATIONS
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
SRM NAGAR, KATTANKALATHUR
SYLLABUS / QUESTION BANK
Class & Semester : I ECE & II Semester
Subject Code : CS152
Subject Name : COMPUTER PROGRAMMING
Prepared by :R.M.Vallikannu, C.Padma, B.Priyadharshini, V.Dhanakoti, S.Metilda Florence, A.Vijay Bharath
This course gives a fundamental understanding of the C Language and UNIX operating system.
? C Language constructs and programming concepts
? Advanced concepts like arrays, files and pointers
? Unix file systems and commands
? Unix shell programming and scripting
UNIT - I : INTRODUCTION
Historical perspective and current issues in C. Overview of a simple C program. Elementary data types Enumeration types, TypeDefs, Variables, Constants, Character Processing, Strings, Operators, expressions, precedence rules, Storage classes, Basic input/output (I/O) techniques and program control mechanisms. Compiling and executing a C program. Preprocessing Directives, Built in Library functions - mathematical, character, string, I/O.
UNIT - II : CONTROL STRUCTURES AND FUNCTIONS
Control flow - Statements and blocks, If-Else, Switch statement, While and For loops. Do-While loops, Break and Continue. Functions and Program Structure - The C preprocessor, Variable initialization, Static and Register variables, External variables, Header Files, Basics of functions, Functions returning values.
UNIT - III : ARRAY STRUCTURE AND POINTERS
Arrays, Structures : Arrays - Array notation, Manipulating array elements, Arrays of unknown size, Array initialization, Dynamic Memory allocation. Structures - Purpose and usage of structures, Declaring a structure, Array of structures, Pointers to structures. Self-referential structures, Table lookup, Typedef and Unions.
UNIT - IV : UNIX INTRODUCTION
Unix system, components of Unix, structure of Unix file system, directories, wildcards, finding files, archives, file I/O, backingup, linking, utilities. Unix shell commands, pipes, filters, Login and logout, using korn, bourne and C shells as programming language.
UNIV - V : ADVANCED CONCEPTS
Limitations of Unix, FTP and Telnet, Regular expression parsing and engines - grep, egrep, sed, awk, vi etc. Process and signals - fork, Networking commands, Unix programming in C.
1. Harvey M.Deital, Paul Deital, "C - How to Program", Pearson Education Asia Publication, 2001.
2. Brain W.Kernighan et al, "C Programming Language, 2nd Edition., 1998.
3. Richard Stevens, "Unix Network Programming" , PHI, 1990.
1. Mullish Cooper, "The spirit of C, Jaico publishing house, 2002
2. Maurice Bach, "Design of Unix Operating System", PHI 1999.
1. Describe the four basic data types.
2. How to get a string as input using scanf( ) function?
3. What are enumeration variables? How are they declared?
4. When dealing with numbers, what steps would you take to improve the accuracy of the calculations?
5. What is initialization? Why is it important?
6. Define four types of storage classes.
7. What is constant? Give example.
8. Write short note on typedef.
9. List out the rules to be followed while naming a variable?
10. What is Type Casting?
11. Write C assignment statements to evaluate the following equations.
Side = ? a2 + b2 - 2ab cos (x)
12. Evaluate the following expressions using precedence rules.
X - (Y/(3+3) * 2) -1
Where X = 9
13. What is structured programming?
14. How do you read & write a single character?
15. What is variable?
16. How do you get input from the user and also display the output on the screen in the 'C' language?
17. List out the any four string-handling functions and their uses.
18. What is the use of header file?
19. What is the size and range of basic data types?
20. Explain the role of C preprocessor.
21. Write the difference between preprocessor and macro in C.
22. What is a macro and how is it different from a C variable name?
23. Distinguish between #ifdef and #if directives.
24. List out the operators used in C language.
25. Explain the use of header files in C.
PART - B
1. Explain the different data types used in C with examples.
2. Explain various string functions used in C with examples.
3. Explain the different types of storage classes with example.
4. Write short notes on operators and expression.
5. Discuss about the library functions, which are used in 'C' language.
6. (i) Discuss about the precedence rule in the 'C' language.
(ii) How do you get a formatted output?
7. (i) Write a Basic structure of C Program.
(ii) How do you compile and execute a C Program in a Vain System?
8. (i) What is symbolic constant?
(ii)Write a program to convert temperature in Fahrenheit to Celsius using symbolic
9. Discuss the preprocessor in C language.
10. Explain variables, constants, enum data type & operators in the 'C' language.
1.Write the difference between while and do..while.
2.What are the different forms of ‘if’ control structure.
3.Write the syntax for ‘switch’ statement.
4.Write the syntax for ‘for’ loop structure.
5.What is the use of ‘break’ in a loop structure.
6.What is the use of ‘continue’ in a loop structure.
7.What are the different forms of functions.
8.Write a program to find the largest of three numbers.
9.Explain the significance of break statement in switch-case construct.What would result in the absence?
10. When is the default keyword useful in a switch-case construct?
11. Write a program to generate fibonacci series.
12. Write the difference between break and continue.
13.Write the usefulness of functions.
14. What is function declaration?
15. What is function definition?
16.What is an argument/ parameter? How do you pass it over function.?
17.What are the two ways by which you can pass arguments?
18.When are function declaration useful?
19.What is the necessity of a ‘return’ statement?(or)When is the return statement mandatory in a function.
20.Clearly differentiate between function prototype, function definition and function call.
21.Distinguish between actual and formal parameters.
22. Distinguish between recursion and iteration.
23. Define ‘extent’ of a variable.
24. Define ‘scope’ of a variable.
25.What is the use of scope resolution operator.
26.Differentiate between local and global variable.
27.What are the four storage classes?
28.What are auto variables?
29.When is register storage class most useful?
30.What is static storage class?
31.When is extern qualifier used?
32.Name few header files in ‘C’.
33 Name an header file and list out few functions under it.
34.List out some activities of the preprocessor.
35.Give an example for macro substitution.
36.Give an example for array initialization.
1.Explain all the control structures available in ‘C’.
2. Explain all the loop structures available in ‘C’.
3.Write a program to compute sin series.
4.Write a program to convert binary number to decimal number.
5.Write a program to check whether the given number is palindrome.
6.Write a program to find the roots of a quadratic equation using switch-case.
7.Write a program to find factorial of a number using recursion.
8.Write a program to generate Pascal’s triangle.
1 2 1
1 3 3 1
1 4 6 4 1
9.Write a program to search an element from a list of elements using binary search method.
10.Explain all the storage classes with suitable example.
11.Explain the different forms of functions with an example.
1. Explain an array with proper example?
2. Show an example for passing array elements to a function.
3. Write a program to show Pointers and Arrays together
4. Write a program to input string and store it in an array and finally print the array
5. Describe Array initialization with proper example.
6. Initialize a 2 dimensional array with proper example.
7. Describe a multi dimensional array with example.
8. Write a program to copy one array to another
9. Define Structures with proper example.
10.Write a syntax of a structure,rules for declaring a structure and give a proper example.
11. Write an example for accessing structure elements.
12. Write a program to store 100 records in 1 structure with the help of arrays.
13. Write an example for structure to funtion.
14. Write short notes on Unions and write its syntax
15. Describe the structure variable and arrays
16. Describe initialization of structure variable and array
17. What is a pointer ? What are the uses of pointers ?
18. Describe assigning value of a structure to another structure.
19. What is the use of structures?
20. Explain different dimensional arrays?
PART - B
1. Write a program to add two matrices of order M*N
2. Write a program to sort a set of N numbers in ascending order and explain the algorithm used.
3. Write a program to find the sum of given N integers using an array
4. Write a program to read a list of test marks (integers in the range of 0-100) of 50 students.calculate the mean of marks and printa list marks greater than mean (rounded to 2 decimals)
5. Write a program to search a key value in each set of N values.Print the position of key value if it is a successful search
6. Write a program to multiply a matrix of order M*N with b matrix of order N*L
7. Write a program to find and print the transpose of a matrix.
8. Write a program to print the smallest value in a given array along with the position in the array
9. Write a program to find the second largest value in the array of numbers
10. Write a program to read x1,x2,x3....upto xn of raw data and compute the number of data above and below the mean (average) using while statement to find average
11. Write a program to sort the elements of an array in descending order
12. Write a program to search an element in an array of N elements
13. Write a program to find the product of two matrix
14. 4 tests are given to a class of 30 students.Write a program that calculates the average in each tests and the class average of all the tests.
15. Read and Display a character array until '$'
16. Write a program to input information about N students in a class given the following:
Roll no,Student name,Total marks.The program should output the marks of specified
students given his/her roll numbers.(using structure)
17. Declare structure of students with details like roll no,student name,total marks.Using this declare an array with 50 elements.Write a program to read details of 'N' students and print the list of students who have scored 75 marks and above.
18.Create a structure to store the following information of an employee.
Employees no,name, pay,date of joining.
It is decided to increase the pay as the following rules.
pay <=Rs.2000 :15% increase
pay <=Rs.5000 but >Rs2000 :10% increase
pay > Rs.1500 :no increase
write a program using a function
19. Read a employee biodata from a file using structure("biodata.txt")and display is in the screen.
20. Read ten biodatas from a file ("bioten.txt") and display is in the screen.
UNIT - IV
PART - A
1. Name any 5 salient features of UNIX operating system.
2. What is the basic difference between DOS, WINDOWS 95 and UNIX.
3. State two different ways in which you would identify whether a given file is an ordinary file or a directory.
4. What does uid and gid signify?
5. Write the UNIX equivalent of the following DOS commands.
DIR DEL COPY TYPE CD MD RD REN
6. What is the meaning of . and .. ?
7. How will you print the listing of the parent directory from the current directory?
8. How will you forcibly remove a file to which you don’t have write permission?
9. How will you print the contents of files “aaa” “bbb” “ccc” using a single command?
10. What is Boot Block?
11. What is Super Block?
12. What is Inode Table?
13. What is Data Block?
14. When a file is deleted what happens to its entry in the inode table?
15. What do you mean by a filter? Give examples of filters.
16. Which of the following are filters?
Date head grep tail ls more who pg ps tee
17. Can we redirect the output to keyboard and redirect input to screen?
18. What is the difference between the commands :
cat < file1 > file2
cat > file2 < file1
19. List out the logical operators in UNIX.
20. Write about shell variables.
21. Write about shell keywords.
22. Write about arithmetic operators in shell programming.
23. Explain read command in UNIX.
24. What is tput? Explain.
25. What are the typical characteristics of a UNIX file system?
26. How will you list the current directory in columnar format?
27. What is the usual permission settings for a file and a directory?
28. Can a file have more than two links?
29. Which command is used to write in-core super block and inode table information to the disk.
30. What is the size of each entry in the inode table?
PART - B
1. Write about the UNIX file system.
2. List out all file and directory related commands in UNIX.
3. What is piping? Explain with example.
4. List out the commonly used filters in UNIX and explain.
5. Explain about different form of if statement in UNIX with example.
6. Write about the test command in detail with example.
7. Explain the following:
8. (i) Write about the loop control structures in UNIX.
(ii) Explain the following :
(a) while statement
(b) until statement
(c) for loop
9. (a) Write a shell script to print prime numbers from 1 to 300.
(b)Write a shell program to find the factorial of any number entered through the keyboard.
10. What will be the effect of following UNIX commands.
(iv) in dir1 dir2 (dir2 is existing on the disk)
(v) du ../..
(vi) du .
UNIT – V
PART - A
1. Give two limitations of Unix operating systems.
2. What is file transfer protocol?
3. What is Telnet?
4. How telnets accessed?
5. Explain GREP command.
6. Explain EGREP command.
7. Explain Sed command.
8. Explain Awk command.
9. Explain Vi command.
10. What is a fork process?
11. What are commonly used edit commands.
12. What are the operators used in Sed regular expressions?
13. Give the EGREP command line options.
14. How EGREP commands differ from GREP command?
15. Give the usage of Sed command.
16. Give some regular expressions in Awk
17. What operators can be used in AWK?
18. Explain the Awk variables.
19. Give some of the Awk functions.
20. Explain the purpose of using Vi editor command.
PART - B
1. Explain briefly the limitations of Unix operating system.
2. Discuss briefly the file transfer protocol? Why it is used?
3. How would you access the remote system by Telnet?
4. Explain the following commands.
5. Explain the fork( ) process with an example.
6. Explain the usage of Sed command with example.
7. Explain briefly the use of regular expressions in Sed.
8. Explain in brief the GREP and EGREP command with example.
9. How would you invoke Awk? Explain the use of regular expression in Awk.
10. Discuss about the various functions and variables in Awk.
Return to question paper search