C Programming Concepts - Q&A
1. Define Algorithm and list the characteristics of an algorithm.
An algorithm is a step-by-step procedure to solve a problem.
Characteristics:
1. Finiteness
2. Definiteness
3. Input
4. Output
5. Effectiveness
Page 1
C Programming Concepts - Q&A
2. Define flowchart. Give five symbols used in flowcharts.
A flowchart is a graphical representation of an algorithm.
Symbols:
1. Terminal (Start/End)
2. Process
3. Decision
4. Input/Output
5. Arrow (Flow line)
Page 2
C Programming Concepts - Q&A
3. What is an identifier? Write the rules to declare an identifier.
An identifier is the name used to identify variables, functions, arrays, etc.
Rules:
1. Must begin with a letter (A-Z or a-z) or underscore (_)
2. Can contain letters, digits, and underscores
3. Cannot be a keyword
4. Case sensitive
5. No special characters
Page 3
C Programming Concepts - Q&A
4. Write the syntax of the if...else statement.
Syntax:
if (condition) {
// statements
} else {
// statements
Page 4
C Programming Concepts - Q&A
5. What is a data type? List the various basic data types available in C.
A data type specifies the type of data a variable can hold.
Basic data types in C:
1. int
2. float
3. char
4. double
5. void
Page 5
C Programming Concepts - Q&A
6. Write the syntax of if, if...else, and if...else if statements.
if (condition) {
// statements
if (condition) {
// statements
} else {
// statements
if (condition1) {
// statements
} else if (condition2) {
// statements
} else {
// statements
Page 6
C Programming Concepts - Q&A
7. Write the syntax of for, while, and do...while loops.
for (init; condition; update) {
// statements
while (condition) {
// statements
do {
// statements
} while (condition);
Page 7
C Programming Concepts - Q&A
8. Write the syntax of if, while, do...while, switch, and for. Include break usage with an example.
if (condition) {...}
while (condition) {...}
do {...} while (condition);
switch (expression) {
case value:
// statements
break;
default:
// statements
for (...) {...}
Page 8
C Programming Concepts - Q&A
9. Write a program to print n natural numbers using a for loop.
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
printf("%d ", i);
return 0;
Page 9
C Programming Concepts - Q&A
10. Write a C program to reverse a number.
#include <stdio.h>
int main() {
int n, rev = 0;
scanf("%d", &n);
while(n != 0) {
rev = rev * 10 + n % 10;
n /= 10;
printf("%d", rev);
return 0;
Page 10