Professional Documents
Culture Documents
PART- A
1. Write down the steps involved in writing a program to solve a problem.
To design a program, a programmer must determine three basic steps:
a. The instruction to be performed.
b. The sequence in which those instructions are to be performed.
c. The data required to perform those instructions.
1
7. What you mean by C tokensw? w(Jwun.Ae
C 20
tokens
1e2)are the basic buildings blocks in C language which are constructed together to write
U N wsBlog.net
a C program. Each and every smallest individual unit in a C program are known as C tokens.
„C‟ language contains the individual units called C tokens. C tokens are of six types. They
are as follows
a. Keywords (Ex: int, while)
b. Identifiers (Ex: main, total)
c. Constants (Ex: 10, 20)
d. Strings (Ex: “total”, “hello”)
e. Special symbols (Ex: (), {})
f. Operators (Ex: +, /,-,*)
11. What are Keywords? What is the importance of keywords in C? (May 2015)
Keywords are pre-defined / reserved words in a C compiler. Each keyword is meant to can be
used only for a specific function in a C program. Since keywords are referred names for
compiler, they can‟t be used as variable name. Ex. auto, break, const, else
www.AUNewsBlog.net 2
13. Difference between Local anwdwGwlo.bAaUl
vaerwiasbBle Local Variable Global Variable
N loing.Cn.et
a. Variables are declared inside a function. a. Variables are declared outside any
b. They are accessed only by the function.
statements, inside a function in which b. They are accessed by any statement in the
they are declared. entire program.
c. Local variables are stored on the stack, c. Stored on a fixed location decided by a
unless specified. compiler.
d. Created when the function block is d. Remain in existence for the entire time
entered and destroyed upon exit. your program is executing.
e. They are unknown to other functions e. They are implemented by associating
and to the main program. memory locations with variable names.
f. They are recreated each time a function f. They do not get recreated if the function
is executed or called. is recalled
16. List out the rules to be followed in forming in identifier. (June 2010)
a. First letter should be alphabets.
b. Both numeric and alphabets are permitted.
c. Both lower case and upper case are allowed.
d. No special symbols are permitted except underscore ( _ ).
e. Keywords are not permitted, blank space is not allowed.
17. What is identifier? Give any two examples for an identifier. (Jan 2009)
Identifiers are the names given to variable program elements such as variables, functions and
arrays. Ex. STDNAME, sub, TOT_MARKS,sub123
www.AUNewsBlog.net 3
18. What are Operators? Menwtwiown .AthUeiNr etwypseBs loing.nCe. t What are
operators?
various types (Jan
of C 2014)
An operator is a symbol that tells the compiler to perform specific mathematical or logical
manipulations. C language is rich in built-in operators and provides following type of
operators
a. Arithmetic Operators d. Bitwise Operators
b. Relational Operators e. Assignment Operators
c. Logical Operators f. Misc Operators
20. Give two examples for logical and relational expression. (Jan 2011)
Relational Expression Logical Expression
(a>b) if((a>b)&&(a>c))
(a==b) if((a>b)||(a>c))
22. Write the following conditions using ternary operator. (Jan 2009)
4x+100 for x<40
Salary= 300 for x=40
Salary= x<40?4*x+100:x>40?4.5*x+150:300;
24. What do you meant by conditional or ternary operator? Give an example for
Ternary operator. (Nov 2014)
Conditional or ternary operator‟s returns one value if condition is true and returns another
value is condition is false. Using ?: reduce the number of line codes and improve the
performance of application.
Syntax: (Condition? true_value: false_value); Ex: a<b ? printf("a is less") : printf("a is greater");
4
www.AUNewsBlog.net
25. What is the use of sizeof() opwewrawto.rAiUn NCe?wsBlog.net
sizeof() is used with the data types such as int, float, char… it simply return amount of
memory is allocated to that data types.
sizeof(char); //1
sizeof(int); //4
sizeof(float); //4
sizeof(double); //8
sizeof() is used with the expression, it returns size of the expression.
int a = 0;
double d = 10.21;
printf("%d", sizeof(a+d)); //8
30. Write a for loop statement to print numbers from 10 to 1. (Jan 2014)
#include <stdio.h>
void main(void) Output:
{ 10 9 8 7 6 5 4 3 2 1
int count; // Display the numbers 10 to 1
for(count = 10; count >= 1; count--) Press any key to continue . . .
printf("%d ", count);
}
www.AUNewsBlog.net 5
31. What are the types of I/O stawtwemwe.nAtUs
aNveaiwlasbBleloing.Cn?et
a. Formatted I/O Statements
b. Unformatted I/O Statements.
34. Write the limitations of using getchar() and scanf() functions for reading strings.
(Jan 2009)
getchar(): It is written in standard I/O library. It reads a single character only from a standard
input device. This function is not use for reading strings.
Scanf: It is use for reading single string at a time. When there is a blank was typed, the
scanf() assumes that it is an end.
35. What are the pre-processor directives? (Jan 2014, May 2014, 2015)
Preprocessor directives are the commands used in preprocessor and they begin with “#”
symbol. Before a C program is compiled in a compiler, source code is processed by a
program called preprocessor. This process is called preprocessing.
Syntax: #define
Macro
This macro defines constant value and can be any of the basic data types.
Syntax: #include <file_name>
Header file
The source code of the file “file_name” is included in the main program at
inclusion
the specified place.
Syntax: #ifdef, #endif, #if, #else, #ifndef
Conditional
Set of commands are included or excluded in source program before
compilation
compilation with respect to the condition.
Syntax: #undef, #pragma
Unconditional
#undef is used to undefine a defined macro variable. #Pragma is used to call
compilation
a function before and after main function in a C program.
www.AUNewsBlog.net 6
36. What are storage classes? www.AUNewsBlog.net
A storage class is the one that defines the scope (visibility) and life time of variables and/or
functions within a C Program.
41. Define Macro in C. What is the use of #define preprocessor? (Nov 2014)
A macro can be defined as the facility provided by the C preprocessor by which a token can
be replaced by the user defined sequence of characters. Macros are defined with the help of
define directive. Its format is: #define identifier replacement.
#define TABLE_SIZE 100
www.AUNewsBlog.net 7
45. What will be the output for wthwe wfo.lAloUwNinegwpsroBglroagm.n, ewthen
the (June 2012)
value of i is 5 and 10?
void main()
{
Output
int I; Five (if I is 5)
scanf(“%d”,&i); No output if I is 10
if(i=5)
{
printf(“five”);
}
}
PART - B
1. Explain different data types in C with examples.
2. What are the different operators available in C? Explain with examples.
3. Differentiate Signed and Unsigned integer.
4. Describe the statements for decision making, branching and looping.
5. Explain in detail about the formatted and unformatted I/O functions in C.
6. Discuss about bitwise operators and logical operators in C.
7. Explain any four format string with examples.
8. Write the syntax of „for‟ construct in C. Give an example.
9. Write the algorithm and C program to print the prime numbers less than 500.
10. Explain the following conditional
statements. Nested if-else statement
Switch-case statement
11. Write about the need and types of looping statements in C language and discuss
with examples. (Jan, Nov 2014, May 2015)
12. Write about the need and types of branching statements in C language and discuss
with examples. (Jan 2014)
13. Write a program to check whether a given number is prime or not. (May 2014)
14. Write a C program to find sum of digits of an integer. (May 2014)
15. Write a C program to find roots of a quadratic equation. (May 2014)
16. Differentiate entry and exit checked conditional constructs with an example. (May 2014)
17. What are the various operators available in C? Discuss each one of them with
suitable illustrations. (Nov 2014, May 2015)
18. What are constants? Explain the various types of constants in C. (May 2015)
19. Write a C program to solve any quadratic equations. (May 2015)
www.AUNewsBlog.net 8
UNITwIwI
wA.RARUAN YeSwAsNBDlogS.T
PART-
1. Def
ine array. Give example. (Jan 2009, 2014)
Array can be define as a collection of similar data elements of similar data type that are
stored in consecutive memory locations. They are referenced by an index/subscript.
Syntax: data_type array_name [size] Ex.: int rollno[10];
www.AUNewsBlog.net
9
8. Define Two Dimensional
Two
Arrawdimensional arrays can be defined as an array with two subscripts. A two dimensional
yws. w.AUNewsBlog.net
array enables us to store multiple row of elements. Ex. int a[10][10];
12. What are the limitation of one-dimensional and two dimensional arrays?
The limitations of one dimensional array are
a. There is no easy method to initialize large number of array elements
b. It is difficult to initialize selected array element
The limitations of two dimensional arrays are
a. Deletion of any element from an array is not possible
b. Wastage of memory when it is specified in large array size
www.AUNewsBlog.net 10
15. Write a C program to calculwatwe
#include
wth.eAp<stdio.h>
UoNweewr osfBalongu.mnebter.
int main() Output
{
int base, exponent; Enter a base number: 3
long long result = 1; Enter an exponent: 4
printf("Enter a base number: "); Answer = 81
scanf("%d", &base);
printf("Enter an exponent: ");
scanf("%d", &exponent);
while (exponent != 0)
{
result *= base;
--exponent;
}
printf("Answer = %lld", result);
return 0;
}
www.AUNewsBlog.net 11
17. Write a C program to find twhewnwu.mAbUeNr
array.
oefwes#include
leBmloen<stdio.h>
gt.sneint an
int main() Output
{
int array[] = {15, 50, 34, 20, 10, 79, 100}; Size of the given array is 7
int n;
n = sizeof(array);
printf("Size of the given array is %d\n",
n/sizeof(int)); return 0;
}
www.AUNewsBlog.net 12
25. Write a C program to inputwa wstwri.nAgUaNndewstsorBelothge.inreAt SCII
andinprint
values the array.
an integer array Output
#include <stdio.h>
void main() Enter the no of characters to be
{ in an array 8
char string[20]; Enter the string of 8
int n, count = 0; characters ProgRams
printf("Enter the no of characters to be in an array P = 80 r
\n"); scanf("%d", &n); = 114 o
printf(" Enter the string of %d characters \n" , n); = 111 g
scanf("%s", string); = 103 R
while (count < n) = 82 a
{ = 97 m
printf(" %c = %d\n", string[count], string[count]); =
++ count; 109 s =
} 115
}
26. What is the formula to calculate determinant of 3 x 3 Matrix?
a bc
A d e f | A | aei fh bdi gf cdh eg
g h i
27. What is the use of strlen()?
This function is used to count and return the number of character present in a
string Syntax: len=strlen(string);
www.AUNewsBlog.net 13
32. Define sorting. www.AUNewsBlog.net
Sorting can be defined as a technique to rearrange the elements of a list in ascending or
descending order, which can be numerical, lexicographical, or any user-defined order. Sorting
is a process through which the data is arranged in ascending or descending order.
PART-B
1. Discuss about any eight built in functions of string. (Jan 2013)
2. Briefly explain the various string handling functions in C. (Jan 2010)
3. Write C program to sort the given set of numbers in ascending order. (Jan 2013, 2011)
4. Write C program to find addition of two matrices. (Jan 2013, 2014)
5. Write C program to find multiplication of two matrices.
6. Write a C program to reverse a given string. (May 2011)
7. Write C program to perform scaling on a given matrix.
8. Write C program to calculate determinant of a matrix
9. Write a C program to convert the given string from lowercase characters to uppercase
character and uppercase to lowercase. (May 2011)
10. Write a C program using arrays with height of persons and find how many persons are above
the average height.
11. Populate a two dimensional array with height and weight of persons and compute the Body Mass
Index of the individuals.
12. Write a C program to find largest and smallest number in the given array. (May 2010)
13. Write a C program to concatenate two strings. (May 2009)
14. Write a C program to demonstrate one dimensional, two dimensional and
multidimensional arrays.
www.AUNewsBlog.net 14
UNIT IIwI
FwUwN.ACUTIPART-
NOeNwASsABNloDg.Pn
1. What is a function? (Nov 2014)
A function is a group of statements that together perform a task. Every C program has at least
one function which is main(), and all the most trivial programs can define additional
functions.
15
www.AUNewsBlog.net
9. What are standard library fuwncwtiwon.sA?
The standard library functions are built-in functions in C programming to handle tasks such
UNewsBlog.net
as mathematical computations, I/O processing, string handling. These functions are defined in
the header file. When you include the header file, these functions are available for use. For
example: The printf() is a standard library function to send formatted output to the screen
(display output on the screen). This function is defined in "stdio.h" header file.
13. What are address operator and indirection operator? (Nov 2014)
a. The address operator (&) - It represents the address of the variable.
b. Indirection pointer (*) - When a pointer is dereferenced, the value stored at that
address by the pointer is retrieved.
15. What are actual parameters and formal parameters? (May 2015)
Actual Parameters: The parameters in the calling program or the parameters in the function
call are known as actual parameters.
Formal Parameters: The parameters in the called program or the parameters in the function
header are known as formal parameters.
www.AUNewsBlog.net 16
d. Makes program developmwenwt wea.sAy:UWNoerwk scaBnlobge.dnievitde
implementation
among can be
project members completed in parallel.
thus
e. Program testing becomes easy: Each function can be tested separately and it is easy
to locate and isolate a faculty function for further investigation.
f. Increases program readability.
21. What is a Pointer? How a variable is declared to the pointer? (Jan 2013, May
2009) Pointer is a variable which holds the address of another variable.
Syntax: data_type *variable_name;
Ex.: int *x, a=5;
x=&a;
www.AUNewsBlog.net 17
23. What are the uses of Pointerws?w(wJa.An U20N1e4w,
The
MsBuses
ayloof
2gpointers
0.1n2e, tare
May as2010)
follows
a. Pointers are used to return more than one value to the function
b. Pointers are more efficient in handling the data in arrays ·Pointers reduce
the length and complexity of the program ·
c. They increase the execution speed
d. The pointers save data storage space in memory
www.AUNewsBlog.net 18
29. What will be output of the
#include<stdio.h>
fowllwow wi.nAgUpNroegwrasmB?log.net
int main() Output
{ 20
int n=20; 1260034844
printf(“\n %d “, n); 20
printf(“\n %u“, &n);
printf(“\n %d “, *(&n));
}
19
www.AUNewsBlog.net
www.APUANReTw-
sBBlog.net
1. Explain in detail about Function with example.
2. Explain function with and without arguments with example for each. (Jan 2014)
3. What is recursion? Give an example and explain in detail. (Jan 2014, Nov 2014)
4. Explain (Jan 2014, May 2014, Nov 2014)
(i) Function declaration
(ii) Call by reference; call by value with an example.
5. Explain the use of pointers in arrays with suitable example. (May 2014)
6. How array elements are accessed using pointers?
7. How can you pass a array as a parameter in C? Give an example
8. How can you pass a pointer as a parameter in C? Give an example.
9. Write a function using pointers to add two matrices and to return the resultant matrix
to the calling function. (May 2012)
10. Write a C program to find the factorial of a given number using function. (May 2014)
11. Write a C program to exchange the values of two variables using pass by
reference. (May2014)
12. Write a C program to find the sum of the digits using recursive function. (May 2015)
13. Write a C program to using pointers to read in an array of integers and print its
elements in reverse order. (May 2015)
14. Write an iterative and recursive function to find the power of a number. (Nov 2014)
15. Explain any 5 string functions with example.
16. Explain the math functions briefly.
17. Explain in detail about recursion with an example.
18. Write a program to calculate the sine series using function recursion.
19. Explain pointer arithmetic with examples.
20. Explains the use of pointers in handling arrays.
21. Write a program to sort names using pointers.
22. With a suitable example explain the pass by reference method of calling a function.
UNIT IV STRUCTURES
PART – A
1. Distinguish between arrays and structures.
Arrays Structures
a. An array is a collection of data items of a. A structure is a collection of data items
same data type. Arrays can only be of different data types. Structures can be
declared. declared and defined.
b. There is no keyword for arrays b. The keyword for structures is struct.
c. An array name represents the address c. A structure name is known as tag. It is
of the starting element a Shorthand notation of the declaration.
d. An array cannot have bit fields d. A structure may contain bit fields
www.AUNewsBlog.net 20
2. Differentiate structures and log.net
uwniwonws..A(JUStructure
aNn e20w1s4B) Union
a. Every member has its own memory. a. All members use the same memory.
b. The keyword used is struct. b. The keyword used is union.
c. All members occupy separate memory c. Different interpretations for the same
location, hence different interpretations of memory location are possible.
the same memory location are not possible.
d. Consumes more space compared to union. d. Conservation of memory is possible.
3. Define Structure in C.
Structure can be defined as a collection of different data types which are grouped together
and each element in a C structure is called member. To access structure members in C,
structure variable should be declared. The keyword used is struct.
www.AUNewsBlog.net 21
8. How can you access the memwbwerws .oAf UthNe eUwnsioBnl?og.net
To access any member of a union, use the member access operator (.). The member access
operator is coded as a period between the union variable name and the union member to
access. Union keyword is used to define variables of union type.
22
www.AUNewsBlog.net
member that we wish to access. Pwerwiowd .iAs uUsNedetwo
sinBitlioagli.zneeatstructure. The members of structure can be accessed individually
18. How will you access the structures member through pointers?
The structures member can be accessed through pointers by the following ways
a. Referencing pointer to another address to access memory
b. Using dynamic memory allocation
21. Consider the declaration and illustrate the application of size of operator to
this structure. (Nov 2010)
struct student
{ Size of this is 3 bytes:1 byte for name and 2 bytes for integer num.
char name;
int num;
} S;
www.AUNewsBlog.net 23
c. Search the corresponding
d. noReplace
w wdewi.nthe
AtU heNlein
original wkesofdBthat
value llionode
sgt. .net
by a new value.
e. Display the message as “The node is modified”.
27. List the operations on singly linked list.
a. Create function
b. Display function
c. Search function
d. Insert function
e. Delete function
PART - B
1. Define Structures. Explain structures in detail.
2. Explain array of structure in C.
3. Write a C program to create mark sheet for students using structure. (Jan 2014)
4. How can you insert structure with in another structure?
5. Explain the concept of structures and functions, structures and pointers with example.
www.AUNewsBlog.net 24
6. Define Union. Explain Union inwdwewta.iAl.
U(M
7. Naeare
What ywstorage
2s0B15classes?
lo) g.netExplain each with example. (May 2014, Jan 2014, May 2015)
8. Describe in detail about the Preprocessors in C.
9. What is a structure? Create a structure with data members of various types and declare two
structure variables. Write a program to read data into these and print the same. (Nov 2014)
10. Justify the need for structured data type. (Nov 2014)
11. Write notes on: (Nov 2014)
(i) Unions
(ii) Register storage class
(iii) #include statement
(iv) #ifndef…#endif
12. Define a structure called book with book name, author name and price. Write a C
program to read the details of book name, author name and price of 200 books in a library and
display the total cost of the books and the book details whose price is above Rs. 500. (May
2015)
13. Write a C program using structure to store date, which includes day, month and year. (Jan
2014)
14. Write a C program to store the employee information using structure and search a
particular employee using Employee Number. (June 2014)
15. A sample C programming code for real time Bank application program is given below.
This program will perform all below operations.
(i) Creating new account: To create a new account
(ii) Cash Deposit: To Deposit some amount in newly created account
(iii)Cash withdrawal: To Withdraw some amount from your account
(iv) Display Account information: It will display all information‟s of the existing accounts
(v) Log out
(vi) Clearing the output screen and display available options
www.AUNewsBlog.net
6. Define Union. Explain Union inwdwewta.iAl.
U(MNaeyw2s0B15lo) g.net
25
www.AUNewsBlog.net
3. What are the standards
strewamwswa.vAaUilaNbelewisnBCloLga.nngeut age?
a. Standards input(stdin)
b. Standards output(stdout)
c. Standards error(stderr)
a. File name
b. File Position
c. File Structure
d. File Access Methods
e. Attributes flag
7. What are the statements used for reading a file? (Nov 2014)
a. FILE*p;Initialize file pointer.
b. fp=fopen(“File_name” ”r”);Open text file for reading.
c. Getc(file_pointer_name);Reads character from file.
d. fgets(str,length,fp); Reads the string from the file.
www.AUNewsBlog.net 26
11. What is file pointer? www.AUNewsBlog.net
The pointer to a FILE data type is called as a stream pointer or a file pointer. A file pointer
points to the block of information of the stream that had just been opened.
www.AUNewsBlog.net 27
20. What is purpose of library fwunwcwtio.An
UNewsBlog.net
a. The C library function int feof(FILE*stream) tests the end-of-file indicator for the
given stream.
b. This function returns a non-zero value when End-of-file indicator associated with the
stream is set, else zero is returned.
www.AUNewsBlog.net 28
25. List the difference between Awpwpwen.Ad UanNdewwrsitBelomgo.dneet
Write (w) mode and append mode, while opening a file are almost the same. Both are used to
write in a file. In both the modes, new file is created if it doesn‟t exists already.
The only difference they have is, when you open a file in the write mode, the file is reset,
resulting in deletion of any data already present in the file. While in append mode this will
not happen. Append mode is used to append or add data to the existing data of file (if any).
Hence, when you open a file in append(a) mode, the cursor is positioned at the end of the
present data in the file.
www.AUNewsBlog.net 29
33. What is the advantage of a rwanwdwom.AUacNceesws fsilBe?log.net
If the amount of data stored in a file is fairly large, the use of random access will allow you to
search through it quicker. If it had been a sequential access file, you would have to go
through one record at a time until you reach the target data. A random access file lets you
jump directly to the target address where data is located.
34. How do you search data in a data file using random access method?
Use the fseek() function to perform random access input / output on a file. After the file was
opened by the fopen() function, the fseek would require three parameters to work: a file
pointer to the file, the number of bytes to search, and the point of origin in the file.
PART - B
1. What is file in C? Give brief introduction about files and its operations.
2. How to read and write the binary file? Explain with example.
3. Briefly explain the concept of the file management functions.
4. List out some inbuilt functions for file handling in c language.
5. How to access random access file? Write an example program.
6. Give brief notes about command line arguments in c.
7. Write a C program to write data to a text file and to read it.
8. Create a file, which contains a series of integer numbers. Search all odd numbers and save
it to file called odd.txt. Search all even numbers and save it to a file called even.txt.
9. Write a C program to implement the random access file.
10. Write a C program for handling records (structures) in a file.
11. Write a C program to calculate electricity bill as per the consumer usage.
12. Write a program to copy contents of input, txt file to output .txt file.
13. Explain about random access to files with examples.
14. Write a program that reads a text of characters from a file in departmental store and keep
track of the frequency of usage of each items stock and price.
15. Write a C program to read name and marks of n number of students from user and store
them in a file. If the file previously exits, add the information of n students.
16. With a C program find Sum of numbers given in Command Line Arguments Recursively
17. Write a C program for the following. There are two input files named “first.dat” and
“second.dat”. The files are to be merged. That is, copy the contents of first.dat and then
second.dat to a new file named result.dat.
18. Write a program to read the current date in the order: year, month, and day of month. The
th
program then prints the date in words: Today is the n day of Month of the year Year.
th
Example: Today is the 24 day of December of the year 2000
19. Explain the command line argument. What are the syntactic constructs followed in C?
20. Write a C program to copy the contents of one file into another using command line
arguments.
21. Explain about transaction processing using random access files.
22. Write a C program to find average of numbers stored in sequential access file.
www.AUNewsBlog.net 30