0% found this document useful (0 votes)
9 views8 pages

C Compiled

The document contains a compilation of questions and programming tasks related to C programming, covering topics such as algorithms, flowcharts, control statements, arrays, functions, pointers, file handling, and graphics. It includes theoretical questions, programming exercises, and short notes for each topic, aimed at enhancing understanding and practical skills in C programming. The content is structured to facilitate learning through examples and problem-solving.

Uploaded by

Scribd
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)
9 views8 pages

C Compiled

The document contains a compilation of questions and programming tasks related to C programming, covering topics such as algorithms, flowcharts, control statements, arrays, functions, pointers, file handling, and graphics. It includes theoretical questions, programming exercises, and short notes for each topic, aimed at enhancing understanding and practical skills in C programming. The content is structured to facilitate learning through examples and problem-solving.

Uploaded by

Scribd
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

Compiled Questions From 2071 - 2080

Input 1, 2 & 3
1. what is algorithm/flowchart. How is it different from flowchart?
2. Explain flowchart with example. What are the benefits of using flowchart.
3. what are the features of a good algorithm/flowcharts.

4. Explain or discuss structure of C-Program with suitable example.


5. What do you mean by statements? Explain the different types of statement with
example.
6. Draw a flow chart and write an algorithm to find a number is divisible by either 5
or 7?
7. Draw a flow chart and write an algorithm to find out whether a given number is
zero, +ve or –ve.
8. Describe the four basic data types with example.
9. What is data type? Why do we need it in programming? Explain any three basic
data types with example.
[Link] is preprocessor directive? Discuss # define directive with example.
[Link] do you mean by unformatted I/O? Explain
[Link] do you mean by problem analysis? What are the properties of a good
algorithm? Explain the Compilation and Execution of any C program? [10-marks]
[Link] is variable? How is it different from constant? How do you write comments
in c?

Operators and Expressions


1. Explain the relational operator and Increment/decrement operator with
example.
2. Discuss increment and decrement operators with suitable example
3. Discuss logical operators along with the truth table.
OR
Discuss different logical operators in detail
4. What are the different types of operators available in C? Explain.
5. List different types of operators and explain any three of them.
6. What is type conversion? Discuss type casting with suitable examples.
7. Define nested if else statement with suitable flowchart.
8. List various binary and unary operators used in C?
9. Differentiate between constant and literals. Why do we need to define the
type of data?
Programs
1. Write a program using switch statement to display EXCELLENT, VERY
GOOD, GOOD, SATISFACTORY, or FAIL if the user enters A, B, C,D,E
respectively
2. Write a program to calculate sum of first 10 odd numbers.
3. Write a program to check whether a number entered is even or odd.
4. Write a program to display first n prime numbers
5. Write a C code to check if user given input is exactly divisible by 5 or 11
using nested if else statement?
6. Write a program to print largest among three numbers entered by the
user.

Control Statement
Questions and program
1. What are the four types of control statement use in C programming? Explain
2. What do you mean by looping? Explain while loop with suitable example.
Compare while loop with do while loop. Write a program to find sum and
average of first n natural numbers. [10 marks]
3.
4. What is looping statement? Discuss different looping statements with suitable
example of each.
5. What do you mean by entry-controlled and exit-controlled loop? Write a
program to print the following output.(2+4)
1
01
101
0101
10101
6. Differentiate break statement with continue statement. What is the output if
the following program ?
#include<stdio.h>
#include<conio.h>
#include<math.h>
Void main()
{
int x=2, n=5, sum=0, i;
clrscr();
for(i=1; i<=n; i++)
{
If(i%2==0)
Sum==sum-pow(x,i);
elseDownloaded from CSIT Tutor
sum=sum+pow(x,1);
}
Printf(“sum=%d”,sum);
Getch();
}
7. Why do we need a break and continue statement? Define formal argument
and actual argument in function with examples. Identify and list the errors in
the following code.
int main(){
int a,b,c
scanf("%d%d%d, &a, &b, &c);
sum(a, b, c);
return -1;
}
void sum(int x, int y, int z){
int sum;
sum = a + b + c;
return sum;

8. Differentiate between while and do while loop with example.


9. What is a break statement? Discuss with example. How the break statement
is different from continue statement?
10.
[Link] that computes the sum of digits of a given integer number.
[Link] a program that uses "while" loop to compute and prints the sum of a
given numbers of squares. For example, if 4 is input, then the program will
print 30, which is equal to 12+ 22 + 32 + 4 2.
[Link] do you mean by jump statement? Explain each jump statement with an
example. Write a program to check whether the number entered is prime or
not. [10-marks]
[Link] a program to demonstrate the following menu-driven program. The
user will provide an integer and alphabet for making choice and the
corresponding task has to be performed according as follow:
A. Find Odd or Even
B. Find Positive or Negative
C. Find the Factorial value
D. Exit
The choice will be displayed until the user will give “D” as a choice.
15.
Array
1. What is array?
2. What are the benefits of using array?
3. Compare one dimensional array with two dimensional array.
4. "Size of character array is always declared one more that the input size."
Justify the statement
5. Write syntax to declare and initialize 2-dimensional array? With suitable
program logic explain how would u find transpose of a 3*3 matrix.

Programs
1. Write a program to find the sum of each row of 3*2 matrix.
2. Write a program to check whether the diagonal elements of a (4*4) matrix
are all Zero.
3. Write a program to add two matrices using array.
4. Write a program to find transpose of a matrix.
5. Write a program to read a character array in input as "TRIBHUVAN
UNIVERSITY" from the user and find out how many times a character "I"
occurs in that array?
6. Write a program to check if two matrices are identical or not.
7. Write a program to read P*Q matrix of integers and find the largest integer of each row
and display it.
8. Write a program to initialize an array of dimension 10 and sort the numbers within the
array in ascending order.

Functions
1. Explain the functions and its types use in C programming with example
2. Discuss the benefits of using functions.
3. Explain the passing structure to function with example
4. Explain pass by value and pass by reference with suitable example of each.
5. Differentiate between call by value and call by reference with example.
6. What is structure? How is it different from array and Union? Discuss
7. Explain nested structure with example.
8. What is the difference between exit(0) and exit(1)? Discuss the need of
nested structue with an example. Write a program to find the value of x y
without using POW function. [10-marks]
9. Explain different file I/O functions with example
[Link] the different types of I/O functions used in file handling with syntax.
[Link] any three string functions.
[Link] the concept of recursive function using the example program to find
the factorial of given positive integer
[Link] is the advantage of the union over structure? List any four-string library
functions with the prototype.
[Link] structure and nested structure. Write a program to find out whether the nth term
of the Fibonacci series is a prime number or not. Read the value of n from the user and
display the result in the main function. Uses separate user-defined function to generate
the nth Fibonacci term and to check whether that number is prime or not. [10-marks]

Programs
1. Write a program to accept 10 numbers and print the sum of these numbers
through function.
2. What is structure? Create a structure rectangle with data members length
and breadth.
3. WAP to find sum and average of 10 integer numbers stored in an array.
4. Write a program to find product of two integers using your own function.
5. Write a program using your own function to find sum of two numbers.
6. Write a program to find the value of x y without using POW function.
7. Write a program to find out whether the nth term of the Fibonacci series is a prime
number or not.
8. Write a program to find the second largest number in the given array of
numbers.
9. Write a program to compute the sum of first 10 even numbers using function.

10.
[Link] a structure named book with name, author, and publisher as its
members. Write a program using this structure to read data of 50 books and
display name of those books published by “XYX” publisher.

[Link] a structure “Employee” having Name, Address, Salary, and Age as


member functions. Display the name of the employee having aged between
40 and 50 are living in Kathmandu.

[Link] a structure named course with name,code and credit_hour as its


member. Write a program using this structure using this structure to read
data of 5 courses and display data of those courses with credit_hour greater
than 3.

[Link] a structure named Book with members Book_Name, Price and Author_Name,
then take input for 10 records of Book and print the name of authors having the price of
book greater than 1000.

Pointers
1. Define pointer. Discuss the relationship between pointer and one-dimensional
array.
2. How do you return pointers from functions? Explain with example
3. Explain the use of pointer in C-programming. How can you declare the
pointer? Explain with example.
4.
5. What is dynamic memory allocation? Discuss the use of malloc() in dynamic
memory allocation with example.
6. Explain dynamic memory allocation with example
7. What is dynamic memory allocation? Write a program to find sum and
average of numbers entered from the keyboard using dynamic memory
allocation to create array to store these n numbers.
8. What is the function of a pointer variable? Explain the declaring and
initializing pointers with example.
9. Describe the fundamental concept of pointer and its arithmetic with suitable
examples
[Link] any one advantage and disadvantage of the pointer. How do you pass
pointers as function arguments?

Programs
1. Write a program to accept 10 numbers and soft them with using pointer.
2. Write a program to find sum and average of n numbers entered from the
keyboard using dynamic memory allocation to create array to store these n
numbers.
3. Write a program using pointers to read in an array of integers and print its
elements in reverse order.

File Handling
1. Discuss different file openings modes.
2. Why do we need data files? What are the different file opening modes? Write
a program that reads data from a file "[Link]" and writes to "[Link]"
file. (10-Marks)
3.

Programs
1. Write a program to read the data file which has following details.
a. Name
b. Age
c. Test player
d. Total run.
2. Write a program to read all the numbers from the input file “[Link]” and store
only even numbers in an output file named as “[Link]”.
3. Write a program to read and print data stored in a input file .txt.
4. Write a program that simply reads data from a file.
5. Suppose a file named “[Link]” contains a list of integers. Write a program to
extract the prime numbers only from that file and write them on “[Link]” file.
6.

Graphic
1. Discuss with example any five graphics function used in c-programming.
2. Define the graphics function.
3. Why do we need graphics function?
OR
Explain the use of graphical functions.

4. Write a program to draw a triangle using line() graphics function.


5. Write a program to draw a line using graphics function.
6. Write a program to draw a circle using graphics function. [imp]
7.

Short Notes
1. Graphics function
2. Formatted I/O
3. Documentation
4. Structure
5. Benefits of data files
6. Compilation and execution
7. Operator precedence and associativity
8. Dynamic Memory Allocation
9. break and continue.
[Link] of Computer
[Link] Operator
[Link], Global, and Static variables
[Link] Operator

NOT SURE FROM WHICH CHAPTER


1. Discuss any five string library functions
2. How do you swap the values of two integers without using the third
temporary variable? Justify with the example.
3. Explain the relation to array and pointer. Differentiate call by value and call by reference
with a suitable program.
4. Differentiate between source code and object code.

5. Trace the output

#include<conio.h>
#include<stdio.h>
void main(){
int i =0,k;
for(k=5;k>=0;k–){
i=i+k;
}
printf(“%d\t”,i);
getch();
}

6. Write a program to calculate the factorial of a given number using recursion.


7. Write a program to find the sum of digits of a given integer using recursion.
8. Write a program to check whether the entered word is palindrome or not.

You might also like