Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

c programming (1)

C programming

Uploaded by

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

c programming (1)

C programming

Uploaded by

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

C – PROGRAMMING

1st semester B.C.A


[ Rani Channamma university Belagavi ]

IMPORATANT QUESTION WITH ANSWERS


[2019, 2018, 2017]

SECTION – A
Answer the following questions [10 X 2 =20 ]
1] what is computer ? [2019 ,2018]
-> A computer is a programmable electronic device that accepts raw data as
input and processes it with a set of instructions (a program) to produce the result as
output.
It renders output just after performing mathematical and logical operations
and can save the output for future use.
It can process numerical as well as non-numerical calculations. The term
"computer" is derived from the Latin word "computer" which means to calculate.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

2] what is variable ? [2019 ,2018, 2017]


-> A variable is a name of the memory location. It is used to store data. Its value
can be changed, and it can be reused many times.
It is a way to represent memory location through symbol so that it can be
easily identified.
The syntax to declare a variable:
type variable_list

3] name any four input device ? [2019, 2018]


-> Some of the popular input devices are:
Keyboard.
Mouse.
Scanner.
Joystick.
Light Pen.
Digitizer.
Microphone.
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

4] what is keyword ? Give an example [2019, 2018]


-> A keyword is a reserved word. You cannot use it as a variable name,
constant name, etc. There are only 32 reserved words (keywords) in the C language
examples : auto, break ,case, char, const, continue, default do, double, else, enum,
extern, float, for, go to ,if.

5] write syntax for , do-while [2019, 2018]


-> The syntax of the for loop is:
for (initialization Statement; test Expression; update Statement)
{
// statements inside the body of loop
}
The syntax of a do...while loop :
do
{
statement(s);
} while( condition ); Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]
6] what are c tokens ? [2019, 2018]

-> Tokens in C is the most important element to be used in creating a program in


C. We can define the token as the smallest individual element in C.
For example we cannot create a sentence without using words; similarly,
we cannot create a program in C without using tokens in C.

7] write a syntax for instead if statements ? [2019]


-> The syntax of the if statement
if(expression){
//code to be executed
}

8] what is an array ? [2019, 2018, 2017]


-> An array is defined as the collection of similar type of data items stored at
contiguous memory locations. Arrays are the derived data type in C programming
language which can store the primitive type of data such as int, char, double, float, etc
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

9] which are the basic data types in c ? [2019, 2018]

-> A data type specifies the type of data that a variable can store such as
integer, floating, character, etc.
Types Data Types

Basic Data Type int, char, float,


double
Derived Data array, pointer,
Type structure, union

Enumeration enum
Data Type
Void Data Type void

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

10] define recursion ? [2019, 2017]

-> Recursion is the process which comes into existence when a function calls
a copy of itself to work on a smaller problem. Any function which calls itself is called
recursive function, and such function calls are called recursive calls. Recursion
involves several numbers of recursive calls.

11] how do initialize array ? [2019]

-> The simplest way to initialize an array is by using the index of each
element. We can initialize each element of the array by using the index.
Consider the following example.
marks[0]=80;//initialization of array
marks[1]=60;
marks[2]=70;
marks[3]=85;
marks[4]=75; Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

12] what is for loop in c ? [2019]


-> The for loop in C language is used to iterate the statements or a part of the
program several times. It is frequently used to traverse the data structures like the
array and linked list.

13] expand DVD and ,CD - RW ? [2018 ]


-> DVD ( Digital Versatile Disk)
CD-RW (Compact Disc-Re Writable)

14] define flow chart ? [2019, 2018 ,2017,2015]


-> The Flowchart is the most widely used graphical representation of an
algorithm and procedural design workflows. It uses various symbols to show the
operations and decisions to be followed in a program. It flows in sequential order.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

15] write a algorithm to computer area of circle ? [2018 ]


-> step 1: start ;
step 2 :float radius, area;
step 3 : print the radius of Circle
step4 : scan the ("%d", &radius);
step 5 :area = 3.14 * radius * radius;
step 6: print the Area of Circle : %f", area ;
step 7 :return (0);
step 8 : stop ;

16] what is unary operators ? Give example [2018, 2017 ]


-> Unary Operator in C is used to apply on single variable or operand.
Unary minus, pre increment and decrement, post increment and decrement,
negation, address and size of() operators are unary operators in C.
1. Unary minus(-) 4 . Decrement(–)
2. Unary plus(+) 5. Logical Negation(!)
3. Increment(++) 6. Address Operator(&) Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]
17] what is syntax for Nested if statement [2018 ]

-> if (condition1)
{
// Executes when condition1 is true
if (condition2)
{
// Executes when condition2 is true
}
}

18] what is function [2018 ]

-> we can divide a large program into the basic building blocks known as
function. The function contains the set of programming statements enclosed by
{}. A function can be called multiple times to provide reusability and modularity
to the C program. In other words, we can say that the collection of functions
creates a program. Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

19] what is string ? Give example [2018 ]

-> The string can be defined as the one-dimensional array of characters


terminated by a null ('\0'). The character array or the string is used to manipulate
text such as word or sentences.
Example :By char array
By string literal

20] what is c programming [2021, 2019, 2018, 2017, 2016 ]

-> The C Language is developed by Dennis Ritchie for creating system


applications that directly interact with the hardware devices such as drivers, kernels,
etc. C programming is considered as the base for other programming languages,
that is why it is known as mother language.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

21] what is an Algorithm ? [2021, 2019, 2017, 2016 , 2014]


-> Algorithm is a step-by-step procedure, which defines a set of instructions
to be executed in a certain order to get the desired output. Algorithms are generally
created independent of underlying languages

22] what is an global variable ?[, 2017, 2015 , 2014]


-> The variables that are declared outside the given function are known as
global variables. These do not stay limited to a specific function- which means that
one can use any given function to not only access but also modify the global
variables.

23] define the term structure [, 2017, 2018 , 2019]


-> A structure is a key word that create user defined data type in C/C++. A
structure creates a data type that can be used to group items of possibly different
types into a single type.
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

SECTION – B
Answer the following questions [4 X 5 =20 ]

1 ] explain the block diagram of computer system [ 2019 ]

There are 5 main computer components


that are given below:

 Input Devices
CPU
Output Devices
Primary Memory
Secondary Memory

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

1) Inputting: It is the process of entering raw data, instructions and information into
the computer. It is performed with the help of input devices.

2) Storing: The computer has primary memory and secondary storage to store data
and instructions. It stores the data before sending it to CPU for processing and
also stores the processed data before displaying it as output.

3) Processing: It is the process of converting the raw data into useful information. This
process is performed by the CPU of the computer. It takes the raw data from
storage, processes it and then sends back the processed data to storage.

4) Outputting: It is the process of presenting the processed data through output


devices like monitor, printer and speakers.

5) Controlling: This operation is performed by the control unit that is part of CPU.
The control unit ensures that all basic operations are executed in a right manner
and sequence. Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

2] write a note in CD - ROM [ 2019 ]

 Compact Disc-Read Only Memory A type of CD disc that can only be read, but not
recorded.
 Used to store programs and data files, a CD-ROM holds 650MB or 700MB of data
 An audio CD player cannot read CD-ROMs, but CD-ROM drives can play audio discs.
In practice, the term "CD" refers to all CD formats. The phrase "insert the installation
CD" really means "insert the installation CD-ROM.“
 CD-ROM is an optical disc containing audio or software data whose memory is read-
only A CD-ROM Drive or optical drive is the device used to read them.
 CD-ROM drives have speeds ranging from 1x to 72x, meaning it reads the CD roughly
72 times faster than the 1x version.
As you would imagine, these drives are capable of playing audio CDs and reading data
CDs, including CD-Rand CD-RWdiscs.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

3] explain syntax of switch statements with example [ 2019 ]

-> The switch statement in C is an alternate to if-else-if ladder statement which


allows us to execute multiple operations for the different possible values of a single
variable called switch variable. Here, We can define various statements in
the multiple cases for the different values of a single variable.
The syntax of switch statement in c language
switch(expression){
case value1:
//code to be executed;
break; //optional
case value2:
//code to be executed;
break; //optional
......
default:
code to be executed if all cases are not matched; } Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

4] write a program to swap two numbers [ 2019 ]

#include <stdio.h>
int main()
{
int x, y, t;// x and y are the swapping variables and t is another variable
printf("Enter the value of X and Y\n");
scanf("%d%d", &x, &y);
printf("before swapping numbers: %d %d\n",x,y);
/*swapping*/ Output:
t = x;
x = y; Enter the value of X and Y
y = t; 29 39
printf("After swapping: %d %d",x,y); before swapping numbers: 29 39
return 0; After swapping: 39 29
}
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

5] explain all the symbols used in flow chart [ 2022,2019,2018, 2017,2015 ]

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

6] explain the characteristics of computer [ 2018 ]

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

 Speed :
A computer works with much higher speed and accuracy compared
to humans while performing mathematical calculations.

 Accuracy
Computers perform calculations with 100% accuracy. Errors may
occur due to data inconsistency or inaccuracy.

 Diligence
A computer can perform millions of tasks or calculations with the
same consistency and accuracy. It doesn’t feel any fatigue or lack of
concentration.

 Versatility
Versatility refers to the capability of a computer to perform different kinds of
works with same accuracy and efficiency.
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

Reliability
A computer is reliable as it gives consistent result for similar set of data i.e.,
if we give same set of input any number of times, we will get the same result.

 Memory
A computer has built-in memory called primary memory where it stores
data. Secondary storage are removable devices such as CDs, pen drives, etc., which
are also used to store data.

7] write the characteristics of algorithm [ 2018 ]

 Unambiguous − Algorithm should be clear and unambiguous. Each of its steps


(or phases), and their inputs/outputs should be clear and must lead to only one
meaning.
 Input − An algorithm should have 0 or more well-defined inputs.
 Output − An algorithm should have 1 or more well-defined outputs, and should
match the desired output. Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]
 Finiteness − Algorithms must terminate after a finite number of steps.
 Feasibility − Should be feasible with the available resources.
 Independent − An algorithm should have step-by-step directions, which should be
independent of any programming code.

8] write the basic structure of c program [ 2018 ]

-> Basically structure of the C program is divided into six different sections,

 Documentation section:
The Documentation section consists of a set of comment lines.

 Link section:
The link section provides instruction to the compiler to link the header files or
functions from the system library.

Definition section:
The definition section defines all symbolic constants such by using theBca Expert
#define
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]
 Global declaration section:
There are some variables that are used in more than one function,
such variables are called global variables.
In C there are two types of variable declaration,
Local variable declaration: Variables that are declared inside the main function.
Global variable declaration: Variables that are declared outside the main
function.

 Main function section:


Every C-program should have one main() function.
This section contains two parts:
Declaration part
Executable part

 Sub-program section:
If the program is a multi-function program, then the subprogram
section contains all user-defined functions that are called in the main() function.
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]
8] describe the basic steps involve in problem solving [ 2017 ]

-> Step 1: Understanding the Problem:


Here we try to understand the problem to be solved in totally. Before with the
next stage or step, we should be absolutely sure about the objectives of the given
problem.

Step 2: Analyzing the Problem:


After understanding thoroughly the problem to be solved, we look at
different ways of solving the problem and evaluate each of these methods.
The idea here is to search for an appropriate solution to the problem under
consideration. The end result of this stage is a broad overview of the sequence of
operations that are to be carried out to solve the given problem.

Step 3: Developing the solution:


Here, the overview of the sequence of operations that was the result of the
analysis stage is expanded to form a detailed step by step solution to the problem
Bca Expert
under consideration.
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

Step 4: Coding and Implementation:


The last stage of problem-solving is the conversion of the detailed sequence
of operations into a language that the computer can understand. Here, each step is
converted to its equivalent instruction or instructions in the computer language that
has been chosen for the implantation.
The vehicle for the computer solution to a problem is a set of explicit and
unambiguous instructions expressed in a programming language. This set of
instruction is called a program with problem solving through programming in C.

9] describe briefly one dimensional arrays declaration with an example


[ 2017 ]
-> One dimensional array is an array that has only one subscript specification
that is needed to specify a particular element of an array. A one-dimensional array is
a structured collection of components (often called array elements) that can be
accessed individually by specifying the position of a component with a single index
value.
Syntax: data-type arr_name[array_size]; Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

Rules for Declaring One Dimensional Array

 An array variable must be declared before being used in a program.


 The declaration must have a data type(int, float, char, double, etc.), variable
name, and subscript.
 The subscript represents the size of the array. If the size is declared as 10,
programmers can store 10 elements.
 An array index always starts from 0.
 For example, if an array variable is declared as s[10], then it ranges from 0 to
9.
 Each array element stored in a separate memory location.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

10] explain any 5 string handling function [ 2017, 2018 ]

unction Syntax (or) Example Description


strcpy() strcpy(string1, string2) Copies string2 value into
string1
strncpy() strncpy(string1, string2, 5) Copies first 5 characters
string2 into string1
strlen() strlen(string1) returns total number of
characters in string1
strcat() strcat(string1,string2) Appends string2 to string1
strncat() strncpy(string1, string2, 4) Appends first 4 characters of
string2 to string1
strcmp() strcmp(string1, string2) Returns 0 if string1 and
string2 are the same;
less than 0 if string1<string2;
greater than 0 if
string1>string2
strncmp() strncmp(string1, string2, 4) Compares first 4 characters
of both string1 and string2
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

11] differentiated between array and string [ 2017 ]

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

SECTION – C
Answer the following questions [4 X 10 =40 ]
1] mention the features of C language and explain the basic structure
of a C program [ 2019, 2018 ]

->C is the widely used language. It provides many features that are given below.
Simple
 Machine Independent or Portable
 Mid-level programming language
 structured programming language
 Rich Library
 Memory Management
 Fast Speed
 Pointers
 Recursion
Extensible
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

basic structure of a C program

Documentation Section
The documentation section is the part of the
program where the programmer gives the details
associated with the program.

Link Section
This part of the code is used to declare all the
header files that will be used in the program. This leads
to the compiler being told to link the header files to the
system libraries.

Definition Section
In this section, we define different constants. The
keyword define is used in this part.
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

Global Declaration Section


This part of the code is the part where the global variables are
declared. All the global variable used are declared in this part. The
user-defined functions are also declared in this part of the code.

Main Function Section


Every C-programs needs to have the main function. Each main
function contains 2 parts. A declaration part and an Execution part.
The declaration part is the part where all the variables are declared

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

2] explain in detail types of operators with example in c [ 2019,2018 ]

-> An operator is simply a symbol that is used to perform operations. There can
be many types of operations like arithmetic, logical, bitwise, etc.

 Arithmetic Operators
 Increment Operator in C
 Decrement Operator in C
 Assignment Operator
 Relational Operators in C
 Logical Operators in C
 Conditional Operator in C
 Bitwise Operator in C
. Misc operators in C
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

1. Arithmetic Operators in C
The purpose of this operator is to perform mathematical operations like
addition, subtraction, division, multiplication etc.

2. Increment Operator in C
Mainly used for incrementing the value of an integer. It is represented by
the ‘++’ operator. ++x will increase the value of the variable x instantly. But if it is
placed after the variable then it gets increased before the execution of the next
statement.

3. Decrement Operator in C
Mainly used for decrementing the value of an integer. It is represented by
the ‘–’ operator. –x will decrease the value of the variable x instantly. But if it is
placed after the variable then it gets decreased before the execution of the next
statement.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

4. Assignment Operators in C
The purpose of this operator is to assign value to a variable. The most
used assignment operator is “=”.

5. Relational Operators in C
Mainly used for checking relationships between operands. With the help
of this operator, you can check whether one operand is equal to or greater than
the other operand or not.

6. Logical Operators in C
In the C programming language, Logical operators are mostly used for
decision making. A logical operator returns either 0 or 1 whether the condition is
true or false.

7. Conditional Operator in C
Also known as Ternary operator. The main purpose of conditional operators is in
decision making statements. It is similar to an if-else statement. Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

8. Bitwise Operator in C
C also provides special operators for bit operation between two variables.

9. Misc operators in C
It includes operators like sizeof(), reference operator(&), pointer
operator(*), condition operator(?).

3] explain various branching statement giving examples for each


[ 2019 ]
-> Branching statements are the statements used to jump the flow of execution
from one part of a program to another. The branching statements are mostly used
inside the control statements.
The common branching statements used within other control structures
include: break, continue, return, and goto. The goto is rarely used in modular
structured programming. Additionally, we will add to our list of branching items a pre-
defined function commonly used in programming languages of: exit.
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

Examples
break
The break is used in one of two ways; with a switch to make it act like a
case structure or as part of a looping process to break out of the loop. The
following gives the appearance that the loop will execute 8 times, but the break
statement causes it to stop during the fifth iteration

counter = 0;
While counter < 8
Output counter
If counter == 4
break counter += 1

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

continue
The following gives the appearance that the loop will print to the
monitor 8 times, but the continue statement causes it not to print number 4.

For counter = 0, counter < 8,counter += 1


If counter == 4
continue
Output counter

return
The return statement exits a function and returns to the statement
where the function was called.

Function DoSometing
Statements
Return <optional return value>
Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

Goto
The goto structure is typically not accepted in good structured programming.
However, some programming languages allow you to create a label with an identifier
name followed by a colon. You use the command word goto followed by the label.

some lines of code;


goto label; // jumps to the label
some lines of code;
some lines of code;
some lines of code;
label: some statement; // Declared label
some lines of code;

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

4] write a c program to perform basic arithmetic operation [ 2019 ]


#include<stdio.h>
int main()
{
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
int a, b, add, subtract, multiply;
float divide;
printf("Enter two integers: \n");
scanf("%d%d", &a, &b);
add = a+b;
subtract = a-b;
multiply = a*b;
divide = a/b;
printf("\addition of the numbers = %d\n", add);
printf("Subtraction of 2nd number from 1st = %d\n", subtract);
printf("Multiplication of the numbers = %d\n", multiply);
printf("Dividing 1st number from 2nd = %f\n", divide);
printf("\n\n\t\t\tCoding is Fun !\n\n\n");
return 0; Bca Expert
}
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

5] write a c program to check whether given number is even or not


[ 2019 ]
#include <stdio.h>
void main()
{
int num1, rem1;

printf("Input an integer : ");


scanf("%d", &num1);
rem1 = num1 % 2;
if (rem1 == 0)
printf("%d is an even integer\n", num1);
else
printf("%d is an odd integer\n", num1);
}

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]
6] explain with syntax switch case , while loop , and nested for loop
statements
[ 2021,2019, 2018, 2017,2016,2015,2014 ]

-> Switch Case Statement


Switch case is a control statement which is used to implement decision
making logic. Switch Case Statement Syntax
switch(expression){
case expression:
// statements
case expression:
// statements
----------------
case expression n:
// statements
default:
// statements
Bca Expert
}
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

while loop in C
While loop is also known as a pre-tested loop. In general, a while loop
allows a part of the code to be executed multiple times depending upon a given
Boolean condition

The syntax of while loop in c language is given below:

while(condition)
{
//code to be executed
}

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

Nested Loops in C

Nesting of loops is the feature in C that allows the looping of statements


inside another loop. Let's observe an example of nesting loops in C.

Syntax of Nested loop


Outer_loop
{
Inner_loop
{
// inner loop statements.
}
// outer loop statements.
}

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

7] explain all
a) binary operators
b) relational operators
c) two dimensional array
d) call – by- references
e) go to statements
[ 2021,2019, 2018, 2017,2016,2015,2014 ]

a) Binary Operators C Programming


Binary operators act upon a two operands to produce a new value. Such,
operators can be classified into different categories.

Syntax for binary operator is:

operand1 operator operand2

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

An operator is simply a symbol that is used to perform operations.


There can be many types of operations like arithmetic, logical, bitwise, etc.

 Arithmetic Operators
 Increment Operator in C
 Decrement Operator in C
 Assignment Operator
 Relational Operators in C
 Logical Operators in C
 Conditional Operator in C
 Bitwise Operator in C
. Misc operators in C

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

b) relational operators
These operators are very helpful for making decisions. Depending upon the
condition, it returns either 0 or 1. When the condition with these operators is true, 1
is returned. If the condition is false, it returns 0.

Different relational operators available in C programming language

Symbol Meaning

< Less Than


> Greater Than
<= Less Than or Equal To
>= Greater Than or Equal To
== Equal To
!= Not Equal To

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

c) two dimensional array


The two-dimensional array can be defined as an array of arrays. The 2D
array is organized as matrices which can be represented as the collection of rows
and columns. However, 2D arrays are created to implement a relational database
lookalike data structure. It provides ease of holding the bulk of data at once which
can be passed to any number of functions wherever required.

Declaration of two dimensional Array in C

The syntax to declare the 2D array is given below.


data_type array_name[rows][columns];

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

d) call – by- references


The call by reference method of passing arguments to a function copies the
address of an argument into the formal parameter. Inside the function, the address is
used to access the actual argument used in the call. It means the changes made to
the parameter affect the passed argument.
To pass a value by reference, argument pointers are passed to the functions
just like any other value. So accordingly you need to declare the function parameters
as pointer types as in the following function swap(), which exchanges the values of
the two integer variables pointed to, by their arguments.
e) go to statements
The goto statement is a jump statement which is sometimes also
referred to as unconditional jump statement. The goto statement can be used to
jump from anywhere to anywhere within a function.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

8] write the different between algorithm and flow chart


[ 2019,2018,2017]

S.NO Algorithm Flowchart

Flowchart is a diagram created by


Algorithm is step by step procedure
1. different shapes to show the flow of
to solve the problem.
data.

2. Algorithm is complex to understand. Flowchart is easy to understand.

3. In algorithm plain text are used. In flowchart, symbols/shapes are used.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

4. Algorithm is easy to debug. Flowchart it is hard to debug.

Flowchart is simple to
5. Algorithm is difficult to construct.
construct.

Algorithm does not follow any Flowchart follows rules to be


6.
rules. constructed.

Algorithm is the pseudo code for Flowchart is just graphical


7.
the program. representation of that logic.

Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

9] discuss the different types of looping statements in c- programming


[ 2021,2019,2018,2017,2016,2015,2014]

-> The looping can be defined as repeating the same process multiple times
until a specific condition satisfies. There are three types of loops used in the C
language.
Advantage of loops in C
1) It provides code reusability.
2) Using loops, we do not need to write the same code again and again.
3) Using loops, we can traverse over the elements of data structures (array
or linked lists).

Types of C Loops
There are three types of loops in C language that is given below:
1) do while
2) while
Bca Expert
3) for
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

do-while loop in C
The do-while loop continues until a given condition satisfies. It is also called
post tested loop. It is used when it is necessary to execute the loop at least once
(mostly menu driven programs).
The syntax of do-while loop in c language is given below:
do{
//code to be executed
}while(condition);

while loop in C
The while loop in c is to be used in the scenario where we don't know the
number of iterations in advance. The block of statements is executed in the while
loop until the condition specified in the while loop is satisfied. It is also called a pre-
tested loop.
syntax : while(condition){
//code to be executed
} Bca Expert
C – PROGRAMMING
1st semester B.C.A
[ Rani Channamma university Belagavi ]

for loop in C
The for loop is used in the case where we need to execute some part of
the code until the given condition is satisfied. The for loop is also called as a per-
tested loop. It is better to use for loop if the number of iteration is known in
advance.
The syntax of for loop in c language is given below:
for(initialization;condition;incr/decr){
//code to be executed
}

Thank you for watching


- Bca Expert

You might also like