PROGRAMMING TO PROBLEM SOLVING (C) SOME IMP
PRACTICE QUESTIONS (TOPICS- BUBBLE SORT ,BINARY AND
LINEAR SEARCH,ARRAY,STRING HANDLING FUNCTIONS)
1.WHAT IS CHARACTER ARRAY AND WRITE ITS SYNTAX?
2. NAME AND WRITE TWO STRING HANDLING FUNCTIONS WITH
THE HELP OF SUITABLE EXAMPLE.
3.EXPLAIN BINARY SEARCH WITH THE HELP OF EXAMPLE AND
WRITE ITS ALGORITHM.
4.COMPARE LINEAR AND BINARY SEARCH.
5.CONSTRUCT A PROGRAM FOR BUBBLE SORT.
SOLUTIONS:-
① ARRAY: To process a large amount of data, we need a data Structure known as Array.
CONDITIONS:
● The data elements have the same datatype.
● The elements of the array are stored in continuous memory locations
referred as index.
CHARACTER ARRAY:
In character array, we use characters that can be alphabets, numerics, and Special symbols.
SYNTAX:
datatype arrayname [size];
For example: char a[10];
, → char name [6] = { 'H' , 'e' , 'l' , 'l' , 'o' , '\0' }; (5+1=6, 10-Null)
② STRING: Every string can be implemented using character array because string is a
combination of Characters.
For example:
#include <stdio.h>
int main ()
{
char a [] = "ABC" ;
printf ("%s\n", a);
return 0;
}
OUTPUT: ABC
The string handling functions:
● Str cat()
● Str rev ()
● Str lwr ()
● Str upr()
Str upr():
#include<stdio.h>
#include <string.h>
int main()
{
char str[]=”hello world”;
printf(“%s\n”,strupr(str));
return 0;
}
OUTPUT: HELLO WORLD
PRACTICE QUESTIONS (TOPICS- BUBBLE SORT ,BINARY AND
LINEAR SEARCH,ARRAY,STRING HANDLING FUNCTIONS)
1.WHAT IS CHARACTER ARRAY AND WRITE ITS SYNTAX?
2. NAME AND WRITE TWO STRING HANDLING FUNCTIONS WITH
THE HELP OF SUITABLE EXAMPLE.
3.EXPLAIN BINARY SEARCH WITH THE HELP OF EXAMPLE AND
WRITE ITS ALGORITHM.
4.COMPARE LINEAR AND BINARY SEARCH.
5.CONSTRUCT A PROGRAM FOR BUBBLE SORT.
SOLUTIONS:-
① ARRAY: To process a large amount of data, we need a data Structure known as Array.
CONDITIONS:
● The data elements have the same datatype.
● The elements of the array are stored in continuous memory locations
referred as index.
CHARACTER ARRAY:
In character array, we use characters that can be alphabets, numerics, and Special symbols.
SYNTAX:
datatype arrayname [size];
For example: char a[10];
, → char name [6] = { 'H' , 'e' , 'l' , 'l' , 'o' , '\0' }; (5+1=6, 10-Null)
② STRING: Every string can be implemented using character array because string is a
combination of Characters.
For example:
#include <stdio.h>
int main ()
{
char a [] = "ABC" ;
printf ("%s\n", a);
return 0;
}
OUTPUT: ABC
The string handling functions:
● Str cat()
● Str rev ()
● Str lwr ()
● Str upr()
Str upr():
#include<stdio.h>
#include <string.h>
int main()
{
char str[]=”hello world”;
printf(“%s\n”,strupr(str));
return 0;
}
OUTPUT: HELLO WORLD