C programming
C programming Learning Resources
All study materials, past questions and viva prep in one place.
Problem analysis, Algorithms and Flowchart, Coding, Compilation and Execution, History of C,
C Standards( ANSI C and C99), C Character Set, C Tokens, Escape sequence, Delimiters,
Conversion specification, Reading a character, Writing a character, I/O operations, Formatted
Arithmetic operator, Relational operator, Logical or Boolean operator, Assignment Operator,
Conditional Statements, Decision Making and Branching, Decision Making and Looping, Exit
Introduction to Array, Types of Array (Single Dimensional and Multidimensional), Declaration
Library Functions, User defined functions, Funciton prototype, Function call, and Function
Introduction, Array of structure, Passing structure to function, Passing array of structure to
Introduction, The & and * operator, Declaration of pointer, Chain of Pointers, Pointer
Concept of File, Opening and closing of File, Input Output Operations in File, Random access in
Concepts of Graphics, Graphics Initialization and Modes, Graphics Function
Course Syllabus
C programming — Official Curriculum
Course Description:
This course covers the concepts of structured programming using C programming language.
Course Objectives:
This course is designed to familiarize students to the techniques of programming in C.
Course Contents:
Unit 1: Problem Solving with Computer (2 Hrs.)
Problem analysis, Algorithms and Flowchart, Coding, Compilation and Execution, History of C, Structure of C program, Debugging, Testing and Documentation
Unit 2: Elements of C (4 Hrs.)
C Standards( ANSI C and C99), C Character Set, C Tokens, Escape sequence, Delimiters, Variables, Data types (Basic, Derived, and User Defined), Structure of a C program, Executing a C program, Constants/ Literals, Expressions, Statements and Comments.
Unit 3: Input and Output (2 Hrs.)
Conversion specification, Reading a character, Writing a character, I/O operations, Formatted I/O
Unit 4: Operators and Expression (4 Hrs.)
Arithmetic operator, Relational operator, Logical or Boolean operator, Assignment Operator, Ternary operator, Bitwise operator, Increment or Decrement operator, Conditional operator, Special Operators(sizeof and comma), Evaluation of Expression, Operator Precedence and Associativity.
Unit 5: Control Statement (4 Hrs.)
Conditional Statements, Decision Making and Branching, Decision Making and Looping, Exit function, Break and Continue.
Unit 6: Arrays (6 Hrs.)
Introduction to Array, Types of Array (Single Dimensional and Multidimensional), Declaration and Memory Representation of Array, Initialization of array, Character Array and Strings, Reading and Writing Strings, Null Character, String Library Functions( string length, string copy, string concatenation, string compare)
Unit 7: Functions (5 Hrs.)
Library Functions, User defined functions, Funciton prototype, Function call, and Function Definition, Nested and Recursive Function, Function Arguments and Return Types, Passing Arrays to Function, Passing Strings to Function, Passing Arguments by Value, Passing Arguments by Address, Scope visibility and lifetime of a variable, Local and Global Variable.
Unit 8: Structure and Union (5 Hrs.)
Introduction, Array of structure, Passing structure to function, Passing array of structure to function, Structure within structure ( Nested Structure), Union, Pointer to structure
Unit 9: Pointers (6 Hrs.)
Introduction, The & and * operator, Declaration of pointer, Chain of Pointers, Pointer Arithmetic, Pointers and Arrays, Pointers and Character Strings, Array of Pointers, Pointers as Function Arguments, Function Returning pointers, Pointers and Structures, Dynamic Memory Allocation
Unit 10: File Handling in C (4 Hrs.)
Concept of File, Opening and closing of File, Input Output Operations in File, Random access in File, Error Handling in Files
Unit 11: Introduction to Graphics (3 Hrs.)
Concepts of Graphics, Graphics Initialization and Modes, Graphics Function
Laboratory Works:
This course requires a lot of programming practices. Each topic must be followed by a practical session. Some practical sessions include programming to:
- Create, compile and run simple C programs, handle different data types available in C, perform arithmetic operations in C, perform formatted input and output operations, perform character input and output operations.
- Perform logical operations, create decision making programs, create loops to repeat task.
- Create user-defined functions, create recursive functions, work with automatic, global and static variables, create, manipulate arrays and matrices (single and multidimensional), work with pointes, dynamically allocate de-allocate storage space during runtime, manipulate strings (character arrays) using various string handling functions.
- Create and use structures and files to keep record of students, employees etc.
Text Books:
- Byron Gottfried: “Programming with C,” , Second Edition, McGraw Hill Education.
- Herbert Schildt, C The Complete Reference, Fourth Edition, Osborne/McGrawHill Publication.
Reference Books:
- Brian W. Keringhan, Dennis M. Ritchiem, The C programming Language, Second Edition, PHI Publication.
- Ajay Mittal, Programming in C: A Practical Approach, Pearson Publication
- Stephen G. Kochan, Programming in C, CBS publishers & distributors.
- E. Balagurusamy, Programming in ANSI C, Third Edition, TMH publishing
No videos added yet.
Text Book
Official reference book for C programming
Tribhuvan University
Institute of Science and Technology
Candidates are required to give their answers in their own words as far as practicable.
The figures in the margin indicate full marks.
SECTION A
Answer any two questions.List different types of operators and explain any four of them.
List different types of operators and explain any four of them.
What are the characteristics of array? Write a program to input age of 500 persons and display the following
- Average age
- Age between 25 to 30
What are the characteristics of array? Write a program to input age of 500 persons and display the following
- Average age
- Age between 25 to 30
Differentiate between library function and user defined function. Write a program to swap two values using call by reference concept.
Differentiate between library function and user defined function. Write a program to swap two values using call by reference concept.
SECTION B
Answer any eight questions.
Explain the basic structure of C Programming.
Explain the basic structure of C Programming.
Describe different formatted input and output functions. Why do we use them?
Describe different formatted input and output functions. Why do we use them?
Write a program to display first 50 prime numbers.
Write a program to display first 50 prime numbers.
Write a program to display the following series up to 25 terms but do not print the 7th term. 2 x 3, 3 x 5, 4 x 7, 5 x 9…
Write a program to display the following series up to 25 terms but do not print the 7th term. 2 x 3, 3 x 5, 4 x 7, 5 x 9…
Demonstrate the use of recursive function with a suitable example.
Demonstrate the use of recursive function with a suitable example.
Create a structure called STUDENT with data members SID, name, address, CGPA. Write a program to initialize the value of 100 students and display the information of those students whose address is “KTM” and CGPA is between 3.5 to 4. using C program
Create a structure called STUDENT with data members SID, name, address, CGPA. Write a program to initialize the value of 100 students and display the information of those students whose address is “KTM” and CGPA is between 3.5 to 4. using C program
Explain different file opening modes.
Explain different file opening modes.
Write a program to draw two shapes of your choice using graphics function.
Write a program to draw two shapes of your choice using graphics function.
Write short notes on:
- Global variable
- Debugging
Write short notes on:
- Global variable
- Debugging
Tribhuvan University
Institute of Science and Technology
Candidates are required to give their answers in their own words as far as practicable.
The figures in the margin indicate full marks.
SECTION A
Answer any two questions.Define 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 a separate user-defined function to generate the nth Fibonacci term and to check whether that number is prime or not.
Define 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 a separate user-defined function to generate the nth Fibonacci term and to check whether that number is prime or not.
Explain the relation to array and pointer. Differentiate call by value and call by reference with a suitable program.
Explain the relation to array and pointer. Differentiate call by value and call by reference with a suitable program.
Differentiate between source code and object code. Create 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.
Differentiate between source code and object code. Create 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.
SECTION B
Answer any eight questions.
Describe the different types of I/O functions used in file handling with syntax.
Describe the different types of I/O functions used in file handling with syntax.
Write a program to read P*Q matrix of integers and find the largest integer of each row and display it.
Write a program to read P*Q matrix of integers and find the largest integer of each row and display it.
Write a program to calculate the factorial of a given number using recursion.
Write a program to calculate the factorial of a given number using recursion.
Write a program to check whether the entered word is pallindrome or not.
Write a program to check whether the entered word is pallindrome or not.
List different types of operators and explain any three of them.
List different types of operators and explain any three of them.
Trace the output
#include
#include
void main(){
int i =0,k;
for(k=5;k>=0;k–){
i=i+k;
}
printf(“%d\t”,i);
getch();
}
Trace the output
#include
#include
void main(){
int i =0,k;
for(k=5;k>=0;k–){
i=i+k;
}
printf(“%d\t”,i);
getch();
}
Write a program to compute the sum of first 10 even numbers using function.
Write a program to compute the sum of first 10 even numbers using function.
What is dynamic memory allocation? Explain with a suitable program.
What is dynamic memory allocation? Explain with a suitable program.
Write a program to initialize an array of dimension 10 and sort the numbers within the array in ascending order.
Write a program to initialize an array of dimension 10 and sort the numbers within the array in ascending order.
Tribhuvan University
Institute of Science and Technology
Candidates are required to give their answers in their own words as far as practicable.
The figures in the margin indicate full marks.
SECTION A
Answer any two questions.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 xy without using POW code.
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 xy without using POW code.
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;
}
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;
}
Write 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:
- Find Odd or Even
- Find Positive or Negative
- Find the Factorial value
- Exit
The choice will be displayed until the user will give “D” as a choice.
Write 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:
- Find Odd or Even
- Find Positive or Negative
- Find the Factorial value
- Exit
The choice will be displayed until the user will give “D” as a choice.
SECTION B
Answer any eight questions.
How do you swap the values of two integers without using the third temporary variable? Justify with the example.
How do you swap the values of two integers without using the third temporary variable? Justify with the example.
Write a program to find the sum of digits of a given integer using recursion.
Write a program to find the sum of digits of a given integer using recursion.
Differentiate between constant and literals. Why do we need to define the type of data?
Differentiate between constant and literals. Why do we need to define the type of data?
Write a program to find the second largest number in the given array of numbers.
Write a program to find the second largest number in the given array of numbers.
Create 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.
Create 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.
List any one advantage and disadvantage of the pointer. How do you pass pointers as function arguments?
List any one advantage and disadvantage of the pointer. How do you pass pointers as function arguments?
Suppose a file named “Num.txt” contains a list of integers. Write a program to extract the prime numbers only from that file and write them on “Prime.txt” file.
Suppose a file named “Num.txt” contains a list of integers. Write a program to extract the prime numbers only from that file and write them on “Prime.txt” file.
What is the advantage of the union over structure? List any four-string library functions with the prototype.
What is the advantage of the union over structure? List any four-string library functions with the prototype.
Write short notes on
- Local, Global, and Static variables
- Conditional Operator
Write short notes on
- Local, Global, and Static variables
- Conditional Operator
Tribhuvan University
Institute of Science and Technology
Candidates are required to give their answers in their own words as far as practicable.
The figures in the margin indicate full marks.
SECTION A
Answer any two questions.What do you mean by jump statement? Explain each jump statement with example. Write a program to check whether a number entered is prime or not.
What do you mean by jump statement? Explain each jump statement with example. Write a program to check whether a number entered is prime or not.
Explain any three string functions. Write a program to check if two matrices are identical or act.
Explain any three string functions. Write a program to check if two matrices are identical or act.
Define structure. Explain nested structure with example. Create 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.
Define structure. Explain nested structure with example. Create 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.
SECTION B
Answer any eight questions.
Discuss structure of a C Program with suitable example.
Discuss structure of a C Program with suitable example.
What is variable? How is it different from constant? How do you write comments in c?
What is variable? How is it different from constant? How do you write comments in c?
Explain formatted I/O functions in detail.
Explain formatted I/O functions in detail.
Write a program using your own function to find sum of two numbers
Write a program using your own function to find sum of two numbers
Write a program to print largest among three numbers entered by the user.
Write a program to print largest among three numbers entered by the user.
Explain dynamic memory allocation with example
Explain dynamic memory allocation with example
Write a program that simply reads data from a file
Write a program that simply reads data from a file
Write a program to draw a line using graphics function.
Write a program to draw a line using graphics function.
Write short notes on:
- History of C
- Bitwise Operator
Write short notes on:
- History of C
- Bitwise Operator
Tribhuvan University
Institute of Science and Technology
Candidates are required to give their answers in their own words as far as practicable.
The figures in the margin indicate full marks.
SECTION A
Answer any two questions.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.
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.
What is structure? How is it different from union? Create a structure named course with name, code, and credit_hour as its members. Write a program using this structure to read data of 5courses and display data of those curses with credit_hour greater than 3.
What is structure? How is it different from union? Create a structure named course with name, code, and credit_hour as its members. Write a program using this structure to read data of 5courses and display data of those curses with credit_hour greater than 3.
What is structure? How is it different from union? Create a structure named course with name, code, and credit_hour as its members. Write a program using this structure to read data of courses and display data of those curses with credit_hour greater than 3.
What is structure? How is it different from union? Create a structure named course with name, code, and credit_hour as its members. Write a program using this structure to read data of courses and display data of those curses with credit_hour greater than 3.
SECTION B
Answer any eight questions.
Explain flowchart with example. What are the benefits of using flowcharts?
Explain flowchart with example. What are the benefits of using flowcharts?
What is data type? Why do we need it in programming? Explain any three basic data types with example.
What is data type? Why do we need it in programming? Explain any three basic data types with example.
What do you mean by unformatted I/O? Explain
What do you mean by unformatted I/O? Explain
Write a program to display first n prime numbers.
Write a program to display first n prime numbers.
Write a program to find product of two integers using your own function.
Write a program to find product of two integers using your own function.
Define pointer. Flow to you return pointers from functions? Explain with example.
Define pointer. Flow to you return pointers from functions? Explain with example.
Explain different file I/O functions with example.
Explain different file I/O functions with example.
Write a program to draw a circle using graphics function
Write a program to draw a circle using graphics function
Write short notes On
- Compilation and execution
- Operator precedence and associativity
Write short notes On
- Compilation and execution
- Operator precedence and associativity
Viva Questions
Click any question to reveal the answer.
What is problem solving in programming and what are its steps?
What is the structure of a C program?
What are tokens in C? Explain types.
What are data types in C?
Explain formatted input and output in C.
What is operator precedence and why is it important?
Explain different types of control statements in C.
What is an array and how is it stored in memory?
What is a string in C and how is it represented?
What is a function? Explain types of functions in C.
What is recursion? Give an example.
Differentiate between structure and union.
What is a pointer and why is it used?
Explain dynamic memory allocation in C.
What is file handling in C?