You are on page 1of 17

Chapter 1

Introduction
1. With the help of block diagram of digital computer explain the function of control unit and
Memory unit.

2. How does digital computer differ from Analog computer? Define hybrid computer .

3. Explain briefly the various generations of computers.

4. Discuss briefly about the history of computing and computers.

5. What is a programming language? Differentiate between high level language and low
level programming language.

6. Why second generation of computer is better than first generation. Differentiate between
third generation and forth generation of computer

7. What do you mean by programming language? Explain all types of programming


language with examples.

8. Explain the classification of computers based on size and capabilities.

9. Why higher generation computers are better?

10. Why C is called structured programming language?

11. What is software? Differentiate tailored and packaged software.

12. Differentiate structured programming concept from traditional concept.

13. Define Software development Life Cycle.


Chapter 2
Programming logic
1. What is the importance of documentation in programming? Write an algorithm and draw a
flowchart to find and output all the roots of a quadratic equation, for non-zero coefficients. In
case of errors program should report suitable error message.
2. Write down the algorithm and flowchart for the stated program. Until the user presses "Y",
read marks of student in 3 subjects and display his total percentage.
3. Draw a flow-chart and then write a program to read three sides of a triangle and print area
for valid data and to print " Invalid data" if either one side of the triangle is greater or equals
to the sum of other two sides.
(Area = √ s ( s−a )( s−b)( s−c ) where a, b, c are the three sides and s = (a + b + c)/2)
4. State the characteristics of a good algorithm. Flowchart is a pictorial representation of an
algorithm. Justify the statement with suitable example.
5. Write an algorithm and draw a flow chart to count positive and negative number in n given
numbers.
6. Define pseudo-code with example. Write an algorithm and draw a flow chart to find the
largest among three numbers.
7. Write an algorithm for finding greatest number among 'n' numbers.
8. Write an algorithm and then draw a flowchart for the following:
Read two numbers from the user (say A and B). If A is less than B then add them otherwise
subtract them store the result. Finally, if the result is negative, then make it positive.
9. Draw a Flowchart to read 3 numbers from the user and find the smallest one.
10. Draw a flow chart for finding greatest digit for the supplied number by the user.
11. Describe the steps involved while developing a program.
12. What are the differences between a flow chart and an algorithm?
13. Write a program and flow chart to read a positive integer value and compute the following
sequence. If the number is even, half it, if it is odd, multiply by 3 and add 1 and print result.
If the input value is less than 1, print a message containing the word “ERROR”.
14. Draw a flow chart to read three integer numbers and display sum of greater two numbers
among them.
15. Write algorithm and flowchart for following.
a. Armstrong number
b. Palindrome number
c. Perfect number
d. Prime number
e. Factorial
16. What do u mean by language translation? Differentiate compiler and interpreter.
17. Define coding, compilation, debugging, execution, testing, implementation and
maintenance.
18. Differentiate run time error from compile time error.

Chapter 3
Variables and data types
1. Describe with example the different types of operators available in C.
2. What is ternary operator? Explain it with flowchart and syntax.
3. Why we need different data types in programming? Differentiate between local and
global variables with suitable example.
4. What are the final values of a, b, c and x after execution of the following statements?
int x =10, a = 10, y = 11, z = 12;
X + = ++a - b++;
x - = ++ z % --b;
x *= ++a + b++ * z -- ;
5. Given the code below write the output of the program.
#include<stdio.h>
#include<conio.h>
void main ( )
{
int x, y, z;
x = 3 ; y = 4 ; z = 5;
clrscr ( ) ;
printf ( “Given x = %d, y = %d, and z = %d, \n”, x, y, z) ;
x = + + x + y;
printf ( “ x = x + y assigns %d to x; \n”, x) ;
x = 6 ;
x + = y ;
printf ( “ x + = y assigns %d to x ; \n”, x) ;
x = 2;
z = z * x + y + + ;
printf ( “ z = z * x + y assigns %d to z; \n”, z) ;
z = 10 ;
z = z * (x + y) ;
printf ( “ z = z * (x + y) assigns %d to z ; \n”, z) ;
z = 10 ;
z * = x + y ;
printf ( “ z * = x + y assigns %d to z ; \n”, z) ;
z = 10 ;
Z * = x + y ;
printf ( “z * = x + y assigns %d to z ; \n”, z) ;
getch ( ) ;
}

6. Determine the output of the following program.


void main ( )
{
int m = 100, n = 50;
printf ("%d\n", 10 + m++);
printf ("%d\n", 10 + n--);
printf ("%d\n", 10 + --n);
}
7. What are constant and variable?
8. What are the steps involving during the programming? Explain.
9. What are the rules to defining identifiers and variables?
10. Differentiate keywords and Identifier.
11. Define the following terms with suitable example
i. Statement
ii. Token
iii. Format specifier
12. Mention the appropriate data type for storing following data. Also justify your answer in
brief.
i. Distance jumped by a frog.
ii. A prime number between 5 and 555.
iii. Weight of your body.
iv. The examination symbol number of a student.
13.
a) Find the value of k;
int i = 4,j = 6, k = 7
k +=(5+i*j%7)*6/(i+j)-3;
b) Find the value of x, y, z, w, p and q
int x=10,y=5,z,w=9, p,q;
x+=10;
y=x++;
z= – – x;
w/=x;
p=x+y;
q=p+w;
z=p++;

Chapter 4
Control Structures
1. What do you mean by entry controlled an exit controlled loop? Explain different types of
looping constructs available in C with suitable examples.

2. Write a program in C to read temperature of 10 cities for a month (daily for 30 days).
Then calculate and display the average monthly temperature of each city.

3. Define "Nested Loop". Use the nested loop to calculate and display the multiplication
table from |X| =(1 to 12) X 12 = 144.

4. Analyze and predict the correct output.


#include<stdio.h>
main()
{
int i,j,x=0;
for (i=0;i<5;i++)
for (j=0;j<i;j++)
{
x+=(i+j-1);
printf(“%d”,x);
}
printf(“\n x=%d”,x);
}
5. Correct the errors, if any, in give program, and predict its output.
#include<stdio.h>
test(float)
main()
{
int b,c;
float z;
b=15.67 ;z=16.45 ; c=17;
b=test(z);
printf(“\n%d”,b);
}
test (float q);
{
q=q+1;
return(q);
}
6. Differentiate between break and continue with suitable example.

7. Write a program to display the following menu:

Menu

a) conversion of ASCII code to char

b) conversion of 0F temperature to 0C

c) multiplication table of given number

d) exit from program

and to perform task as per user's choice repeatedly until his/her choice is to exit.

8. Define nested looping. Write a program to generate all the possible combinations of
integer numbers 1, 2 and 3.

9. Consider the following tax table:

Income Tax
< Rs.10,000 Nil
Rs. 10,000 to Rs. 19,999 10%
Rs. 20,000 to Rs. 29,999 15%
Rs. 30,000 to Rs. 49,999 20%
>Rs.50,000 25%
Write a flow–chart and a program to compute tax amount when income
amount is given.
10. At which condition would you prefer switch statement in C? Explain switch statement
with suitable example.
11. Explain if, elseif, if..else,for,while,do..while with suitable example,flowchart and syntax.
(decision control mechanism and looping/iteration).

12. Write a menu program to satisfy the following functions.

a) Check whether given string is palindrome or not

b) Find all the prime numbers from 100 to 200

c) Sum of n natural numbers

d) Exit from program

(Perform above task until the user wants to exit. Full marks is given if user-defined
functions are used)

13. What is the output of the following program?

main()
{
int k, a;
a = 10;
for(k=0; k<10; k++)
{
if(k%2 = =0)
a = a+k;
else
a = a–1;
printf("a=%d\n",a);
}
printf("\n the value of a = %d", a);
}
14. What do you mean by selective and repetitive statement? Why do we need break and
continue statement.

15. Write a program to find the terms in the given series till the term value is less than 250.

(12+22)/3, (22+32)/4, (32+42)/5,.............................

16. Write a program to generate Fibonacci series up to nth term.

17. WAP to find factorial of supplied number.

18. An electricity board charges according to the following rates.


For the first 100 units -------------------------- Rs. 40 per unit

For the next 200 units ------------------------- Rs. 50 per unit

Beyond 300 units ------------------------------ Rs. 60 per unit

All users are also charged ‘meter charge’, which is equal to Rs. 50. Write a complete C
program to read the number of units consumed and print out the total charges.

19. WAP to read a number and perform the following.

a. To find sum and product of each digit.

b. To find sum and product of odd digit.

c. To find largest and smallest digit.

d. To check whether it is Armstrong or not.

e. To check whether it is perfect or not.

f. To check whether it is palindrome or not.

g. To check whether it is strong or not.

h. To check prime or not.

i. To find sum of prime digit only.

j. To reverse it.

k. To find sum of first and last digit only.

20. WAP to implement cosine series.

Cos x =

(−1)n (2 n) = x2 x4
∑ (2 n !) x 1− + ............. .
2! 4 !
n=0

21. WAP to implement sin series.

x 3 x5 x 7
Sin x= x− + − ............. .
3! 5 ! 7 !
22. WAP to display following series.

a. 1,11,111,1111,11111

b. 1,4,9,16..upto 10th term.

c. 1,121,12321,1234321…
Chapter 5
Arrays and Strings
1. Why array is important in programming? How can you initialize different types of arrays?
Explain 2-dimensional array in C.

2. Define String. Write a program to read n employees names and display them in
alphabetical order.

3. How different types of array are initialized? Explain it with suitable example.

4. Why array is called static and homogenous data type?

5. Describe string handling functions with suitable example.

6. WAP to read m X N array and perform the following

a. Find sum of diagonal element(left to right, right to left)

b. Find sum of first row.

c. Find sum of second column.

d. Convert it to upper triangular matrix.

e. Convert it to lower triangular matrix.

f. Transpose it.

7. WAP to read two m X n matrix and find their sum and product.

8. WAP to read n element matrix and sort them in ascending and descending order.

9. WAP to search supplied number in one dimensional and two dimensional matrix.

10. WAP to read n element matrix and find their sum.

11. Write a program that asks a user for a number and finds out if the number is present in
the 2D array given below:

int arr [3][3]= {


{ 6, 37, 33},
{ 12, 11, 13},
{ 14, 85, 96}
};
12. Print the following pattern using a C program. Take the string as an input from the user.
Write a generic program to accept string of any length.

Example pattern

If the user input is NEPAL than the output should be as follows:

1N
2EE
3PPP
4 AAAA
5LLLLL

13. WAP to read n element array and find sum of smallest and largest element of matrix.

14. WAP to read m X n matrix and find smallest one.

15. WAP to read string and count specified character on it.

16. WAP to read string and check whether it is palindrome or not.

17. Write a C program to read a string and display only vowels of that string.

18. Write a C program to read a string and count vowels and consonant separately of that
string.

19. Write a program to insert a given character at the given array index of a given string. For
example if the given string is “Gnesh”, given character is ‘a’, and the given array index is
1, the resulting string should be “Ganesh”.

20. Write a program to read a message and print changing the uppercase alphabets to
lowercase and vice-versa.
Chapter 6
Functions
1. What is recursive function? Write a recursive program to generate the first 15 numbers
of Fibonacci sequence.

2. What do you mean by storage class? Define its types with suitable examples.

3. Explain how function can be used to write concise programming and also differentiate
between macros and function.

4. Explain components of function with suitable example.

5. Explain merit and demerits of using function in programming.

6. Why C is called structured programming?

7. What is a function? Categorize it in terms of arguments and return value.

8. Differentiate user defined function from built in function.

9. Differentiate between local and global variable with suitable example.

10. Write a recursive function for the following.

a. To find factorial of given number.

b. To find sum of each digit of supplied number.

c. To find whether number is palindrome or not.

d. To find sum of first 10 natural number.

11. Differentiate between macro and function with the help of examples.

12. Write a program with user defined function using pointer to convert all the upper
case to lower case and vice-versa in a string given by the user .
13. Write a program with user defined function using pointer to convert all the upper
case to lower case and vice-versa in a string given by the user .
14. Write the output.

#include<stdio.h>
#include<conio.h>
fun(int p);
void main()
{
int x=4, y;
clrscr();
printf(“%d \n”, x);
y=fun(x);
printf(“y=%d \n”,y);
getch();
}
fun(int p)
{
return (2*p/12+13);
}
15. Write a program with user defined function using pointer to convert all the upper
case to lower case and vice-versa in a string given by the user .
16. Define prototype. Show its example.

17. Write a program to find the sum of all prime numbers in a given array. The main function
of your program should take the help of a user defined function that tests whether a
given number is prime or not.
Chapter 7
Pointers
1. What are the advantages of function call-by -* reference over call-by-value? How would
you pass a variable by reference to a function? Give an example.
2. What is Pointer? How does a pointer differ from an array? Explain dynamic memory
allocation.
3. Define pointer and show how pointers can be used to return more than one values from
a function.
4. Write a program with user defined function using pointers to convert all the upper- case
letters to lower-case and vice versa in a string given by the user.
For example: The C pRogramming.
tHE c PrOGRAMMING.
5. Write a program to sort (ascending order) n integer values in an array using pointer.
6. Why do we need dynamic memory allocation? How it is achieved? Explain it with
suitable example.
7. What is memory leak? Write a program to print reverse elements of an array using
Dynamic Memory Allocation.
8. Find output
a.
void main()
{
int a=9 , b=4, d;
printf(" a: %d b: %d \ n", a , b);
printf(" sum: %d", func(&a,b));
}
int func(int *y, int x)
{
return (++*y + (++x) );
}

b.
#include<stdio.h>
void main()
{
int i, j;
char str[]="POINTER";
clrscr();
for(i=0;str[i]!='\0';i++)
{
for(j=0;j<=i;j++)
{
printf("%c",str[j]);
printf("\n");
}
}
}

c.
#include<stdio.h>
void disp(int*n);
void main ()
{
int i;
int marks [ ]={15,16,17,18,19,20,21,22,23,24};
disp(marks);
}
9. What is the difference between array of pointers and pointer to arrays? Explain with
examples.
10. Define pointer variable. What are the advantages of using pointer in a function?
11. Explain malloc, calloc, realloc and free functions with their syntax and meaning.
12. Can function return multiple values? If so, how?
13. What is double indirection? Show its example.
14. What does the following mean
- int *p
- int *p[10]
- int (*p)[10]
- int (*p) (void)
- int *p (char *a)
Chapter 8
Structure
1. What is nested structure? When would you use nested structure?

2. Create a structure called book having member name, price, author and published date in
day, month and year. Write a program to read 100 books information from the user and
display those books having price is greater than 250.

3. What difference between Structure and Union. Write about the storage space (in byte) of
they have same definition.

Like –

Struct a Union a

{ {

int i; int i;

char c[2] char c[2];

}; };

4. How is Union different from Structure? Illustrate with suitable example.

5. How a nested structure component is accessed? Explain it with suitable example.

6. How structure is passed while calling function? Explain it with suitable example.

7. What is structure? Explain its components. How can you access the members of a
structure?

8. Create a following structure named as student.

Roll. No. Name Address Faculty Date Of Birth


mm dd Yy

Write a program to read 48 student details (record) and display


i. Display all records.

ii. Display those records whose address is Pokhara.

iii. Display those student records who born in July month.

Chapter 9
File Handling
1. A car company requires that records should be kept in stated format.

Model No, Engine Power, No of seats, No of doors, Model Name

For example, 152DV4c, 76.234,5,5, NextGen.

Write an EFFICIENT program to read 4 sets of such data and store in a data file.

2. Describe the rules governing the use of fopen function. What information is returned by
it? Also describe about file pointer.

3. Write a program to read information of 10 students in 4 subjects, store in a file and print
the result:

EEMC
Name C BEE MTH CT Total
John 88 78 98 87 --
Beecky 78 65 45 23 --
------- ---- ---- ---- ---- ----
4. What is a FILE pointer? Write a program to create a structure for customers in a Shop of
the following data:

CID, CName, Address, TelNo, Balance

Read 100 customers from a file customer.dat and display the information of the
customers who is greater than Rs 1000.

5. What are file opening modes ? Explain them briefly.

6. Describe file handling functions fopen, fprintf, fscanf, fclose with their syntax and
meaning.

7. WAP to read name of employee and store it on a file eemc.txt.

8. What is significance of file pointer in file handling? Consider a following structure

Roll. No. Name Address Faculty Date Of Birth


mm dd Yy

Write a program to create”student.txt” file to store the above records for 100 students.
Also display these records of students who are not from Pokhara.

You might also like