0% found this document useful (0 votes)
18 views5 pages

Revisions Questions of C Programming

Questions for revision

Uploaded by

beshhydra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

Revisions Questions of C Programming

Questions for revision

Uploaded by

beshhydra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

C PROGRAMMING REVISION QUESTIONS

1. Explain the meaning of the following as used in C programming language


a. #include<>
b. Main()
2. Describe the structure of a C program
3. Explain five reasons why c is a preferred programming language
4. With aid of three examples explain the meaning of curly brackets “i.e. {} “in c programming
5. Illustrate two ways of:
a. Defining constants
b. Inserting comments in C programming language
6. Define the following program elements of structured programming languages.
a. Reserved words.
b. Data types.
c. Variables.
7. Explain the following components of a structured programming language:
a. Program header;
b. Declaration;
c. Program body.
8. Describe the five main data types of C programming language
9. Explain the function of the following Character Escape sequence
a. \a
b. \b
c. \t
d. \v
e. \n
f. \r
10. Describe the three categories of statements in c programming
11. Describe the following techniques of error handling
a. Use of watch values
b. Breakpoints
c. Stepping
12. Using examples explain the three main categories of operators in c programming
13. Describe the three logical operators in C programming using truth tables
14. Using relevant examples describe the following relational operators of C Programming language
a. Not Equal to
b. Equal to
15. Explain the meaning of the following characters as used with Printf statements
i. d
ii. e
iii. f
iv. c
16. Using flowcharts describe the three control structures in c programming
17. Describe compound assignment statements available in C programming
18. With aid of examples describe the conditional/ternary operator of C programming language
19. Differentiate between the following error handling techniques
a. Error isolation.
b. Tracing.
20. With the aid of relevant examples differentiate between the following selection control structures as
used in C programming
a. If-else statement. And Nested if statement.
b. Switch statement and Goto statement

21. Rewrite the following portion of c program using Nested if statement


switch colour {
case ‘r’:
case ‘R’:
printf (“RED”);
break;
case ‘w’:
case ‘W’:
` printf (“WHITE”);
break;
case ‘b’:
case ‘B’:
printf (“BLUE”);
break;
default:
printf (“ERROR!”);
}

22. Write syntax diagram for the following control structures


a. If Else statement
b. Switch statement

23. Explain the similarity and difference between Nested if and switch ststements
24. Write the output of the following program given the input as
a. K=12 P= 7 H= 10 and G= 100
b. K=15 P= 70 H= 100 and G= 100
c. K=25 P= 32 H= 170 and G= 81
d. K=100 P= 100 H= 100 and G= 100

Int K,H,P,G
If (K>P && G!=H)
{
printf(“Value ok”);
Printf((“ Add Ten to G”);
}
else if (K<P II G==H)
Printf(“The values are wrong”);
else if (K<=P II G>=H)
Printf(“The values are almost ok”);
else if (K>=P II G>=H)
Printf(“The values are almost ok”);
else
Printf (“Try again”);
Printif( “it shall be well”);
25. Write the output of the following C program
#include <stdio.h>
main ()
{ int digit;
digit = 0;
while (digit <=9)
{ printf(“%d\n”, digit);
++digit;
}
}
26. Rewrite the program in 25 above using FOR and DO WHILE statements as used in C programming
27. Differentiate between printf() and scanf() functions of C programming and explain their relation with
#include<stdio.h> header file
28. With the aid of syntax diagrams differentiate between FOR and DO WHILE repetition control structures
29. Write the output of the following C program
#include<stdio.h>
{
int i, j ;
for(i=1; i<=2; i++)
for(j=1; j<=2; j++)
{
if(i==j)
continue;
else
printf(“%d %d\n”, i,j );
}
}
30. Rewrite the program in 29 above using WHILE and DO WHILE statements
31. Write the output of the following codes
a. for(int k=1;k<=5; k++)
{
for(int J=1;j<=5; j++)
printf(“%d ”,k);
printf(“\n”);
}
b. for(int k=1;k<=5; k++)
{
for(int J=1;j<=5; j++)
printf(“%d ”,j);
printf(“\n”);
}
c. for(int k=1;k<=5; k++)
{
for(int J=1;j<=5; j++)
printf(“%d ”,k*j);
printf(“\n”);
}
d. for(int k=6;k>=1; k--)
{
for(int J=1;j<=k; j++)
printf(“%d ”,j);
printf(“\n”);
}
e. for(int k=7;k>=1; k--)
{
for(int J=1;j<=5; j++)
printf(“%d ”,k);
printf(“\n”);
}
f. for(int k=1;k<=5; k++)
{
for(int J=1;j<=k; j++)
printf(“%d ”,k);
printf(“\n”);
}
g. for(int k=1;k>=5; k++)
{
for(int J=1;j<=5; j++)
printf(“%d ”,j*k);
printf(“\n”);
}
32. Rewrite the program in 31 above using WHILE and DO WHILE statements
33. Define the term Data Structures
34. Give a brief description of the following data structures
a. Arrays
b. Stack
c. List
35. Differentiate between passing by value and passing by reference as used in c programming giving
examples in each case
36. Explain two advantages of using arguments/ parameters when writing programs involving functions in
programming
37. Explain the importance of the following in relation to program development
a. Use of care
b. Choice of identifier
c. Indenting
d. Use of Sub Programs
38. With the aid of a C program illustrate the scope of Local and Global variables
39. Illustrate bubble sort using the following number
8 2 9 6 3 5 7 4
40. Illustrate selection sort using the following number
6 7 15 8 3 11 12
41. Explain advantage(s) of bubble sort over other sorting algorithms
42. Differentiate between the following sorting algorithms
43. Explain the reason why bubble sort algorithm is considered slow;
44. Compare and contrast between bubble and selection sort.
45. Draw flowcharts for bubble, selection and insertion sorting algorithms
46. Write algorithms to illustrate quick sort algorithm.
47. Explain three differences between binary search and sequential search algorithms
48. Draw a flowchart to illustrate searching for a number in an array of ten numbers.
49. Write an algorithm for binary search algorithm
50. Explain the main difference between bubble sort and selection sort algorithms
51. Distinguish between insertion sort and quick sort algorithms
52. Explain Three advantages of insertion sort over bubble and selection sort algorithms

You might also like