0% found this document useful (0 votes)
17 views1 page

C Programming Internal Assessment 2024

Very nice

Uploaded by

mitha9008
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)
17 views1 page

C Programming Internal Assessment 2024

Very nice

Uploaded by

mitha9008
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

Government College of Engineering, Salem-11

(An Autonomous Institution Affiliated to Anna University, Chennai)


Internal Assessment Test - 1
ELECTRONICS AND COMMUNICATION ENGINEERING
Year/Semester: I/I Regulation:2022 Batch: 2024-2028 Date&Session:20.11.2024 &FN
22CS101 – Problem Solving and C Programming
Time : 2 Hours Maximum Marks: 40
Part A (4 x 2 = 08 Marks)

Answer ALL Questions BTL M CO

1. Define problem-solving and its significance in programming. R 2 CO1

2. What is a variable in C? Provide an example. U 2 CO1

3. Write a C program using a for loop to print the multiplication table A 2 CO2
of a given number.

4. Illustrate the usage of the switch statement with an example program A 2 CO2

5. Describe how to initialize an array in C U 2 CO3

6. Identify the syntax for declaring an integer array in C R 2 CO3

*****ALL THE BEST*****

Part B (2 x 16 = 32 Marks)
Answer ALL Questions BTL M CO

7. i) Examine the basic data types in C and illustrate with AN 8 CO1


examples of variable declarations for each type.

ii) Compare while and do-while loops in C, and illustrate with AN 8 CO2
examples

8. i) Write a C program to simulate a banking system with the AN 8 CO2


following functionalities: Create an account (Name, Account
Number, Balance), Deposit money, withdraw money (ensure
sufficient balance) & Display account details.

ii) Write a C program to sort an array in ascending order using AN 8 CO3


bubble sort, and explain the steps.

Common questions

Powered by AI

An integer array is preferred when dealing with a fixed-sized collection of integer elements requiring index-based access. With direct memory access and contiguous storage, it is optimal for scenarios requiring high-speed computations and minimal memory overhead, such as mathematical computations or when interfacing with memory-mapped hardware .

Loops in C, including for, while, and do-while, repeatedly execute code as long as a condition holds true, drastically reducing the need for code repetition and allowing for efficient traversals over data structures. They form fundamental constructs ensuring that programs are both flexible and efficient, enabling developers to handle repetitive tasks dynamically with minimal code .

The primary difference between while and do-while loops is that a while loop evaluates the condition before executing the loop body, while a do-while loop executes the loop body at least once before checking the condition. For instance, in a while loop: 'while(condition) { /* code */ }', the code executes only if the condition is true. However, in a do-while loop: 'do { /* code */ } while(condition);', the code executes once regardless of the condition, and continues if the condition remains true .

In C, arrays can be initialized using list initialization, such as 'int arr[3] = {1, 2, 3};', or iteratively through a loop. Proper initialization is crucial as it ensures that arrays start with defined values, preventing undefined behavior and logical errors from uninitialized data, which can lead to unpredictable runtime results .

Bubble sort iteratively compares adjacent elements and swaps them if they are in the wrong order, repeatedly passing through the list until it is sorted. Key steps include setting a flag to determine swaps, iterating over the array n-1 times (where n is the array size), performing swaps whenever two adjacent elements are out of order, and continuing the process until a complete pass requires no swaps .

Problem-solving is essential in programming as it aids in understanding and framing complex issues into manageable problems, crafting algorithms to solve these systematically. It influences the development process by guiding the logical structuring of code, optimizing solutions for efficiency, and ensuring robust functionality of software by foreseeing possible errors and creating mitigation strategies .

In C, a variable is a storage location identified by a memory address and an associated symbolic name (an identifier), which contains data that can be modified during program execution. For example: 'int count = 10;' initializes an integer variable named 'count' with the value 10. Variables enable dynamic data handling, essential for computational tasks in programming .

A C program simulating a banking system could create an account by structuring it to hold a customer's name, account number, and balance. Functions would manage deposits by adding to balance, ensuring sufficient balance for withdrawals, and display account details with printf statements. Typically, such a system uses a structure to organize account information and functions to execute operations on these structures .

A switch statement in C executes one block of code from many based on the value of a single variable or expression. For example, this structure evaluates 'int option;' to execute associated cases: 'switch(option) { case 1: printf("Choice 1"); break; case 2: printf("Choice 2"); break; default: printf("Invalid"); }'. Each 'case' represents a potential match to 'option's value, with execution continuing until 'break' or reaching the end of the switch .

C programming includes basic data types such as int, float, char, and double. Each is used to define variables that can store different types of data. For example, 'int age;' declares an integer variable, 'float temperature;' declares a float for decimal values, 'char initial;' for character data, and 'double precision;' for double-precision floating-point numbers . These types provide a fundamental basis for creating more complex data structures and operations in programming.

You might also like