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

Document

The document provides a comprehensive overview of programming concepts, including definitions of programming, algorithms, and flowcharts. It covers arrays, functions, structures, and file handling in C, with examples and explanations of key topics such as call by value and call by reference. Additionally, it offers study tips for mastering the material.

Uploaded by

Mahnoor Naeem
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)
14 views8 pages

Document

The document provides a comprehensive overview of programming concepts, including definitions of programming, algorithms, and flowcharts. It covers arrays, functions, structures, and file handling in C, with examples and explanations of key topics such as call by value and call by reference. Additionally, it offers study tips for mastering the material.

Uploaded by

Mahnoor Naeem
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
You are on page 1/ 8

1.

Theory (10-15 Marks)

Possible Questions:

1. What is programming?

Answer: Programming is the process of creating a set of instructions that tell


a computer how to perform a task. It involves writing, testing, debugging,
and maintaining code in a specific programming language.

2. Define algorithms and flowcharts.

Answer:

Algorithm: A step-by-step procedure to solve a problem.

Flowchart: A diagrammatic representation of an algorithm using symbols.

3. Array/String/Insertion (10-15 Marks)


Possible Questions:

1. Explain arrays and their types.

Answer: An array is a collection of elements of the same type stored in


contiguous memory locations. Types include:

1D Array (e.g., int arr[5];)

2D Array (e.g., int matrix[3][3];)

2. Write a program to insert an element into an array.

#include <stdio.h>

Int main() {

Int arr[100] = {1, 2, 3, 4, 5}, n = 5, pos = 2, newElem = 10;

For (int i = n; i ≥ pos; i--)

Arr[i] = arr[i – 1];

Arr[pos – 1] = newElem; n++;

For (int i = 0; i < n; i++)

Printf(“%d “, arr[i]);

Return 0;

}
3. Functions and Function Parameter Passing (10-15 Marks)

Possible Questions:

1. What is the difference between call by value and call by reference?

Answer:

Call by Value: A copy of the actual parameter is passed to the function.


Changes don’t affect the original value.

Call by Reference: The actual parameter address is passed. Changes affect


the original value.

2. Write a function to calculate the factorial of a number.

#include <stdio.h>

Int factorial(int n) {

If (n == 0) return 1;

Return n * factorial(n – 1);

Int main() {

Int num = 5;
Printf(“Factorial: %d”, factorial(num));

Return 0;

3. Structures, Arrays of Structures, Unions, Parameter Passing (10-20


Marks)

Possible Questions:

1. What is a structure? Write an example.

Answer: A structure is a user-defined data type that groups different data


types. Example:

Struct Student {

Int id;

Char name[50];

Float marks;

};

2. Write a program to store and display details of students using an array


of structures.
#include <stdio.h>

Struct Student {

Int id;

Char name[50];

Float marks;

};

Int main() {

Struct Student students[2];

For (int i = 0; i < 2; i++) {

Printf(“Enter ID, Name, Marks: “);

Scanf(“%d %s %f”, &students[i].id, students[i].name,


&students[i].marks);

For (int i = 0; i < 2; i++) {

Printf(“ID: %d, Name: %s, Marks: %.2f\n”, students[i].id,


students[i].name, students[i].marks);

Return 0;

4. File Handling (3-8 Marks)


Possible Questions:

1. Explain file handling in C.

Answer: File handling in C is used to create, read, write, and modify files.
Common file functions are:

Fopen(): Opens a file.

Fprintf(): Writes to a file.

Fscanf(): Reads from a file.

Fclose(): Closes a file.

2. Write a program to write and read data from a file.

#include <stdio.h>

Int main() {

FILE *fptr;

Fptr = fopen(“file.txt”, “w”);

Fprintf(fptr, “Hello, File Handling!”);

Fclose(fptr);

Fptr = fopen(“file.txt”, “r”);

Char str[100];
Fscanf(fptr, “%[^\n]”, str);

Printf(“Data: %s”, str);

Fclose(fptr);

Return 0;

Study Tips:

1. Understand Theory: Memorize definitions and differences.

2. Practice Programming: Write and run small programs for arrays,


structures, functions, and file handling.

3. Focus on Important Topics: Arrays, functions, and file handling are


frequently asked.

Let me know if you need further clarification!

You might also like