0% found this document useful (0 votes)
9 views

C Assignment (2)

The document contains a comprehensive list of short and long questions related to the C programming language, covering topics such as variables, loops, memory management, functions, and file handling. Additionally, it includes programming exercises that require the implementation of various algorithms and data structures in C. This resource is aimed at enhancing understanding and practical skills in C programming.

Uploaded by

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

C Assignment (2)

The document contains a comprehensive list of short and long questions related to the C programming language, covering topics such as variables, loops, memory management, functions, and file handling. Additionally, it includes programming exercises that require the implementation of various algorithms and data structures in C. This resource is aimed at enhancing understanding and practical skills in C programming.

Uploaded by

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

Purbanchal University, Biratnagar

Short Questions

1.​ What is a variable in C?


2.​ Differentiate between local and global variables.
3.​ What is the purpose of the sizeof operator in C?
4.​ Explain the difference between ++i and i++.
5.​ What are the different types of loops available in C?
6.​ How do you declare a pointer variable in C?
7.​ What is the purpose of the const keyword in C?
8.​ Explain the difference between scanf() and printf() functions.
9.​ What is the significance of the void keyword in C?
10.​How do you allocate memory dynamically in C?
11.​How do you define a multi-dimensional array in C?
12.​Explain the purpose of the typedef keyword in C.
13.​Differentiate between strcmp() and strncmp() functions.
14.​What is the significance of the static keyword in C?
15.​What is the difference between malloc() and calloc() in C?
16.​Explain the difference between while and do-while loops in C.
17.​What is the purpose of the break statement in a switch statement in C?

Long Questions

1.​ Describe the process of declaring and defining a function in C.


2.​ Explain the difference between pass by value and pass by reference in function
arguments.
3.​ Discuss the concept of pointers in C, including pointer arithmetic and pointer
dereferencing.
4.​ How do you handle memory leaks in C programs? Explain with examples.
5.​ Describe the working of the switch statement in C with suitable examples.
6.​ Discuss the various file handling functions available in C, including fopen(),
fclose(), fread(), and fwrite().
7.​ What is recursion? How is it implemented in C? Provide an example.
8.​ Discuss the different storage classes in C, including auto, register, static,
and extern.
9.​ Describe the concept of arrays in C, including one-dimensional and
multi-dimensional arrays.

Er. Santosh Sah​ ​ ​ ​ ​ ​ www.santoshsah.com.np


Purbanchal University, Biratnagar

10.​Explain the role of the #define preprocessor directive in C.


11.​Describe the working of the do-while loop in C with an example.
12.​Discuss the steps involved in dynamic memory allocation in C. Explain the roles
of malloc(), calloc(), and realloc() functions. Provide examples
demonstrating the allocation and deallocation of memory using these functions.
Discuss potential issues like memory leaks and how to avoid them.
13.​Describe the process of reading and writing text files in C. Explain how to open a
text file, read its contents line by line, and write data to it. Discuss the usage of
functions such as fopen(), fclose(), fgets(), and fputs() in file handling.
Provide examples illustrating error handling and best practices when working
with text files.
14.​Explain the concept of arrays and pointers in C and how they are related. Discuss
how arrays are stored in memory and how pointers can be used to access array
elements. Provide examples demonstrating the relationship between arrays and
pointers, including array-to-pointer decay and pointer arithmetic.
15.​Discuss the role of the struct keyword in C and how it is used to define
user-defined data types. Explain how to declare and initialize structures, access
structure members, and pass structures to functions. Provide examples
illustrating the usage of structures in organizing and manipulating related data.

Programming Questions

1.​ Write a C program to find the factorial of a given number using recursion.
2.​ Implement a function in C to check if a given string is a palindrome or not.
3.​ Implement a C program to calculate the sum of all elements in an array.
4.​ Write a function in C to reverse a given integer number.
5.​ Create a program in C to find the largest element in an array.
6.​ Implement a C program to convert a decimal number to binary.
7.​ Write a C program to calculate the power of a number using recursion.
8.​ Create a program in C to find the Fibonacci series up to a given term.
9.​ Implement a function in C to compute the factorial of a number using iteration
(without recursion).
10.​ Write a program in C to find the sum of all prime numbers within a given range.
11.​Implement a function in C to reverse a given string without using any library
functions.
12.​Write a program to check if a given number is Armstrong or not.
13.​Implement a C program to find the factorial of a large number using arrays.
14.​Write a program to merge two sorted arrays into a single sorted array in C.

Er. Santosh Sah​ ​ ​ ​ ​ ​ www.santoshsah.com.np


Purbanchal University, Biratnagar

15.​Create a C program to implement a simple calculator that can perform addition,


subtraction, multiplication, and division operations.
16.​Implement a C program to find the transpose of a matrix.
17.​Write a program to check if a given string is an anagram of another string.
18.​Create a C program to find the GCD (Greatest Common Divisor) of two numbers
using recursion.
19.​Develop a C program to convert temperature from Celsius to Fahrenheit and vice
versa, based on user input.
20.​Write a C program to calculate the sum of all even numbers from 1 to n, where n
is provided by the user.

Er. Santosh Sah​ ​ ​ ​ ​ ​ www.santoshsah.com.np

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy