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

C Programming Semester 1 Question Paper

The document contains questions about C programming for a course. It has multiple choice and long answer questions testing knowledge of keywords, variables, loops, data types, and operators in C.

Uploaded by

suganya devi
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)
502 views1 page

C Programming Semester 1 Question Paper

The document contains questions about C programming for a course. It has multiple choice and long answer questions testing knowledge of keywords, variables, loops, data types, and operators in C.

Uploaded by

suganya devi
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

Branch:CSE/CS/IT Year / Sem : I /02 [Link]: Branch:CSE/CS/IT Year / Sem : I /02 Reg.

no:
Course Code/Name: CS3251/PROGRAMMING IN C Marks: 50 Course Code/Name: CS3251/PROGRAMMING IN C Marks: 50
PART – A PART – A
ANSWER ALL THE QUESTIONS (05X02 = 10marks) ANSWER ALL THE QUESTIONS (05X02 = 10marks)

1. Write a short notes on keywords in C language. 1. Write a short notes on keywords in C language.
2. What are the types of variables? 2. What are the types of variables?
3. What is the use of preprocessor directive? 3. What is the use of preprocessor directive?
4. Difference between while and do-while looping statements? 4. Difference between while and do-while looping statements?
5. What are the two ways to define constants in C? 5. What are the two ways to define constants in C?

PART –B (2*13 = 26 Marks) PART –B (2*13 = 26 Marks)


6. a) Elaborate the various Datatypes in C with suitable examples. 6. a) Elaborate the various Datatypes in C with suitable examples.

(OR) (OR)

b).Enumerate the difference between ‘else-if-ladder’ and ‘switch-case’ b).Enumerate the difference between ‘else-if-ladder’ and ‘switch-case’
statements with appropriate C program. statements with appropriate C program.

7. a) Explain the looping statements in C with suitable examples. 7. a) Explain the looping statements in C with suitable examples.

(OR) (OR)

b) Draw the structure of C program and explain each part in detail. b) Draw the structure of C program and explain each part in detail.

PART-C PART-C

ANSWER ALL THE QUESTIONS ( 1*14 = 14 Marks) ANSWER ALL THE QUESTIONS ( 1*14 = 14 Marks)

8. Explain the various types of operators with simple C program. 8. Explain the various types of operators with simple C program.

Common questions

Powered by AI

Constants in C can be defined using #define preprocessor directive or the 'const' keyword. #define allows for a macro substitution before compilation, while 'const' ensures the value cannot be changed after initialization . Using constants is important for maintaining code clarity and integrity, preventing accidental modifications to values that should remain unchanged throughout the program .

Keywords in C serve as reserved words with special meanings, which are predefined in the language. They cannot be used as identifiers for variables, functions, or any other user-defined items . This restriction ensures consistency and aids in structuring the code by differentiating the language's core constructs from custom identifiers .

Variables in C are essential for storing data values that can be manipulated throughout program execution. They hold different types of data, provide temporary storage, allow for the execution of operations, and contribute to dynamic data handling . By using variables, programmers can efficiently manage complex data operations and support various types of interactions within a program .

Understanding operators in C is crucial for writing efficient code as they determine the operations performed on variables and the manner of data manipulation. Basic operators include arithmetic operators (e.g., +, -, *, /), relational operators (e.g., ==, !=), logical operators (e.g., &&, ||), and bitwise operators (e.g., &, |, ^). Mastery of these operators allows a programmer to perform complex expressions and streamline the execution flow, significantly enhancing program efficiency .

The structure of a C program includes the defining of a main function, declaration of variables, inclusion of headers, and definition of functions. Headers introduce predefined functions, variables are declared for data storage, and functions house executable code . Understanding this hierarchy aids in compiling the code by ensuring all elements are recognized by the compiler and executed in a logical sequence .

Data types in C define the type and size of data that can be stored in variables, aiding in efficient memory allocation. By declaring specific data types, memory is allocated appropriately, avoiding wastage of space and ensuring that operations on data are carried out correctly . This precision in data management contributes to both performance optimization and error prevention in programming .

Both 'while' and 'do-while' loops facilitate repeated execution of a block of code based on a boolean condition. However, 'while' checks the condition before executing the loop body, meaning it may not execute at all if the condition is false initially . In contrast, 'do-while' executes the loop body once before checking the condition, ensuring it runs at least once .

Looping statements such as 'for', 'while', and 'do-while' enable a programmer to efficiently handle repetitive tasks by executing a block of code multiple times under specific conditions. By ensuring tasks like iterations over arrays or executing operations until a condition is met, loops save both time and resources . Proper use minimizes redundancy, streamlines code management, and speeds up execution .

The 'else-if-ladder' is a series of if-else statements that execute different blocks of code based on the evaluation of expressions. It is suitable for checking multiple conditions that might involve more complex and varied logic . On the other hand, 'switch-case' statements are used for simpler scenarios where one variable is compared against a set of constants. This structure is more efficient when multiple conditions depend on a single variable, as it is easier to read and execute .

Preprocessor directives are commands in C that instruct the compiler to process certain actions before actual compilation begins. These directives can include file inclusion, macro definitions, conditional compilation, and line control . By defining these actions beforehand, they enhance program functionality by allowing code modularity, easier maintenance, and conditional code inclusion .

You might also like