Unit - I (2 Marks)
Unit - I (2 Marks)
Unit - I (2 Marks)
Part -A
1. What is meant by Structured Programming?
Structured Programming is a type of programming that generally converts large or complex
programs into more manageable and small pieces of code.
These small pieces of codes are usually known as functions or modules or sub-programs of
large complex programs.
It is known as modular programming and minimizes the chances of function affecting
another.
2. Give the structure of C program.
4
However, you may run into problems in some compilers if the variable name is
longer than 31 characters.
24.Write a C program to get a paragraph of text as input.
#include<stdio.h>
int main() {
char inputString[128], c;
int index = 0;
printf("Enter a multi line string( press ';' to end input)\n");
while((c = getchar()) != ';'){
inputString[index++] = c;
}
inputString[index] = '\0';
printf("Input String = %s", inputString);
return 0;
}
Output
Enter a multi line string(press ';' to end input)
Welcome
To C programming and Data Structures;
Input string
Welcome
To C programming and Data Structures;
25.Give the Length and Range of Primitive data types.
Keyword Size in
Data type Range Use
used bytes
Char char 1 -128 to 127 To store Characters
Int int 2 -32768 to 32767 To store integer numbers
Float float 4 -38 38 To store Floating point numbers
3.4*10 to 3.4*10
Double double 8 -308 308 To store big floating point numbers
1.7*10 to 1.7*10
26. What is function? List the purpose of function. Or What is the need for functions?
A function is a self-contained block of program statements that performs some specific
well-defined task. It is often defined as a section of a program performing a specific job.
Purposes:
To enable code reusability.
To improve readability of program.
To avoid code redundancy
27. Write the syntax for including Function?
The syntax for including functions in program is
return_type function_name(datatype var1, datatype var2,…); //FUNCTION
DECLARATION
int main()
{ …..
variable_name = function_name(var1, var2, …); //FUNCTION CALL
return 0;
}
return_type function_name(datatype var1, datatype var2,…) //FUNCTION DEFINITION
5
{
statements
……
return(variable);
}
28. What are the components of a Function?
Function Declaration
Function Definition
Function Call
29. Differentiate actual parameter and formal parameter.
Actual Parameter Formal Parameter
The Actual parameters are the values that The Formal Parameters are the variables
are passed to the function (i.e., in a defined by the function (i.e., in a function
function call) when it is invoked. header) that receives values when the
function is called.
The actual parameters are passed by the The formal parameters are in the called
calling function. In actual parameters, function. In formal parameters, the data types
there is no mentioning of data types. Only of the receiving values should be included.
the value is maintained.
30. State the difference between pass by reference and pass by value.
Part - B
1. Discuss about the various data types in “C”.
2. Explain in detail about “C” declarations and variables. (Jan 2011)
3. What are constants? Explain the various types of constants in C. (May 2015)
4. Explain about the various decision making statements in “C” language. (or) Write notes on
Branching Statements in C. (Jan 2014, May 2014, Jan 2016)
5. Explain various operators in c with example? (Nov/Dec 2014) (May 2015)
6. Explain briefly about the formatted and unformatted I/O function in C. (Jan 2012).
7. Explain the different looping statement with example?
(Jan 2014, Dec 2014, Jan 2016, May 2015)
8. Differentiate entry and exit checked conditional constructs with an example. (May 2014)
9. Write a C program to check whether the given number is palindrome or not
7
10. Write a C program to sum of digits of an integer. (Jan 2012, May 2014)
11. Write a C program for 1+2+3+4+5…n (Jan 2012)
12. Write a program to solve the Quadratic equation. (May 2015)
13. Write a program to find whether a number is prime or not. (May 2014)
14. Write a C program to reverse a String. (Jan 2014)
15. Write a program to print Fibonacci series for a given number. (Jan 2014)
16. Write a C program to find the Sum and difference of two matrices. (or) Write a C program
to add and subtract two matrices. (Jan 2014, May 2014, May 2015)
17. What is sorting? Write short notes on its types. Write a Program to Sort a set of numbers.
(or) Write a C program to arrange numbers in ascending order.
(May 2014, Dec 2014, May 2015, Nov 2017)
18. What is an array? Explain the characteristics and Classification of an array with examples.
19. Write a C program to find the largest and smallest element in an array.
20. Write a C program to search a given number in an array of elements.
(Nov/Dec 2014, May 2015)
21. Write a program using control structure if…..else that examines the value of an integer
variable called rating and print one of the following messages,
“Not recommended” – if the value of rating is less than 2
“Recommended” - if the value of rating lies between 2 and 4
“Highly recommended” - if the value of rating is above 4 (Nov/Dec 2022)
22. Define Recursive Function in C and Write a program to print the numbers from 1 to 5 using
recursive function. (Nov/Dec 2022)
23. Predict the output of the following Program and state the reason (Nov/Dec 2022)
int main()
{
int i=0;
while(i<=4)
{
printf(“%d”,i);
if(i>3)
goto inside_foo;
i++;
}
getchar();
return();
}
void foo()
{
inside_foo:
printf(“PP”);
}
24. Explain how multi-way selection “switch…case” statement implemented in c (Nov/Dec 2022)
25. Define Array and explain how it can be declared, initialized and accessed by specifying the
corresponding syntax. (Nov/Dec 2022)
26. Define Loop. Write the syntax of any two loop statements in C. (Nov/Dec 2022)
8
PART-C
1. Write a program for addition and multiplication of two matrices. (Jan 2016, Nov 2017)
2. Write a C program to find the Determinant of the resultant matrix. (Jan 2016)
3. Explain various String operations. Write a C Program to find length of a String without
using Library functions. (Nov/Dec 2014, May 2015)
4. Write a C program to find transpose of a matrix.
5. Write a C program to find sum of the elements in an array
6. Write a C program that implements binary search and linear search technique
7. Write a C program to count number of vowels, Consonants, Digits and spaces in a given
string.
(Nov 2017)
8. Write programs in ‘C’ to perform matrix addition and matrix multiplication. (Nov/Dec
2021)
9. Discuss pass by value and pass by reference techniques in C using suitable examples.
(Nov/Dec 2021)
10. Write a C program to exchange the values of two variables using functions. (May/June
2013)
11. Explain about the different parameter passing methods in functions with example
(Nov/Dec 2017)
12. Explain function with and without arguments with example for each. (Jan 2014)
13. Explain the pass by value and pass by reference with an example.
(May 2016) (April/May 2017) (Nov/Dec 2016) (April
2019)
14. Write a program to print Fibonacci series for a given number using recursion. (Jan 2016)
15. Write a c program using function to check if the given input number is palindrome or not.
(April/May 2015)
16. Write a C program to find the sum of the digits using recursive function. (April/May 2015)
17. What is recursion? Explain recursive function with suitable example. Write iterative and
recursive function to find power of a number. (Dec 2014)