TCS-101 Programming B. Tech Exam

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Write the purpose of an operating system?

An operating system (OS) manages computer hardware and software resources and provides common services for computer programs.

A Source program usually in which language?

High-level language.

Give the range of values that can be stored by int data type in C?

The range of values that can be stored by an int data type in C is typically from -32,768 to 32,767 (for a 16-bit int) or -2,147,483,648 to 2,147,483,647 (for a 32-bit int).

How is an array initialized in C language?

<p>In C, an array can be initialized at the time of declaration by providing a list of values enclosed in curly braces <code>{}</code>. For example: <code>int arr[5] = {1, 2, 3, 4, 5};</code></p> Signup and view all the answers

Find out the output of the following code snippet:

int main() { int sum=2+4/2+6*2; printf("%d",sum) ; return0; }

<p>16</p> Signup and view all the answers

Write the disadvantage of arrays in C?

<p>A disadvantage of arrays in C is that they have a fixed size, which must be determined at compile time.</p> Signup and view all the answers

Write the return type of the open() function in C?

<p>The return type of the <code>open()</code> function in C is <code>int</code>.</p> Signup and view all the answers

Find out the output of the following code:

void main() { int i; for (i+1;i<=10;i++) printf("%d\n",i); }

<p>The loop will not execute because <code>i+1</code> is not an assignment, so <code>i</code> is uninitialized and has some garbage value. Otherwise, if <code>i</code> was initilized to 0, then the loop would print numbers from 0 to 9.</p> Signup and view all the answers

Write the types of functions in C language?

<p>The types of functions in C language are library functions and user-defined functions.</p> Signup and view all the answers

Comment on this const int *ptr;

<p><code>const int *ptr</code> declares a pointer <code>ptr</code> to a constant integer. The integer value that <code>ptr</code> points to cannot be modified through this pointer.</p> Signup and view all the answers

List out the return type of malloc() or calloc().

<p>The return type of <code>malloc()</code> and <code>calloc()</code> is <code>void *</code>.</p> Signup and view all the answers

Write the return value of putchar().

<p>The return value of <code>putchar()</code> is the character written, as an <code>unsigned char</code> converted to an <code>int</code>, or <code>EOF</code> on error.</p> Signup and view all the answers

List the different data types in C.

<p>The basic data types in C are <code>int</code>, <code>float</code>, <code>char</code>, <code>double</code>, and <code>void</code>.</p> Signup and view all the answers

Define the variable. Illustrate with an example.

<p>A variable is a named storage location in the computer's memory that can hold a value. For example, <code>int age = 25;</code> declares an integer variable named <code>age</code> and initializes it with the value 25.</p> Signup and view all the answers

Differentiate between a for loop and a while loop? What are its uses?

<p>A <code>for</code> loop is typically used when the number of iterations is known in advance, while a <code>while</code> loop is used when the number of iterations is not known and depends on a condition. A <code>for</code> loop includes initialization, condition, and increment/decrement in its syntax, whereas a <code>while</code> loop only contains a condition.</p> Signup and view all the answers

Explain the decision-making statement in C.

<p>Decision-making statements in C, such as <code>if</code>, <code>else if</code>, and <code>else</code>, allow the program to execute different blocks of code based on whether a condition is true or false.</p> Signup and view all the answers

Differentiate between Array and Pointers?

<p>An array is a contiguous block of memory locations that store elements of the same data type, while a pointer is a variable that stores the memory address of another variable. Arrays are fixed in size, whereas pointers can be dynamically allocated memory.</p> Signup and view all the answers

Differentiate between malloc and calloc?

<p><code>malloc</code> allocates a block of memory of the specified size but does not initialize it, whereas <code>calloc</code> allocates a block of memory for an array of elements, initializes all bytes to zero.</p> Signup and view all the answers

How to declare a members in Structure?

<p>Members in a structure are declared inside the structure definition using data types and member names. For example:</p> <pre><code class="language-c">struct Person { char name[50]; int age; float salary; }; </code></pre> Signup and view all the answers

Write short notes on fseek().

<p><code>fseek()</code> is used to seek to a specific position in a file stream.</p> Signup and view all the answers

Explain the various Storage classes in C in detail.

<p>Storage classes in C define the scope, visibility, and lifetime of variables and functions. The storage classes are <code>auto</code>, <code>extern</code>, <code>static</code>, and <code>register</code>.</p> Signup and view all the answers

Explain the Structure of a C program in detail.

<p>A C program typically consists of preprocessor directives, global declarations, the <code>main()</code> function, and other user-defined functions. The <code>main()</code> function is the entry point of the program.</p> Signup and view all the answers

Difference between CALL by Value and CALL by Address with example.

<p>In call by value, the value of the actual arguments is copied to the formal arguments of the function. Any changes made to the formal arguments inside the function do not affect the actual arguments. In call by address, the memory address of the actual arguments is passed to the formal arguments. Changes made to the formal arguments inside function do reflect in the actual arguments.</p> Signup and view all the answers

Explain the concept of files with examples.

<p>In C, files are used to store and retrieve data from storage devices. A file is opened using <code>fopen()</code>, read/written using functions like <code>fread()</code>, <code>fwrite()</code>, <code>fprintf()</code>, and closed using <code>fclose()</code>.</p> Signup and view all the answers

Flashcards

Operating System

Software that manages computer hardware and provides services for applications.

Source Program

Human-readable form of a program, typically written in a high-level language.

Arrays Disadvantage

Arrays use contiguous memory locations

Functions

Functions are named blocks of code that perform specific tasks, promoting modularity and reusability.

Signup and view all the flashcards

Variable

Variables are named storage locations that hold values, allowing data to be manipulated and stored during program execution.

Signup and view all the flashcards

Storage Classes

Storage classes define the scope, lifetime, and visibility of variables and functions within a program.

Signup and view all the flashcards

Call by Value vs. Call by Address

Call by value passes a copy of the variable. Call by address passes a pointer to the original variable, allowing modifications to the original value.

Signup and view all the flashcards

String

A data type representing sequences of characters.

Signup and view all the flashcards

fseek() function

fseek() is a function used in C to change the file pointer position of a specified stream. It allows the programmer to move to a specific part of the file for reading or writing data.

Signup and view all the flashcards

Study Notes

  • The exam is TCS-101 Programming for Problem Solving in B. Tech (First Semester)
  • The exam is in three hours with a maximum of 60 marks

Section A: Very Short Answer Questions

  • Each question in this section is worth 1 mark
  • A question asks for the purpose of an operating system
  • A question asks to state the language of a source program
  • A question asks for the range of values that can be stored by the int data type
  • A question asks how to initialize an array in C language
  • A question asks for the output of a given code snippet
  • A question asks to note the disadvantage of arrays in C
  • A question asks for the return type of the open() function in C
  • A question asks for the output of a given code
  • A question asks for the types of functions in the C language
  • A question asks to comment on const int*ptr
  • A question asks for the return type of malloc() or calloc()
  • A question asks for the return value of putchar()

Section B: Short Answer Type Questions

  • Each question in this section is worth 4 marks
  • A question asks to list the different data types in C, or define a variable and illustrate with an example
  • A question asks to write a program to find the greatest of three numbers, or write a program to determine if a given number is even or odd
  • A question asks to differentiate between a for loop and a while loop and their uses, or explain the decision making statement in C
  • A question asks to differentiate between arrays and pointers, or write a program to find the average of n numbers using arrays
  • A question asks to differentiate between malloc and calloc, or how to declare a member in a structure
  • A question asks to write short notes on fseek(), or write a program to accept a string and display it in reverse

Section C: Long Answer Type Questions

  • Each question in this section is worth 8 marks
  • A question asks to explain the various storage classes in C in detail, or explain the structure of a C program in detail
  • A question asks to write the difference between CALL by value and CALL by address with an example, or write a program to implement multiplication of 2 matrices
  • A question asks to explain the concept of files with examples, or write a program to COPY one file's contents into another

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser