SlideShare a Scribd company logo
1 of 19
Download to read offline
Computer Science Class XII
Multiple Choice Questions
1.  an escape sequence can be used to beep from the speaker in C.
2. n escape sequence is used for display output in a newline.
3. <,>, <=,>=,!=, == are Relational operator.
4. A global variable is defined as a declaration outside of any function.
5. A memory location with some data that can be changed is called variable.
6. A pictorial representation of a problem is called a flowchart.
7. A single statement for loop is terminated with a semicolon.
8. A syntax error occurs when the program violates any rules of C programming.
9. A warning appears when you delete a field
10. a++ is equivalent to a=a+1
11. Assuming x does not equal 0, the statement while (x==0) print f (“x==0) while (x==0) causes a logical error
12. C is a relatively simple language that was developed to help students learn to program.
13. Database management systems are intended to eliminate data redundancy.
14. During the development of a program drawing a flowchart is a means to plan the solution.
15. The floating-point variable is used instead of integers to permit the use of decimal points in numbers.
16. Function prototyping for built-in functions is specified in the header file.
17. How many control structures are used in C? 3
18. In preparing a program desk-checking and translating are examples of coding.
19. In preparing a program, one should first define the problem.
20. In the switch case statement, a case block ends with a break;
21. Machine language and assembly language are an example of a low-level language.
22. Precedence determined which operator is used first.
23. scanf () is used to take input in C.
24. The C was developed in 1972.
25. The collection of the same datatypes is called an array.
26. The definition of the main function starts with a reserved word void in C Program.
27. The delay () function is declared in which header file? dos.h
28. The do-while loop is Post-test type of loop.
29. The equal to sign (=) is treated as an operator in C language called the assignment operator.
30. The function fopen () can specify which of the following? The file may be opened for appending
31. The statement for (x=0, x<1, x++) printf (“x=0”) will output once.
32. The value cannot change during the execution of the program is called constant.
33. The while loop is also known as Pre-test loop.
34. These statements if (x=0) printf (“x=0”); is correct syntax, but x=0 will never print
35. What do you call the step-by-step solution to a programming problem? Algorithm
36. When reading one character at a time which of the following functions is appropriate? fgetc()
37. Which is the correct way to define a pointer? int *ptr;
38. Which statement is used to display output n screen in C Program: printf()
39. You can easily create a relationship between tables by using the relationships window.
40. You test a program to find which of the following? Syntax error
Introduction to C
Q. Define C as an object-oriented language.
Ans. C is not an object-oriented language. C is a general-purpose, imperative language, supporting structured
programming. Because C isn't object-oriented therefore C++ came into existence to have OOPs feature and OOP
is a programming language model organized around objects. A language to have an OOPs feature needs to
implement certain principles of OOPs. Few of them are Inheritance, Polymorphism, Abstraction, Encapsulation.
Q. Define the origin of C-Language.
Ans. The history of C programming language is quite interesting. C was originally designed for and implemented
on the UNIX operating system on the DEC PDP-ll, by Dennis Ritchie. C is the result of a development process that
started with an older language called BCPL. BCPL was developed by Martin Richards, and it influenced a language
called B, which was invented by Ken Thompson. B led to the development of C in the 1970s.
For many years, the de facto standard for C was the version supplied with the UNIX operating system. In the
summer of 1983, a committee was established to create an ANSI (American National Standards Institute) standard
that would define the C language. The standardization process took six years (much longer than anyone reasonably
expected).
Use printf() function
Q. Write a program that print ½, ¾ 5/6, 7/8, 9/10, 11/12 using for a statement.
Ans. #include <stdio.h>
int main() {
int start=1, end=12;
for (int i = start; i <= end; ++i) {
printf("%d/%dt", i++, i);
}
return 0;
}
Q. Write a program that displays “Welcome to the computer lab. Board of intermediate and secondary
education, Hyderabad.” On-screen.
Ans. #include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Welcome to computer lab.n");
printf("Board of intermediate and secondary education, Hyderabad.");
return 0;
}
Q. Write a program, if you enter any alphabet character, the computer will display ASCII code.
Ans. #include <stdio.h>
int main()
{
char c;
printf("Enter the Alphabet ");
scanf("%c”, &c);
// %d displays the integer value of a character
// %c displays the actual character
printf("The ASCII value of %c is %d", c, c);
return 0;
}
Format Specifiers
Q. Define Format Specifiers in C.
Ans. In C programming we need lots of format specifier to work with various data types. Format specifiers define
the type of data to be printed on standard output. Whether to print formatted output or to take formatted input
we need format specifiers. Format specifiers are also called a format string.
Here is a complete list of all format specifiers used in C programming language.
Format specifier Description Supported data types
%c Character
Char
unsigned char
%d Signed Integer
Short
unsigned short
Int
Long
%e or %E Scientific notation of float values
Float
Double
%f Floating point Float
%g or %G Similar to %e or %E
Float
Double
%hi Signed Integer (Short) Short
%hu Unsigned Integer (Short) unsigned short
%i Signed Integer
Short
unsigned short
Int
Long
Variables and Constants
Q. Write a short note on Variables and Constants.
Ans. Variables: If you declare a variable in C (later on we talk about how to do this), you ask the operating system
for a piece of memory. This piece of memory you give a name and you can store something in that piece of memory
(for later use). There are two basic kinds of variables in C which are numeric and character.
Numeric variables: Numeric variables can either be of the type integer (int) or the type real (float). Integer (int)
values are whole numbers (like 10 or -10). Real (float) values can have a decimal point in them. (Like 1.23 or -
20.123).
Character variables: Character variables are letters of the alphabet, ASCII characters or numbers 0-9. If you declare
a character variable you must always put the character between single quotes (like so‘A’). So, remember a number
without single quotes is not the same as a character with single quotes.
Constants: The difference between variables and constants is that variables can change their value at any time but
constants can never change their value. (The constants value is locked for the duration of the program). Constants
can be very useful, Pi, for instance, is a good example to declare as a constant.
Q. What is variable and how many types of variable in C language.
Ans. A variable is the 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 a symbol so that it can be easily identified.
Types of Variables in C
There are many types of variables in c:
• local variable
• global variable
• static variable
• automatic variable
• external variable
Local Variable: A variable that is declared inside the function or block is called a local variable. It must be declared
at the start of the block.
void function1() {
int x=10;//local variable
}
You must have to initialize the local variable before it is used.
Global Variable: A variable that is declared outside the function or block is called a global variable. Any function
can change the value of the global variable. It is available to all the functions. It must be declared at the start of
the block.
int value=20;//global variable
void function1() {
int x=10;//local variable
}
Static Variable: A variable that is declared with the static keyword is called static variable. It retains its value
between multiple function calls.
void function1() {
int x=10;//local variable
static int y=10;//static variable
x=x+1;
y=y+1;
printf("%d, %d”, x, y);
}
If you call this function many times, the local variable will print the same value for each function call, e.g., 11,11,11
and so on. But the static variable will print the incremented value in each function call, e.g., 11, 12, 13 and so on.
Automatic Variable: All variables in C that are declared inside the block, are automatic variables by default. We
can explicitly declare an automatic variable using the auto keyword.
void main() {
int x=10;//local variable (also automatic)
auto int y=20;//automatic variable
}
External Variable: We can share a variable in multiple C source files by using an external variable. To declare an
external variable, you need to use the extern keyword.
myfile.h
extern int x=10;//external variable (also global)
Input/output
Q. What is the difference between scanf () and gets () function?
SCANF() GETS()
when scanf() is used to read string input it stops reading
when it encounters whitespace, newline or End of File
when gets() is used to read input it stops reading
input when it encounters newline or End of File.
It is used to read input of any datatype
It does not stop reading the input on encountering
whitespace as it considers whitespace as a string.
It is used only for string input.
Escape Sequence
Q. Write down the most common escape sequence.
Escape Sequences Character
' Single quotation mark
" Double quotation mark
? Question mark
 Backslash
0 Null Character
b Backspace
f Form feed
n Newline
r Return
t Horizontal tab
v Vertical tab
Operators
Q. Write a short note on Assignment operator.
Ans. Assignment operators are used to assigning value to a variable. The left side operand of the assignment
operator is a variable and right-side operand of the assignment operator is a value. The value on the right side
must be of the same data-type of the variable on the left side otherwise the compiler will raise an error.
Different types of assignment operators are shown below:
“=”: This is the simplest assignment operator. This operator is used to assign the value on the right to the variable
on the left.
For example:
a = 10;
b = 20;
ch = 'y';
“+=”: This operator is a combination of ‘+’ and ‘=’ operators. This operator first adds the current value of the
variable on left to the value on the right and then assigns the result to the variable on the left.
Example:
(a += b) can be written as (a = a + b)
If initially value stored in a is 5. Then (a += 6) = 11.
“-=” This operator is a combination of ‘-‘ and ‘=’ operators. This operator first subtracts the current value of the
variable on left from the value on the right and then assigns the result to the variable on the left.
Example:
(a -= b) can be written as (a = a - b)
If initially value stored in a is 8. Then (a -= 6) = 2.
“*=” This operator is the combination of ‘*’ and ‘=’ operators. This operator first multiplies the current value of
the variable on left to the value on the right and then assigns the result to the variable on the left.
Example:
(a *= b) can be written as (a = a * b)
If initially value stored in a is 5. Then (a *= 6) = 30.
“/=” This operator is a combination of ‘/’ and ‘=’ operators. This operator first divides the current value of the
variable on left by the value on the right and then assigns the result to the variable on the left.
Example:
(a /= b) can be written as (a = a / b)
If initially value stored in a is 6. Then (a /= 2) = 3.
Comments
Q. What Is Comment in C Language?
Ans. A comment is an explanation or description of the source code of the program. It helps a developer explain
the logic of the code and improves program readability. At run-time, a comment is ignored by the compiler.
There are two types of comments in C:
• A comment that starts with a slash asterisk /* and finishes with an asterisk slash */ and you can place it anywhere
in your code, on the same line or several lines.
• Single-line Comments which uses a double slash // dedicated to commenting single lines
Loops
Q. What is the difference between while and do-while loop?
Ans. In while the given condition is checked at the start of the loop.
If the condition is false then the loop is not executed at all.
Only when the condition is true the loop block is executed.
In do-while first, the loop block is executed then the condition is checked at the end of 1st-time execution.
ex for a while:
int a=10;
while(a==10)
{
printf("Hellon");
a++;
}
In this 1st the condition is checked: is equal to 10? YES, so the printf statement is executed. Now a is incremented
to 11. Now again when it checks if a is equal to 10, it is false and hence the loop block (printf statement) is not
executed.
ex for do-while:
int a = 10;
do
{
printf("Quoran");
} while(a==0);
now observe the condition in the do-while: is a is equal to zero? the statement is false. But what happens in do-
while is that 1st the printf statement is executed and then after that, the condition is checked. Now when the
condition is checked it is false and now the loop is terminated.
If the given condition is false then in while loop it is terminated immediately, but in do while the statement is
executed then the loop is terminated.
The minimum number of times a while loop can run is ZERO times whereas a do-while loop runs for a minimum of
ONE time even if the condition is false.
For
Q. Define for loop with its syntax.
A for loop enables a particular set of conditions to be executed repeatedly until a condition is satisfied. Imagine a
situation where you would have to print numbers from 1 to 100. What would you do? Will you type in the printf
command a hundred times or try to copy/paste it? This simple task would take an eternity. Using a for loop you
can perform this action in three statements. This is the most basic example of the for a loop. It can also be used in
many advanced scenarios depending on the problem statement.
Syntax of a For Loop
for (initialization statement; test expression; update statement) {
// statements
}
The for loop starts with a fork statement followed by a set of parameters inside the parenthesis. The statement is
in lower case. Please note that this is case sensitive, which means the for command always has to be in lower case
in C programming language. The initialization statement describes the starting point of the loop, where the loop
variable is initialized with a starting value. A loop variable or counter is simply a variable that controls the flow of
the loop. The test expression is the condition until when the loop is repeated. The update statement is usually the
number by which the loop variable is incremented.
Q. Write a program that prints numbers from 1 to 10 their squares and cubes side by side.
Ans. #include <stdio.h>
int main() {
int start=1, end=10;
printf(“Numbert Squaret Cuben”);
for (int i = start; i <= end; ++i) {
printf("%dt%dt%dn", i, i*i, i*i*i);
}
return 0;
}
Q. Write a program of the table of 7 by using for statement and draw a flow chart also.
Ans. #include <stdio.h>
int main() {
int n=7, i;
printf("Table of 7n");
for (i = 1; i <= 10; ++i) {
printf("%d * %d = %d n", n, i, n * i);
}
return 0;
}
While
Q. Write a program of factorial of 4 by using while loop.
Ans. #include<stdio.h>
#include<conio.h>
void main()
{
int n=4;
int i, f;
f=i=1;
while(i<=n)
{
f*=i;
i++;
}
printf("The Factorial of %d is: %d”, n, f);
getch();
}
Do-While
Q. Write a program that prints even numbers from 2 to 20.
Ans. #include <stdio.h>
int main()
{
int i, num=20;
printf("Print all even number until %d n", num);
printf("Even number from 1 to %d aren”, num);
i=1;
do{ //loop for iterates from 1 to maximum
if(i%2==0)
{
printf("%dn”, i);
}
i++;
}while(i<=num);
return 0;
}
Q. Write a program of odd series 1 to 19 by using do-while statement.
Ans. #include <stdio.h>
int main()
{
int i, num=19;
printf("Print all odd number until %d n", num);
printf("Odd number from 1 to %d aren”, num);
i=1;
do { //loop for iterates from 1 to maximum
if(i%2==1)
{
printf("%dn”, i);
}i++;
}while(i<=num);
return 0;
}
Break and Continue Statements
Q. Differentiate between Break and Continue Statements.
Break continue
A break can appear in both switch and loop
(for, while, do) statements.
A continue can appear only in the loop (for, while, do)
statements.
A break causes the switch or loop
statements to terminate the moment it is
executed. Loop or switch ends abruptly
when the break is encountered.
A continue doesn't terminate the loop, it causes the loop to go to
the next iteration. All iterations of the loop are executed even
if continue is encountered. The continue statement is used to
skip statements in the loop that appear after the continue.
The break statement can be used in
both switch and loop statements.
The continue statement can appear only in loops. You will get an
error if this appears in a switch statement.
When a break statement is encountered, it
terminates the block and gets the control
out of the switch or loop.
When a continue statement is encountered, it gets the control to
the next iteration of the loop.
A break causes the innermost enclosing
loop or switch to be exited immediately.
A continue inside a loop nested within a switch causes the next
loop iteration.
Conditional Statements
If
Q. Describe the if statement with its syntax. Also, define why it is used.
Ans. The syntax of the if statement in C programming is:
if (test expression)
{
// statements to be executed if the test expression is true
}
Working of if statement:
• The if statement evaluates the test expression inside the parenthesis ().
• If the test expression is evaluated to true, the statements inside the body of if are executed.
• If the test expression is evaluated to false, the statements inside the body of if are not executed.
If-else
Q. Describe the if-else statement with its syntax. Also, define why it is used.
Ans. If-else statement works when there are true statements and false statements that have to be print on the
screen. If the condition is true the true statements print otherwise the false statements displays on the screen.
Syntax of the if-else statement:
If the condition returns true then the statements inside the body of “if” are executed and the statements inside
the body of “else” are skipped.
If the condition returns false then the statements inside the body of “if” are skipped and the statements in “else”
are executed.
if(condition) {
// Statements inside the body of if
}
else {
//Statements inside the body of else
}
The if/else statement executes a block of code if a specified condition is true. If the condition is false, another
block of code can be executed. The if/else statement is a part of JavaScript's "Conditional" Statements, which are
used to perform different actions based on different conditions.
Nested if-else
Q. Write a short note on Nested if statement.
Ans. When an if-else statement is present inside the body of another “if” or “else” then this is called nested if-else.
Syntax of Nested if else statement:
if(condition) {
//Nested if else inside the body of "if"
if(condition2) {
//Statements inside the body of nested "if"
}
else {
//Statements inside the body of nested "else"
}
}
else {
//Statements inside the body of "else"
}
Example of nested if. Else
#include <stdio.h>
int main()
{
int var1, var2;
printf("Input the value of var1:");
scanf("%d", &var1);
printf("Input the value of var2:");
scanf("%d”, &var2);
if (var1 != var2)
{
printf("var1 is not equal to var2n");
//Nested if else
if (var1 > var2)
{
printf("var1 is greater than var2n");
}
else
{
printf("var2 is greater than var1n");
}
}
else
{
printf("var1 is equal to var2n");
}
return 0;
}
Output:
Input the value of var1:12
Input the value of var2:21
var1 is not equal to var2
var2 is greater than var1
Logical operators
Q. Define Logical Operators.
Ans. An expression containing logical operator returns either 0 or 1 depending upon whether expression results
true or false. Logical operators are commonly used in decision making in C programming.
Operator Meaning Example
&&
Logical AND. True only if all operands are
true
If c = 5 and d = 2 then, expression ((c==5) && (d>5))
equals to 0.
||
Logical OR. True only if either one operand
is true
If c = 5 and d = 2 then, expression ((c==5) || (d>5))
equals to 1.
! Logical NOT. True only if the operand is 0 If c = 5 then, expression! (c==5) equals to 0.
Switch statement
Q. Write a short note on a Switch statement.
Ans. Switch case statements are a substitute for long if statements that compare a variable to several integral
values.
The switch statement is a multiway branch statement. It provides an easy way to dispatch execution to different
parts of code based on the value of the expression.
The switch is a control statement that allows a value to change control of execution.
Syntax:
switch (n)
{
case 1: // code to be executed if n = 1;
break;
case 2: // code to be executed if n = 2;
break;
default: // code to be executed if n doesn't match any cases
}
Important Points about Switch Case Statements:
The expression provided in the switch should result in a constant value otherwise it would not be valid.
Valid expressions for switch:
// Constant expressions allowed
switch(1+2+23)
switch(1*2+3%4)
// Variable expression are allowed provided
// they are assigned with fixed values
switch(a*b+c*d)
switch(a+b+c)
• Duplicate case values are not allowed.
• The default statement is optional. Even if the switch case statement does not have a default statement,
• it would run without any problem.
The break statement is used inside the switch to terminate a statement sequence. When a break statement is
reached, the switch terminates, and the flow of control jumps to the next line following the switch statement.
The break statement is optional. If omitted, execution will continue into the next case. The flow of control will fall
through to subsequent cases until a break is reached.
Nesting of switch statements is allowed, which means you can have switch statements inside another switch.
However nested switch statements should be avoided as it makes the program more complex and less readable.
Functions
Structure of function
Q. Explain Functions in C.
Ans. In c, we can divide a large program into the basic building blocks known as a 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.
The function is also known as procedure or subroutine in other programming languages.
Advantage of functions in C
There are the following advantages of C functions.
• By using functions, we can avoid rewriting the same logic/code again and again in a program.
• We can call C functions any number of times in a program and from any place in a program.
• We can track a large C program easily when it is divided into multiple functions.
• Reusability is the main achievement of C functions.
• However, Function calling is always overhead in a C program.
Function Aspects
There are three aspects of a C function.
• Function declaration A function must be declared globally in a c program to tell the compiler about the function
name, function parameters, and return type.
• Function call Function can be called from anywhere in the program. The parameter list must not differ in function
calling and a function declaration. We must pass the same number of functions as it is declared in the function
declaration.
• Function definition It contains the actual statements which are to be executed. It is the most important aspect to
which the control comes when the function is called. Here, we must notice that only one value can be returned from
the function.
SN C function aspects Syntax
1 Function declaration return_type function_name (argument list);
2 Function call function_name (argument_list)
3 Function definition return_type function_name (argument list) {function body;}
The syntax of creating function in c language is given below:
return_type function_name(data_type parameter...) {
//code to be executed
}
Types of Functions
There are two types of functions in C programming:
• Library Functions: are the functions which are declared in the C header files such as scanf(), printf(), gets(), puts(),
ceil(), floor() etc.
• User-defined functions: are the functions which are created by the C programmer, so that he/she can use it many
times. It reduces the complexity of a big program and optimizes the code.
Sending and returning values from a function, return statement
Q. Why functions are used in C-language? Also, describe the importance of the return statement.
Ans. A function is a group of statements that together perform a specific task. Every C program has at least one
function, which is main().
The function is used to divide a large code into the module, due to this we can easily debug and maintain the code.
For example, if we write a calculator program at that time, we can write every logic in a separate function (For
addition sum(), for subtraction sub()). Any function can be called many times.
Advantage of Function
• Code Re-usability
• Develop an application in module format.
• Easily to debug the program.
• Code optimization: No need to write a lot of code.
After performing certain operations that function results in an output which we need to store in a database for
later analysis. In the case where we don’t use the return statement, function after printing out the result, control
comes out of the function and all the data stored in the stack will be erased resulting in data effective usage. but
we didn’t store the value in any permanent data format. To store the value in any file for statistics, we use return
statement where we return value to the main function, which collects the value and stores in a permanent file.
Passing variables and constants as arguments
Q. How data is passed to a function in C?
Ans. There are three ways of passing data in function:
Pass by Value
• Ordinary data types (ints, floats, doubles, chars, etc) are passed by value in C/C++, which means that only the
numerical value is passed to the function, and used to initialize the values of the function’s formal parameters.
• Under the pass-by-value mechanism, the parameter variables within a function receive a copy of the variables (data)
passed to them.
• Any changes made to the variables within a function are local to that function only and do not affect the variables in
main (or whatever other function called the current function.) This is true whether the variables have the same name
in both functions or whether the names are different.
Passing Arrays and/or Array Elements
• When one element of an array is passed to a function, it is passed in the same manner as the type of data contained
in the array. (I.e., pass-by-value for basic types.)
• However, when the entire array is passed, it is effectively passed by reference. (Actually, by pointer/address, to be
explained completely in the section on pointer variables.)
Pass by Pointer / Address
• Pass by pointer/address is another type of data passing that will be covered later under the section on pointer
variables.
• Pass by pointer/address requires the use of the address operator (&) and the pointer dereference operator (*), to
be covered later.
Array
Definition, initializing strings
Q. Explain Array.
Ans. Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type.
An array is used to store a collection of data, but it is often more useful to think of an array as a collection of
variables of the same type.
Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array
variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables.
A specific element in an array is accessed by an index.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the
highest address to the last element.
Declaring Arrays: To declare an array in C, a programmer specifies the type of the elements and the number of
elements required by an array as follows −
type arrayName [ arraySize];
This is called a single-dimensional array. The array size must be an integer constant greater than zero and type can
be any valid C data type. For example, to declare a 10-element array called the balance of type double, use this
statement −
double balance[10];
Here the balance is a variable array which is sufficient to hold up to 10 double numbers.
Initializing Arrays: You can initialize an array in C either one by one or using a single statement as follows −
double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};
The number of values between braces {} cannot be larger than the number of elements that we declare for the
array between square brackets [].
If you omit the size of the array, an array just big enough to hold the initialization is created. Therefore, if you write
double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0};
You will create the same array as you did in the previous example. Following is an example to assign a single
element of the array −
balance[4] = 50.0;
The above statement assigns the 5th element in the array with a value of 50.0. All arrays have 0 as the index of
their first element which is also called the base index and the last index of an array will be the total size of the
array minus 1.
Accessing Array Elements: An element is accessed by indexing the array name. This is done by placing the index of
the element within square brackets after the name of the array. For example −
double salary = balance[9];
The above statement will take the 10th element from the array and assign the value to the salary variable.
String
Definition, initializing strings
Q. Define Strings in C. also how a string is declared and initialized.
Ans. In C programming, a string is a sequence of characters terminated with a null character 0. For example:
char c[] = "c string";
When the compiler encounters a sequence of characters enclosed in the double quotation marks, it appends a
null character 0 at the end by default.
Declare strings
char s[5];
We have declared a string of 5 characters.
Initialize strings
You can initialize strings in a number of ways.
char c[] = "abcd";
char c[50] = "abcd";
char c[] = {'a', 'b', 'c', 'd', '0'};
char c[5] = {'a', 'b', 'c', 'd', '0'};
String functions
Q. Write few strings functions and their applications.
Ans. Few commonly used strings handling functions are discussed below:
Function Work of Function
strlen() computes string's length
strcpy() copies a string to another
strcat() concatenates(joins) two strings
strcmp() compares two strings
strlwr() converts string to lowercase
strupr() converts string to uppercase

More Related Content

What's hot

'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)sachindane
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
20 C programs
20 C programs20 C programs
20 C programsnavjoth
 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language samt7
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteachingeteaching
 
2. data, operators, io
2. data, operators, io2. data, operators, io
2. data, operators, iohtaitk
 
C notes diploma-ee-3rd-sem
C notes diploma-ee-3rd-semC notes diploma-ee-3rd-sem
C notes diploma-ee-3rd-semKavita Dagar
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingAniket Patne
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programminggajendra singh
 
C programming Workshop
C programming WorkshopC programming Workshop
C programming Workshopneosphere
 
Introduction to c language
Introduction to c languageIntroduction to c language
Introduction to c languageRavindraSalunke3
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++ Bharat Kalia
 

What's hot (20)

C Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.comC Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.com
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
20 C programs
20 C programs20 C programs
20 C programs
 
Overview of c++ language
Overview of c++ language   Overview of c++ language
Overview of c++ language
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
C Programming
C ProgrammingC Programming
C Programming
 
2. data, operators, io
2. data, operators, io2. data, operators, io
2. data, operators, io
 
C notes diploma-ee-3rd-sem
C notes diploma-ee-3rd-semC notes diploma-ee-3rd-sem
C notes diploma-ee-3rd-sem
 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - language
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
C language
C languageC language
C language
 
C language
C languageC language
C language
 
C language basics
C language basicsC language basics
C language basics
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C programming Workshop
C programming WorkshopC programming Workshop
C programming Workshop
 
Introduction to c language
Introduction to c languageIntroduction to c language
Introduction to c language
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 

Similar to Reduce course notes class xii

IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxIIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxrajkumar490591
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxLikhil181
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Rohit Singh
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
 
C prog ppt
C prog pptC prog ppt
C prog pptxinoe
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing TutorialMahira Banu
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.pptatulchaudhary821
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computerShankar Gangaju
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1SURBHI SAROHA
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programmingMithun DSouza
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptxRohitRaj744272
 

Similar to Reduce course notes class xii (20)

C language tutorial
C language tutorialC language tutorial
C language tutorial
 
C programming day#1
C programming day#1C programming day#1
C programming day#1
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptxIIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
IIM.Com-FIT-Unit2(14.9.2021 TO 30.9.2021).pptx
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)Learn c language Important topics ( Easy & Logical, & smart way of learning)
Learn c language Important topics ( Easy & Logical, & smart way of learning)
 
Basic c
Basic cBasic c
Basic c
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
C prog ppt
C prog pptC prog ppt
C prog ppt
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computer
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
 
C Basics
C BasicsC Basics
C Basics
 
C programming
C programmingC programming
C programming
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
 

More from Syed Zaid Irshad

More from Syed Zaid Irshad (20)

Operating System.pdf
Operating System.pdfOperating System.pdf
Operating System.pdf
 
DBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_SolutionDBMS_Lab_Manual_&_Solution
DBMS_Lab_Manual_&_Solution
 
Data Structure and Algorithms.pptx
Data Structure and Algorithms.pptxData Structure and Algorithms.pptx
Data Structure and Algorithms.pptx
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Professional Issues in Computing
Professional Issues in ComputingProfessional Issues in Computing
Professional Issues in Computing
 
Reduce course notes class xi
Reduce course notes class xiReduce course notes class xi
Reduce course notes class xi
 
Introduction to Database
Introduction to DatabaseIntroduction to Database
Introduction to Database
 
C Language
C LanguageC Language
C Language
 
Flowchart
FlowchartFlowchart
Flowchart
 
Algorithm Pseudo
Algorithm PseudoAlgorithm Pseudo
Algorithm Pseudo
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
ICS 2nd Year Book Introduction
ICS 2nd Year Book IntroductionICS 2nd Year Book Introduction
ICS 2nd Year Book Introduction
 
Security, Copyright and the Law
Security, Copyright and the LawSecurity, Copyright and the Law
Security, Copyright and the Law
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Data Communication
Data CommunicationData Communication
Data Communication
 
Information Networks
Information NetworksInformation Networks
Information Networks
 
Basic Concept of Information Technology
Basic Concept of Information TechnologyBasic Concept of Information Technology
Basic Concept of Information Technology
 
Introduction to ICS 1st Year Book
Introduction to ICS 1st Year BookIntroduction to ICS 1st Year Book
Introduction to ICS 1st Year Book
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
Using subqueries to solve queries
Using subqueries to solve queriesUsing subqueries to solve queries
Using subqueries to solve queries
 

Recently uploaded

Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
EmpTech Lesson 18 - ICT Project for Website Traffic Statistics and Performanc...
EmpTech Lesson 18 - ICT Project for Website Traffic Statistics and Performanc...EmpTech Lesson 18 - ICT Project for Website Traffic Statistics and Performanc...
EmpTech Lesson 18 - ICT Project for Website Traffic Statistics and Performanc...liera silvan
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Recently uploaded (20)

Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
EmpTech Lesson 18 - ICT Project for Website Traffic Statistics and Performanc...
EmpTech Lesson 18 - ICT Project for Website Traffic Statistics and Performanc...EmpTech Lesson 18 - ICT Project for Website Traffic Statistics and Performanc...
EmpTech Lesson 18 - ICT Project for Website Traffic Statistics and Performanc...
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

Reduce course notes class xii

  • 1. Computer Science Class XII Multiple Choice Questions 1. an escape sequence can be used to beep from the speaker in C. 2. n escape sequence is used for display output in a newline. 3. <,>, <=,>=,!=, == are Relational operator. 4. A global variable is defined as a declaration outside of any function. 5. A memory location with some data that can be changed is called variable. 6. A pictorial representation of a problem is called a flowchart. 7. A single statement for loop is terminated with a semicolon. 8. A syntax error occurs when the program violates any rules of C programming. 9. A warning appears when you delete a field 10. a++ is equivalent to a=a+1 11. Assuming x does not equal 0, the statement while (x==0) print f (“x==0) while (x==0) causes a logical error 12. C is a relatively simple language that was developed to help students learn to program. 13. Database management systems are intended to eliminate data redundancy. 14. During the development of a program drawing a flowchart is a means to plan the solution. 15. The floating-point variable is used instead of integers to permit the use of decimal points in numbers. 16. Function prototyping for built-in functions is specified in the header file. 17. How many control structures are used in C? 3 18. In preparing a program desk-checking and translating are examples of coding. 19. In preparing a program, one should first define the problem. 20. In the switch case statement, a case block ends with a break; 21. Machine language and assembly language are an example of a low-level language. 22. Precedence determined which operator is used first. 23. scanf () is used to take input in C. 24. The C was developed in 1972. 25. The collection of the same datatypes is called an array. 26. The definition of the main function starts with a reserved word void in C Program. 27. The delay () function is declared in which header file? dos.h 28. The do-while loop is Post-test type of loop. 29. The equal to sign (=) is treated as an operator in C language called the assignment operator. 30. The function fopen () can specify which of the following? The file may be opened for appending 31. The statement for (x=0, x<1, x++) printf (“x=0”) will output once. 32. The value cannot change during the execution of the program is called constant. 33. The while loop is also known as Pre-test loop. 34. These statements if (x=0) printf (“x=0”); is correct syntax, but x=0 will never print 35. What do you call the step-by-step solution to a programming problem? Algorithm 36. When reading one character at a time which of the following functions is appropriate? fgetc() 37. Which is the correct way to define a pointer? int *ptr; 38. Which statement is used to display output n screen in C Program: printf() 39. You can easily create a relationship between tables by using the relationships window. 40. You test a program to find which of the following? Syntax error Introduction to C Q. Define C as an object-oriented language. Ans. C is not an object-oriented language. C is a general-purpose, imperative language, supporting structured programming. Because C isn't object-oriented therefore C++ came into existence to have OOPs feature and OOP is a programming language model organized around objects. A language to have an OOPs feature needs to implement certain principles of OOPs. Few of them are Inheritance, Polymorphism, Abstraction, Encapsulation.
  • 2. Q. Define the origin of C-Language. Ans. The history of C programming language is quite interesting. C was originally designed for and implemented on the UNIX operating system on the DEC PDP-ll, by Dennis Ritchie. C is the result of a development process that started with an older language called BCPL. BCPL was developed by Martin Richards, and it influenced a language called B, which was invented by Ken Thompson. B led to the development of C in the 1970s. For many years, the de facto standard for C was the version supplied with the UNIX operating system. In the summer of 1983, a committee was established to create an ANSI (American National Standards Institute) standard that would define the C language. The standardization process took six years (much longer than anyone reasonably expected). Use printf() function Q. Write a program that print ½, ¾ 5/6, 7/8, 9/10, 11/12 using for a statement. Ans. #include <stdio.h> int main() { int start=1, end=12; for (int i = start; i <= end; ++i) { printf("%d/%dt", i++, i); } return 0; } Q. Write a program that displays “Welcome to the computer lab. Board of intermediate and secondary education, Hyderabad.” On-screen. Ans. #include <stdio.h> int main() { // printf() displays the string inside quotation printf("Welcome to computer lab.n"); printf("Board of intermediate and secondary education, Hyderabad."); return 0; } Q. Write a program, if you enter any alphabet character, the computer will display ASCII code. Ans. #include <stdio.h> int main() {
  • 3. char c; printf("Enter the Alphabet "); scanf("%c”, &c); // %d displays the integer value of a character // %c displays the actual character printf("The ASCII value of %c is %d", c, c); return 0; } Format Specifiers Q. Define Format Specifiers in C. Ans. In C programming we need lots of format specifier to work with various data types. Format specifiers define the type of data to be printed on standard output. Whether to print formatted output or to take formatted input we need format specifiers. Format specifiers are also called a format string. Here is a complete list of all format specifiers used in C programming language. Format specifier Description Supported data types %c Character Char unsigned char %d Signed Integer Short unsigned short Int Long %e or %E Scientific notation of float values Float Double %f Floating point Float %g or %G Similar to %e or %E Float Double %hi Signed Integer (Short) Short %hu Unsigned Integer (Short) unsigned short %i Signed Integer Short unsigned short Int Long Variables and Constants Q. Write a short note on Variables and Constants. Ans. Variables: If you declare a variable in C (later on we talk about how to do this), you ask the operating system for a piece of memory. This piece of memory you give a name and you can store something in that piece of memory (for later use). There are two basic kinds of variables in C which are numeric and character.
  • 4. Numeric variables: Numeric variables can either be of the type integer (int) or the type real (float). Integer (int) values are whole numbers (like 10 or -10). Real (float) values can have a decimal point in them. (Like 1.23 or - 20.123). Character variables: Character variables are letters of the alphabet, ASCII characters or numbers 0-9. If you declare a character variable you must always put the character between single quotes (like so‘A’). So, remember a number without single quotes is not the same as a character with single quotes. Constants: The difference between variables and constants is that variables can change their value at any time but constants can never change their value. (The constants value is locked for the duration of the program). Constants can be very useful, Pi, for instance, is a good example to declare as a constant. Q. What is variable and how many types of variable in C language. Ans. A variable is the 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 a symbol so that it can be easily identified. Types of Variables in C There are many types of variables in c: • local variable • global variable • static variable • automatic variable • external variable Local Variable: A variable that is declared inside the function or block is called a local variable. It must be declared at the start of the block. void function1() { int x=10;//local variable } You must have to initialize the local variable before it is used. Global Variable: A variable that is declared outside the function or block is called a global variable. Any function can change the value of the global variable. It is available to all the functions. It must be declared at the start of the block. int value=20;//global variable void function1() { int x=10;//local variable } Static Variable: A variable that is declared with the static keyword is called static variable. It retains its value between multiple function calls.
  • 5. void function1() { int x=10;//local variable static int y=10;//static variable x=x+1; y=y+1; printf("%d, %d”, x, y); } If you call this function many times, the local variable will print the same value for each function call, e.g., 11,11,11 and so on. But the static variable will print the incremented value in each function call, e.g., 11, 12, 13 and so on. Automatic Variable: All variables in C that are declared inside the block, are automatic variables by default. We can explicitly declare an automatic variable using the auto keyword. void main() { int x=10;//local variable (also automatic) auto int y=20;//automatic variable } External Variable: We can share a variable in multiple C source files by using an external variable. To declare an external variable, you need to use the extern keyword. myfile.h extern int x=10;//external variable (also global) Input/output Q. What is the difference between scanf () and gets () function? SCANF() GETS() when scanf() is used to read string input it stops reading when it encounters whitespace, newline or End of File when gets() is used to read input it stops reading input when it encounters newline or End of File. It is used to read input of any datatype It does not stop reading the input on encountering whitespace as it considers whitespace as a string. It is used only for string input. Escape Sequence Q. Write down the most common escape sequence. Escape Sequences Character ' Single quotation mark " Double quotation mark ? Question mark Backslash 0 Null Character
  • 6. b Backspace f Form feed n Newline r Return t Horizontal tab v Vertical tab Operators Q. Write a short note on Assignment operator. Ans. Assignment operators are used to assigning value to a variable. The left side operand of the assignment operator is a variable and right-side operand of the assignment operator is a value. The value on the right side must be of the same data-type of the variable on the left side otherwise the compiler will raise an error. Different types of assignment operators are shown below: “=”: This is the simplest assignment operator. This operator is used to assign the value on the right to the variable on the left. For example: a = 10; b = 20; ch = 'y'; “+=”: This operator is a combination of ‘+’ and ‘=’ operators. This operator first adds the current value of the variable on left to the value on the right and then assigns the result to the variable on the left. Example: (a += b) can be written as (a = a + b) If initially value stored in a is 5. Then (a += 6) = 11. “-=” This operator is a combination of ‘-‘ and ‘=’ operators. This operator first subtracts the current value of the variable on left from the value on the right and then assigns the result to the variable on the left. Example: (a -= b) can be written as (a = a - b) If initially value stored in a is 8. Then (a -= 6) = 2. “*=” This operator is the combination of ‘*’ and ‘=’ operators. This operator first multiplies the current value of the variable on left to the value on the right and then assigns the result to the variable on the left. Example: (a *= b) can be written as (a = a * b) If initially value stored in a is 5. Then (a *= 6) = 30.
  • 7. “/=” This operator is a combination of ‘/’ and ‘=’ operators. This operator first divides the current value of the variable on left by the value on the right and then assigns the result to the variable on the left. Example: (a /= b) can be written as (a = a / b) If initially value stored in a is 6. Then (a /= 2) = 3. Comments Q. What Is Comment in C Language? Ans. A comment is an explanation or description of the source code of the program. It helps a developer explain the logic of the code and improves program readability. At run-time, a comment is ignored by the compiler. There are two types of comments in C: • A comment that starts with a slash asterisk /* and finishes with an asterisk slash */ and you can place it anywhere in your code, on the same line or several lines. • Single-line Comments which uses a double slash // dedicated to commenting single lines Loops Q. What is the difference between while and do-while loop? Ans. In while the given condition is checked at the start of the loop. If the condition is false then the loop is not executed at all. Only when the condition is true the loop block is executed. In do-while first, the loop block is executed then the condition is checked at the end of 1st-time execution. ex for a while: int a=10; while(a==10) { printf("Hellon"); a++; } In this 1st the condition is checked: is equal to 10? YES, so the printf statement is executed. Now a is incremented to 11. Now again when it checks if a is equal to 10, it is false and hence the loop block (printf statement) is not executed. ex for do-while: int a = 10; do
  • 8. { printf("Quoran"); } while(a==0); now observe the condition in the do-while: is a is equal to zero? the statement is false. But what happens in do- while is that 1st the printf statement is executed and then after that, the condition is checked. Now when the condition is checked it is false and now the loop is terminated. If the given condition is false then in while loop it is terminated immediately, but in do while the statement is executed then the loop is terminated. The minimum number of times a while loop can run is ZERO times whereas a do-while loop runs for a minimum of ONE time even if the condition is false. For Q. Define for loop with its syntax. A for loop enables a particular set of conditions to be executed repeatedly until a condition is satisfied. Imagine a situation where you would have to print numbers from 1 to 100. What would you do? Will you type in the printf command a hundred times or try to copy/paste it? This simple task would take an eternity. Using a for loop you can perform this action in three statements. This is the most basic example of the for a loop. It can also be used in many advanced scenarios depending on the problem statement. Syntax of a For Loop for (initialization statement; test expression; update statement) { // statements } The for loop starts with a fork statement followed by a set of parameters inside the parenthesis. The statement is in lower case. Please note that this is case sensitive, which means the for command always has to be in lower case in C programming language. The initialization statement describes the starting point of the loop, where the loop variable is initialized with a starting value. A loop variable or counter is simply a variable that controls the flow of the loop. The test expression is the condition until when the loop is repeated. The update statement is usually the number by which the loop variable is incremented. Q. Write a program that prints numbers from 1 to 10 their squares and cubes side by side. Ans. #include <stdio.h> int main() { int start=1, end=10; printf(“Numbert Squaret Cuben”); for (int i = start; i <= end; ++i) { printf("%dt%dt%dn", i, i*i, i*i*i);
  • 9. } return 0; } Q. Write a program of the table of 7 by using for statement and draw a flow chart also. Ans. #include <stdio.h> int main() { int n=7, i; printf("Table of 7n"); for (i = 1; i <= 10; ++i) { printf("%d * %d = %d n", n, i, n * i); } return 0; } While Q. Write a program of factorial of 4 by using while loop. Ans. #include<stdio.h> #include<conio.h>
  • 10. void main() { int n=4; int i, f; f=i=1; while(i<=n) { f*=i; i++; } printf("The Factorial of %d is: %d”, n, f); getch(); } Do-While Q. Write a program that prints even numbers from 2 to 20. Ans. #include <stdio.h> int main() { int i, num=20; printf("Print all even number until %d n", num); printf("Even number from 1 to %d aren”, num); i=1; do{ //loop for iterates from 1 to maximum if(i%2==0) { printf("%dn”, i); } i++; }while(i<=num);
  • 11. return 0; } Q. Write a program of odd series 1 to 19 by using do-while statement. Ans. #include <stdio.h> int main() { int i, num=19; printf("Print all odd number until %d n", num); printf("Odd number from 1 to %d aren”, num); i=1; do { //loop for iterates from 1 to maximum if(i%2==1) { printf("%dn”, i); }i++; }while(i<=num); return 0; } Break and Continue Statements Q. Differentiate between Break and Continue Statements. Break continue A break can appear in both switch and loop (for, while, do) statements. A continue can appear only in the loop (for, while, do) statements. A break causes the switch or loop statements to terminate the moment it is executed. Loop or switch ends abruptly when the break is encountered. A continue doesn't terminate the loop, it causes the loop to go to the next iteration. All iterations of the loop are executed even if continue is encountered. The continue statement is used to skip statements in the loop that appear after the continue. The break statement can be used in both switch and loop statements. The continue statement can appear only in loops. You will get an error if this appears in a switch statement. When a break statement is encountered, it terminates the block and gets the control out of the switch or loop. When a continue statement is encountered, it gets the control to the next iteration of the loop.
  • 12. A break causes the innermost enclosing loop or switch to be exited immediately. A continue inside a loop nested within a switch causes the next loop iteration. Conditional Statements If Q. Describe the if statement with its syntax. Also, define why it is used. Ans. The syntax of the if statement in C programming is: if (test expression) { // statements to be executed if the test expression is true } Working of if statement: • The if statement evaluates the test expression inside the parenthesis (). • If the test expression is evaluated to true, the statements inside the body of if are executed. • If the test expression is evaluated to false, the statements inside the body of if are not executed. If-else Q. Describe the if-else statement with its syntax. Also, define why it is used. Ans. If-else statement works when there are true statements and false statements that have to be print on the screen. If the condition is true the true statements print otherwise the false statements displays on the screen. Syntax of the if-else statement: If the condition returns true then the statements inside the body of “if” are executed and the statements inside the body of “else” are skipped. If the condition returns false then the statements inside the body of “if” are skipped and the statements in “else” are executed. if(condition) { // Statements inside the body of if } else { //Statements inside the body of else } The if/else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed. The if/else statement is a part of JavaScript's "Conditional" Statements, which are used to perform different actions based on different conditions.
  • 13. Nested if-else Q. Write a short note on Nested if statement. Ans. When an if-else statement is present inside the body of another “if” or “else” then this is called nested if-else. Syntax of Nested if else statement: if(condition) { //Nested if else inside the body of "if" if(condition2) { //Statements inside the body of nested "if" } else { //Statements inside the body of nested "else" } } else { //Statements inside the body of "else" } Example of nested if. Else #include <stdio.h> int main() { int var1, var2; printf("Input the value of var1:"); scanf("%d", &var1); printf("Input the value of var2:"); scanf("%d”, &var2); if (var1 != var2) { printf("var1 is not equal to var2n"); //Nested if else
  • 14. if (var1 > var2) { printf("var1 is greater than var2n"); } else { printf("var2 is greater than var1n"); } } else { printf("var1 is equal to var2n"); } return 0; } Output: Input the value of var1:12 Input the value of var2:21 var1 is not equal to var2 var2 is greater than var1 Logical operators Q. Define Logical Operators. Ans. An expression containing logical operator returns either 0 or 1 depending upon whether expression results true or false. Logical operators are commonly used in decision making in C programming. Operator Meaning Example && Logical AND. True only if all operands are true If c = 5 and d = 2 then, expression ((c==5) && (d>5)) equals to 0. || Logical OR. True only if either one operand is true If c = 5 and d = 2 then, expression ((c==5) || (d>5)) equals to 1. ! Logical NOT. True only if the operand is 0 If c = 5 then, expression! (c==5) equals to 0. Switch statement Q. Write a short note on a Switch statement.
  • 15. Ans. Switch case statements are a substitute for long if statements that compare a variable to several integral values. The switch statement is a multiway branch statement. It provides an easy way to dispatch execution to different parts of code based on the value of the expression. The switch is a control statement that allows a value to change control of execution. Syntax: switch (n) { case 1: // code to be executed if n = 1; break; case 2: // code to be executed if n = 2; break; default: // code to be executed if n doesn't match any cases } Important Points about Switch Case Statements: The expression provided in the switch should result in a constant value otherwise it would not be valid. Valid expressions for switch: // Constant expressions allowed switch(1+2+23) switch(1*2+3%4) // Variable expression are allowed provided // they are assigned with fixed values switch(a*b+c*d) switch(a+b+c) • Duplicate case values are not allowed. • The default statement is optional. Even if the switch case statement does not have a default statement, • it would run without any problem. The break statement is used inside the switch to terminate a statement sequence. When a break statement is reached, the switch terminates, and the flow of control jumps to the next line following the switch statement. The break statement is optional. If omitted, execution will continue into the next case. The flow of control will fall through to subsequent cases until a break is reached.
  • 16. Nesting of switch statements is allowed, which means you can have switch statements inside another switch. However nested switch statements should be avoided as it makes the program more complex and less readable. Functions Structure of function Q. Explain Functions in C. Ans. In c, we can divide a large program into the basic building blocks known as a 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. The function is also known as procedure or subroutine in other programming languages. Advantage of functions in C There are the following advantages of C functions. • By using functions, we can avoid rewriting the same logic/code again and again in a program. • We can call C functions any number of times in a program and from any place in a program. • We can track a large C program easily when it is divided into multiple functions. • Reusability is the main achievement of C functions. • However, Function calling is always overhead in a C program. Function Aspects There are three aspects of a C function. • Function declaration A function must be declared globally in a c program to tell the compiler about the function name, function parameters, and return type. • Function call Function can be called from anywhere in the program. The parameter list must not differ in function calling and a function declaration. We must pass the same number of functions as it is declared in the function declaration. • Function definition It contains the actual statements which are to be executed. It is the most important aspect to which the control comes when the function is called. Here, we must notice that only one value can be returned from the function. SN C function aspects Syntax 1 Function declaration return_type function_name (argument list); 2 Function call function_name (argument_list) 3 Function definition return_type function_name (argument list) {function body;} The syntax of creating function in c language is given below: return_type function_name(data_type parameter...) { //code to be executed } Types of Functions There are two types of functions in C programming:
  • 17. • Library Functions: are the functions which are declared in the C header files such as scanf(), printf(), gets(), puts(), ceil(), floor() etc. • User-defined functions: are the functions which are created by the C programmer, so that he/she can use it many times. It reduces the complexity of a big program and optimizes the code. Sending and returning values from a function, return statement Q. Why functions are used in C-language? Also, describe the importance of the return statement. Ans. A function is a group of statements that together perform a specific task. Every C program has at least one function, which is main(). The function is used to divide a large code into the module, due to this we can easily debug and maintain the code. For example, if we write a calculator program at that time, we can write every logic in a separate function (For addition sum(), for subtraction sub()). Any function can be called many times. Advantage of Function • Code Re-usability • Develop an application in module format. • Easily to debug the program. • Code optimization: No need to write a lot of code. After performing certain operations that function results in an output which we need to store in a database for later analysis. In the case where we don’t use the return statement, function after printing out the result, control comes out of the function and all the data stored in the stack will be erased resulting in data effective usage. but we didn’t store the value in any permanent data format. To store the value in any file for statistics, we use return statement where we return value to the main function, which collects the value and stores in a permanent file. Passing variables and constants as arguments Q. How data is passed to a function in C? Ans. There are three ways of passing data in function: Pass by Value • Ordinary data types (ints, floats, doubles, chars, etc) are passed by value in C/C++, which means that only the numerical value is passed to the function, and used to initialize the values of the function’s formal parameters. • Under the pass-by-value mechanism, the parameter variables within a function receive a copy of the variables (data) passed to them. • Any changes made to the variables within a function are local to that function only and do not affect the variables in main (or whatever other function called the current function.) This is true whether the variables have the same name in both functions or whether the names are different. Passing Arrays and/or Array Elements • When one element of an array is passed to a function, it is passed in the same manner as the type of data contained in the array. (I.e., pass-by-value for basic types.) • However, when the entire array is passed, it is effectively passed by reference. (Actually, by pointer/address, to be explained completely in the section on pointer variables.) Pass by Pointer / Address
  • 18. • Pass by pointer/address is another type of data passing that will be covered later under the section on pointer variables. • Pass by pointer/address requires the use of the address operator (&) and the pointer dereference operator (*), to be covered later. Array Definition, initializing strings Q. Explain Array. Ans. Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables. A specific element in an array is accessed by an index. All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. Declaring Arrays: To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows − type arrayName [ arraySize]; This is called a single-dimensional array. The array size must be an integer constant greater than zero and type can be any valid C data type. For example, to declare a 10-element array called the balance of type double, use this statement − double balance[10]; Here the balance is a variable array which is sufficient to hold up to 10 double numbers. Initializing Arrays: You can initialize an array in C either one by one or using a single statement as follows − double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0}; The number of values between braces {} cannot be larger than the number of elements that we declare for the array between square brackets []. If you omit the size of the array, an array just big enough to hold the initialization is created. Therefore, if you write double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0}; You will create the same array as you did in the previous example. Following is an example to assign a single element of the array − balance[4] = 50.0; The above statement assigns the 5th element in the array with a value of 50.0. All arrays have 0 as the index of their first element which is also called the base index and the last index of an array will be the total size of the array minus 1.
  • 19. Accessing Array Elements: An element is accessed by indexing the array name. This is done by placing the index of the element within square brackets after the name of the array. For example − double salary = balance[9]; The above statement will take the 10th element from the array and assign the value to the salary variable. String Definition, initializing strings Q. Define Strings in C. also how a string is declared and initialized. Ans. In C programming, a string is a sequence of characters terminated with a null character 0. For example: char c[] = "c string"; When the compiler encounters a sequence of characters enclosed in the double quotation marks, it appends a null character 0 at the end by default. Declare strings char s[5]; We have declared a string of 5 characters. Initialize strings You can initialize strings in a number of ways. char c[] = "abcd"; char c[50] = "abcd"; char c[] = {'a', 'b', 'c', 'd', '0'}; char c[5] = {'a', 'b', 'c', 'd', '0'}; String functions Q. Write few strings functions and their applications. Ans. Few commonly used strings handling functions are discussed below: Function Work of Function strlen() computes string's length strcpy() copies a string to another strcat() concatenates(joins) two strings strcmp() compares two strings strlwr() converts string to lowercase strupr() converts string to uppercase