0% found this document useful (0 votes)
0 views

Programming in C - CS3251 - Important Questions with Answer - Unit 2 - Arrays and Strings (1)

cs3251

Uploaded by

njkumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Programming in C - CS3251 - Important Questions with Answer - Unit 2 - Arrays and Strings (1)

cs3251

Uploaded by

njkumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

All 2nd Semester Subjects

Professional English - II - HS3252 Engineering Graphics - GE3251


Statistics and Numerical Methods - Physics for Electronics Engineering -
MA3251 PH3254
Physics for Electrical Engineering - Physics for Civil Engineering - PH3201
PH3202
Materials Science - PH3251 Basic Electrical and Electronics
Engineering - BE3251
Physics for Information Science - Basic Civil and Mechanical Engineering -
PH3256 BE3255
Basic Electrical and Instrumentation Electric Circuit Analysis (Circuit
Engineering - BE3254 Theory) - EE3251
Programming in C - CS3251 Circuit Analysis - EC3251
Data Structures Design - AD3251
www.BrainKart.com
4931_Grace College of Engineering, Thoothukudi

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

BE- Computer Science and Engineering

Anna University Regulation: 2021

CS3251 - PROGRAMMING IN C

I Year/II Semester

QUESTION BANK (2 Marks & 16 Marks)

UNIT -2 (ARRAYS and STRINGS)

Prepared By,

Mrs. K.M.ANNAMMAL, AP/CSE

CS3251_PIC

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes Page 1 of 5
www.BrainKart.com
4931_Grace College of Engineering, Thoothukudi

TWO MARKS
1.Define scanf() function:
Scan f () function is used to read the value from the input device.

2.Define printf () function:


Print f ()function is used to display data on the monitor.

3.Define decision making statement:


These statements are used to execute particular set of instruction for based on cert ain
condition.
Ex:if, if else, nested if, if else if ladder, switch.

4.Define looping statement :


Looping statement are used to execute a group of instruction repeatedly at till some
condition is satisfied.
Example: while, do while, for loop.

5.Define unconditional statement:


This condition is used to transfer the control to other statement without checking any
condition.
Example : goto, break.

6.Define simple if statement:


It is used to execute some statements for a particular condition.

7.Define switch statement :


Switch statement is the simple form of if….else….. If ladder construct. Switch statement
is a multi branch decision statement.

8.Define for statement :


The for loop is entry controlled loop that provides a more concise loop control structure.

9.Define goto statement:


Goto statement can transfer the control to any place in a program. It is useful to provide
branching within a loop.

10.Define break statement:


Break statement exit from the loop can be accomplished by using the break statement.

11.Define exit statement:


It is used to terminate the program it is same as break statement.

12.what is getchar() :
Getchar () function is used to read one character at a time from the standard input
device.

CS3251_PIC

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes Page 2 of 5
www.BrainKart.com
4931_Grace College of Engineering, Thoothukudi

13.Define putchar() :
Single character can be displayed using the function putchar(). The function putchar()
stands for “putchar”and uses an argument.

14. Define Array


Array is a collection of similar type of values
All values are stored in continuous memory locations
All values share a common name
Linear data structure. The elements are organized in a sequential order.

15. Name any two library functions for handling string


strlen() – finds the length of a string. It returns an integer value. It counts the no. of
characters except null character & returns the count
strlen(str)
strcpy() – copies the source string into destination string. So, the source string should
be enough to store the destination string.
strcpy(source,destination)

3. Declare a float array of size 5 and assign 5 values to it

Declaration : float price[5];


Initialization : float price[5]={200.50,150.25,25.5,55.75,40.00}; (or)
float price[]={1.2,3.4,6.5,7.8,9.8};

4. Give an example for initialization of string array

String is a character array.


Collection of one or more characters- enclosed with in double quotes
Declaration : char name[10];
Initialization : char name[10]=‖India‖;
car name[10]={‗I‘,‘n‘,‘d‘,‘i‘,‘a‘};
The char array is terminated by ‗\0‘

5. How a character array is is declared

Declaration : char name[n];


This array can store n-1 characters.
Initialization : char name[10]=‖India‖;
car name[10]={‗I‘,‘n‘,‘d‘,‘i‘,‘a‘};
The char array is terminated by ‗\0‘

6. Write example code to declare two dimensional array

Two dimensional array is an array with two subscript values. First subscript specifies the
row & second subscript specifies the column. Used to process matrix operations.
Declaration : datatype array_name [r][c];

CS3251_PIC

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes Page 3 of 5
www.BrainKart.com
4931_Grace College of Engineering, Thoothukudi

int matrixA[10][10];
This matrixA can store 100 elements in a row major order.

7. What is mean & median of a list of elements?

Mean : Average of the N elements can be computed by


sum of N elements/N
Ex: 2,1,3,4,5
Mean = (2+1+3+4+5)/5 = 3
Median : Middle element of a list. To find the median, the list must be sorted first.
If N is odd then Median= (N+1)/2
Ex: 1,2,3,4,5
Median= 6/2 . The element at 3rd position is the median
If N is even then then Median is the average of
Median= (a[(N+1)/2]+a[(N-1)/2])/2
Ex: 1,2,3,4,5,6
Median=(a[3]+a[2])/2
=4+3/2
=3.5

8. Define Searching

Searching is a process of finding the position of a given element in a list. The searching
is successful if the element is found. There are two types of searching.
Linear Search
Binary Search

9. Define Sorting

Sorting is a process of arranging the elements either in ascending order or descending


order.

10. Sort the following elements using selection sort method. 23,55,16,78,2

Step1:Find smallest element in the list & exchange the element with first element of the
list
2,55,16,78,23
Step2: Find second smallest value & exchange it with the second element of the list
2,16,55,78,23
Step 3: Continue the process until all the elements are arranged in the order
2,16,23,78,55
Step 4: 2,16,23,55,78

CS3251_PIC

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes Page 4 of 5
www.BrainKart.com
4931_Grace College of Engineering, Thoothukudi

PART B
1.Explain Selection Sort in C

2. Explain Linear search in C

3. Explain binary search in C

4.Explain in detail about One - dimensional Array

5.Explain in detail about Two Dimensional Array

6.Explain in detail about String Operations

7.Write a c program for 3 X 3 Matrics Multiplication

CS3251_PIC

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes Page 5 of 5
All 2nd Semester Subjects
Professional English - II - HS3252 Engineering Graphics - GE3251
Statistics and Numerical Methods - Physics for Electronics Engineering -
MA3251 PH3254
Physics for Electrical Engineering - Physics for Civil Engineering - PH3201
PH3202
Materials Science - PH3251 Basic Electrical and Electronics
Engineering - BE3251
Physics for Information Science - Basic Civil and Mechanical Engineering -
PH3256 BE3255
Basic Electrical and Instrumentation Electric Circuit Analysis (Circuit
Engineering - BE3254 Theory) - EE3251
Programming in C - CS3251 Circuit Analysis - EC3251
Data Structures Design - AD3251

You might also like