0% found this document useful (0 votes)
597 views17 pages

Viva Questions

The document contains 22 questions related to C programming and data structures asked during a lab viva. It covers basic data types in C, static variables, functions and pointers, array concepts, structure, call by value vs call by reference and more. The questions aim to evaluate the student's understanding of core C programming concepts and data structures.

Uploaded by

Dr. SATHIYA M
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)
597 views17 pages

Viva Questions

The document contains 22 questions related to C programming and data structures asked during a lab viva. It covers basic data types in C, static variables, functions and pointers, array concepts, structure, call by value vs call by reference and more. The questions aim to evaluate the student's understanding of core C programming concepts and data structures.

Uploaded by

Dr. SATHIYA M
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/ 17

KARPAGAM INSTITUTE OF TECHNOLOGY

COIMBATORE – 641 105

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


ACADEMIC YEAR: 2022 - 2023 (ODD SEMESTER)
Regulations 2021
CS3362 C Programming and Data Structures Laboratory

Data Structures Lab Viva Questions


Q1. What are the basic Datatypes supported in C Programming Language?
Ans: The Datatypes in C Language are broadly classified into 4 categories. They are as follows:
 Basic Datatypes
 Derived Datatypes
 Enumerated Datatypes
 Void Datatypes
The Basic Datatypes supported in C Language are as follows:
Datatype Name Datatype Size Datatype Range
short 1 byte -128 to 127
unsigned short 1 byte 0 to 255
char 1 byte -128 to 127
unsigned char 1 byte 0 to 255
int 2 bytes -32,768 to 32,767
unsigned int 2 bytes 0 to 65,535
-2,147,483,648 to
long 4 bytes
2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295
float 4 bytes 3.4E-38 to 3.4E+38
double 8 bytes 1.7E-308 to 1.7E+308
long double 10 bytes 3.4E-4932 to 1.1E+4932
 
Q2. What do you mean by Dangling Pointer Variable in C Programming?
 Ans: A Pointer in C Programming is used to point the memory location of an existing variable. In
case if that particular variable is deleted and the Pointer is still pointing to the same memory location,
then that particular pointer variable is called as a Dangling Pointer Variable.

 Q3. What do you mean by the Scope of the variable? What is the scope of the variables in C?
Ans: Scope of the variable can be defined as the part of the code area where the variables declared in
the program can be accessed directly. In C, all identifiers are lexically (or statically) scoped. 

Q4. What are static variables and functions?


Ans: The variables and functions that are declared using the keyword Static are considered as Static
Variable and Static Functions. The variables declared using Static keyword will have their scope
restricted to the function in which they are declared.
 
Q5. Differentiate between calloc() and malloc()
Ans: calloc() and malloc() are memory dynamic memory allocating functions. The only difference
between them is that calloc() will load all the assigned memory locations with value 0 but malloc()
will not.
 
Q6. What are the valid places where the programmer can apply Break Control Statement?
Ans: Break Control statement is valid to be used inside a loop and Switch control statements.
 
Q7. How can we store a negative integer?
 Ans: To store a negative integer, we need to follow the following steps. Calculate the two’s
complement of the same positive integer.
Eg: 1011 (-5)
Step-1 − One’s complement of 5: 1010
Step-2 − Add 1 to above, giving 1011, which is -5
 
Q8. Differentiate between Actual Parameters and Formal Parameters.
 Ans: The Parameters which are sent from main function to the subdivided function are called as
Actual Parameters and the parameters which are declared a the Subdivided function end are called
as Formal Parameters.
 
Q9. Can a C program be compiled or executed in the absence of a main()?
Ans: The program will be compiled but will not be executed. To execute any C program, main() is
required.
 
Q10. What do you mean by a Nested Structure?
Ans: When a data member of one structure is referred by the data member of another function, then
the structure is called a Nested Structure.
 
Q11. What is a C Token?
Ans: Keywords, Constants, Special Symbols, Strings, Operators, Identifiers used in C program are
referred to as C Tokens.
 
Q12. What is Preprocessor?
Ans: A Preprocessor Directive is considered as a built-in predefined function or macro that acts as a
directive to the compiler and it gets executed before the actual C Program is executed.
In case you are facing any challenges with these C Programming Interview Questions, please write
your problems in the comment section below.

Q13. Why is C called the Mother of all Languages?


Ans: C introduced many core concepts and data structures like arrays, lists, functions, strings, etc.
Many languages designed after C are designed on the basis of C Language. Hence, it is considered as
the mother of all languages.
 
Q14. Mention the features of C Programming Language.
Ans: 
 

 
 
Q15. What is the purpose of printf() and scanf() in C Program?
Ans: printf() is used to print the values on the screen. To print certain values, and on the other hand,
scanf() is used to scan the values. We need an appropriate datatype format specifier for both printing
and scanning purposes. For example,
 %d: It is a datatype format specifier used to print and scan an integer value.
 %s: It is a datatype format specifier used to print and scan a string.
 %c: It is a datatype format specifier used to display and scan a character value.
 %f: It is a datatype format specifier used to display and scan a float value.
 
Q16. What is an array?
Ans. The array is a simple data structure that stores multiple elements of the same datatype in a
reserved and sequential manner. There are three types of arrays, namely,
 One Dimensional Array
 Two Dimensional Array
 Multi-Dimensional Array
 
Q17. What is /0 character?
Ans: The Symbol mentioned is called a Null Character. It is considered as the terminating character
used in strings to notify the end of the string to the compiler.
 
Q18. What is the main difference between the Compiler and the Interpreter?
Ans: Compiler is used in C Language and it translates the complete code into the Machine Code in
one shot. On the other hand, Interpreter is used in Java Programming Langauge and other high-end
programming languages. It is designed to compile code in line by line fashion.
 
Q19. Can I use int datatype to store 32768 value?
Ans: No, Integer datatype will support the range between -32768 and 32767. Any value exceeding
that will not be stored. We can either use float or long int.

Q20. How is a Function declared in C Language?


Ans: A function in C language is declared as follows,
return_type function_name(formal parameter
1
list)
2
{
3
       Function_Body;
4
}
 
Q21. What is Dynamic Memory allocation? Mention the syntax. 
Ans: Dynamic Memory Allocation is the process of allocating memory to the program and its
variables in runtime. Dynamic Memory Allocation process involves three functions for allocating
memory and one function to free the used memory.
malloc() – Allocates memory
Syntax:
1ptr = (cast-type*) malloc(byte-size);
calloc() – Allocates memory
Syntax:
ptr = (cast-type*)calloc(n, element-
1
size);
realloc() – Allocates memory
Syntax:
ptr = realloc(ptr,
1
newsize);
free() – Deallocates the used memory
Syntax:
free(ptr)
1
;
 
Q22. What do you mean by Dangling Pointer Variable in C Programming?
Ans: A Pointer in C Programming is used to point the memory location of an existing variable. In
case if that particular variable is deleted and the Pointer is still pointing to the same memory location,
then that particular pointer variable is called as a Dangling Pointer Variable.
 
Q23. Where can we not use &(address operator in C)?
Ans: We cannot use & on constants and on a variable which is declared using the register storage
class.
 
Q24. Write a simple example of a structure in C Language
Ans: Structure is defined as a user-defined data type that is designed to store multiple data members
of the different data types as a single unit. A structure will consume the memory equal to the
summation of all the data members.
1 struct employee
2 {
3     char name[10];
4     int age;
5 }e1;
6
7
8
9
int main()
1
{
0
    printf("Enter the name");
1
    scanf("%s",e1.name);
1
    printf("n");
1
    printf("Enter the age");
2
    scanf("%d",&e1.age);
1
    printf("n");
3
    printf("Name and age of the employee: %s,%d",e1.name,e1.age);
1
    return 0;
4
}
1
5
1
6
 
Q25. Differentiate between call by value and call by reference.
Ans:

Factor Call by Value Call by Reference


Actual arguments cannot be changed Operations are performed on actual
Safety
and remain safe arguments, hence not safe
Memory Separate memory locations are created Actual and Formal arguments share the
Location for actual and formal arguments same memory space.
Arguments Copy of actual arguments are sent Actual arguments are passed
//Example of Call by Value method
#include<stdio.h> 
1
void change(int,int); 
2
int main() 
3

4
    int a=25,b=50; 
5
    change(a,b);
6
    printf("The value assigned to a is: %d",a); 
7
    printf("n"); 
8
    printf("The value assigned to of b is:
9
%d",b); 
10
    return 0; 
11

12
void change(int x,int y) 
13

14
    x=100; 
15
    y=200; 
16
}
//Output
The value assigned to of a is: 25
The value assigned to of b is: 50
 
//Example of Call by Reference method
1 #include<stdio.h>
2 void change(int*,int*); 
3 int main() 
4 { 
5     int a=25,b=50; 
6     change(&a,&b);
7     printf("The value assigned to a is: %d",a); 
8     printf("n"); 
9     printf("The value assigned to b is: %d",b); 
10    return 0; 
11} 
12void change(int *x,int *y) 
13{ 
14    *x=100; 
15    *y=200; 
16}
//Output
The value assigned to a is: 100
The value assigned to b is: 200
In case you are facing any challenges with these C Programming Interview Questions, please write
your problems in the comment section below.

Q26. Differentiate between getch() and getche().


Ans: Both the functions are designed to read characters from the keyboard and the only difference is
that
getch(): reads characters from the keyboard but it does not use any buffers. Hence, data is not
displayed on the screen.
getche(): reads characters from the keyboard and it uses a buffer. Hence, data is displayed on the
screen.
//Example
#include<stdio.h>
1
#include<conio.h>
2
int main()
3
{
4
     char ch;
5
     printf("Please enter a character ");
6
     ch=getch();
7
     printf("nYour entered character is
8
%c",ch);
9
     printf("nPlease enter another character ");
10
     ch=getche();
11
     printf("nYour new character is %c",ch);
12
     return 0;
13
}
//Output
Please enter a character
Your entered character is x
Please enter another character z
Your new character is z
 
Q27. Explain toupper() with an example.
Ans. toupper() is a function designed to convert lowercase words/characters into upper case.
//Example
#include<stdio.h>
1#include<ctype.h>
2int main()
3{
4    char c;
5    c=a;
6    printf("%c after conversions  %c", c,
7toupper(c));
8    c=B;
9    printf("%c after conversions  %c", c,
toupper(c));
//Output:
a after conversions A
B after conversions B
 
Q28. Write a code to generate random numbers in C Language.
Ans: Random numbers in C Language can be generated as follows:
1 #include<stdio.h>
2 #include<stdlib.h>
3 int main()
4 {
5      int a,b;
6      for(a=1;a<=10;a++)
7      {
8            b=rand();
9            printf("%dn",b);
10     }
11     return 0;
12}
//Output
1987384758
2057844389
3475398489
2247357398
1435983905
 
Q29. Can I create a customized Head File in C language?
Ans: It is possible to create a new header file. Create a file with function prototypes that need to be
used in the program. Include the file in the ‘#include’ section in its name.
 
Q30. What do you mean by Memory Leak?
Ans: Memory Leak can be defined as a situation where programmer allocates dynamic memory to the
program but fails to free or delete the used memory after the completion of the code. This is harmful
if daemons and servers are included in the program.
1 #include<stdio.h>
2 #include<stdlib.h>
3 int main()
4 {
5      int* ptr;
6      int n, i, sum = 0;
7      n = 5;
8      printf("Enter the number of elements: %dn", n);
9      ptr = (int*)malloc(n * sizeof(int));
1      if (ptr == NULL)
0      {
1             printf("Memory not allocated.n");
1             exit(0);
1      }
2      else
1      {
3             printf("Memory successfully allocated using malloc.n");
1             for (i = 0; i<= n; ++i)
4             {
1                   ptr[i] = i + 1;
5              }
1              printf("The elements of the array are: ");
6              for (i = 0; i<=n; ++i)
1             {
7                   printf("%d, ", ptr[i]);
1             }
8      }
1      return 0;
9 }
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
//Output
Enter the number of elements: 5
Memory successfully allocated using malloc.
The elements of the array are: 1, 2, 3, 4, 5,
In case you are facing any challenges with these C Programming Interview Questions, please write
your problems in the comment section below.
Q31. Explain Local Static Variables and what is their use?
Ans: A local static variable is a variable whose life doesn’t end with a function call where it is
declared. It extends for the lifetime of the complete program. All calls to the function share the same
copy of local static variables.
1 #include<stdio.h>
2 void fun()
3 {
4     static int x;
5     printf("%d ", x);
6     x = x + 1;
7 }
8 int main()
9 {
10    fun();
11    fun();
12    return 0;
13}
//Output
01
 
Q32. What is the difference between declaring a header file with < > and ” “?
Ans: If the Header File is declared using < > then the compiler searches for the header file within the
Built-in Path. If the Header File is declared using ” ” then the compiler will search for the Header File
in the current working directory and if not found then it searches for the file in other locations.
 
Q33. When should we use the register storage specifier?
Ans: We use Register Storage Specifier if a certain variable is used very frequently. This helps the
compiler to locate the variable as the variable will be declared in one of the CPU registers.
 
Q34. Which statement is efficient and why? x=x+1; or x++; ?
Ans: x++; is the most efficient statement as it just a single instruction to the compiler while the other
is not.
 
Q35. Can I declare the same variable name to the variables which have different scopes?
Ans: Yes, Same variable name can be declared to the variables with different variable scopes as the
following example.
1int var;
2void function()
3{
4   int variable;
5}
6int main()
7{
8   int variable;
9}
 
Q36. Which variable can be used to access Union data members if the Union variable is
declared as a pointer variable?
Ans: Arrow Operator( -> ) can be used to access the data members of a Union if the Union Variable is
declared as a pointer variable.
 
Q37. Mention File operations in C Language.
Ans: Basic File Handling Techniques in C, provide the basic functionalities that user can perform
against files in the system.
Function Operation
fopen() To Open a File
fclose() To Close a File
fgets() To Read a File
fprint() To Write into a File
In case you are facing any challenges with these C Programming Interview Questions, please write
your problems in the comment section below.

Q38. What are the different storage class specifiers in C?


Ans: The different storage specifiers available in C Language are as follows:
 auto
 register
 static
 extern
 
Q39. What is typecasting?
Ans: Typecasting is a process of converting one data type into another is known as typecasting. If we
want to store the floating type value to an int type, then we will convert the data type into another data
type explicitly.
Syntax:
(type_name)
1
expression;
 
Q40. Write a C program to print hello world without using a semicolon (;).
Ans: 
1#include&lt;stdio.h&gt;     
2void main()
3{     
4      if(printf("hello world")){}
5}
//Output:
hello world
 
Q41. Write a program to swap two numbers without using the third variable.
Ans:
1 #include&lt;stdio.h&gt;     
2 #include&lt;conio.h&gt;     
3 main()     
4 {     
5      int a=10, b=20;   
6      clrscr();      
7      printf("Before swapping a=%d b=
8 %d",a,b);       
9      a=a+b;      
10     b=a-b;   
11     a=a-b;     
     printf("nAfter swapping a=%d b=%d",a,b);     
12
     getch();     
13
}
//Output
Before swapping a=10 b=20
After swapping a=20 b=10
 
Q42. How can you print a string with the symbol % in it?
Ans: There is no escape sequence provided for the symbol % in C. So, to print % we should use ‘%
%’ as shown below.
printf(&ldquo;there are 90%% chances of rain
1
tonight&rdquo;);
 
Q43. Write a code to print the following pattern.
1
12
123
1234
12345
Ans: To print the above pattern, the following code can be used.
1 #include&lt;stdio.h&gt;
2 int main()
3 {
4       for(i=1;i&lt;=5;1++)
5       {
6            for(j=1;j&lt;=5;j++)
7            {
8                 print("%d",j);
9            }
10           printf("n");
11      }
12      return 0;
13}
 
Q44. Explain the # pragma directive.
Ans: The following points explain the Pragma Directive.
 This is a preprocessor directive that can be used to turn on or off certain features.
 It is of two types #pragma startup, #pragma exit and pragma warn.
 #pragma startup allows us to specify functions called upon program startup.
 #pragma exit allows us to specify functions called upon program exit.
 #pragma warn tells the computer to suppress any warning or not.
 
Q45. How can you remove duplicates in an array?
Ans: The following program will help you to remove duplicates from an array.
1 #include &lt;stdio.h&gt;
2 int main()
3 {
4      int n, a[100], b[100], calc = 0, i, j,count;
5      printf("Enter no. of elements in array.n");
6      scanf("%d", &amp;n);
7      printf("Enter %d integersn", n);
8      for (i = 0; i &lt; n; i++)
9            scanf("%d", &amp;a[i]);
10           for (i = 0; i&lt;n; i++)
11           {
12                 for (j = 0; j&lt;calc; j++)
13                 {
14                        if(a[i] == b[j])
15                        break;  
16                  }
17           if (j== calc)
           {
18
                  b[count] = a[i];
19
                  calc++; 
20
            }
21
      }
22
      printf("Array obtained after removing duplicate
23
elementsn");
24
      for (i = 0; i&lt;calc; i++)
25
      { 
26
             printf("%dn", b[i]);
27
      }
28
      return 0;
29
}
//Output
Enter no. of elements in array. 5
Enter 5 integers
12
11
11
10
4
Array obtained after removing duplicate elements
12
11
10
4
 
Q46. What is Bubble Sort Algorithm? Explain with a program.
Ans: Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares
adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated
until the list is sorted. 
The following code executes Bubble Sort.
int main()
1
{
2
      int array[100], n, i, j, swap;
3
      printf("Enter number of elementsn");
4
      scanf("%d", &amp;n);
5
      printf("Enter %d Numbers:n", n);
6
      for(i = 0; i&lt;n; i++)
7
           scanf("%d", &amp;array[i]);
8
           for(i = 0 ; i&lt;n - 1; i++)
9
           {
10
                 for(j = 0 ; j &lt; n-i-1; j++)
11
{ if(array[j]&gt;array[j+1])
12
                       {
13
                               swap=array[j];
14
                               array[j]=array[j+1];
15
                               array[j+1]=swap;
16
                       }
17
                 }
18
           }
19
           printf("Sorted Array:n");
20
           for(i = 0; i &lt; n; i++)
21
                 printf("%dn", array[i]);
22
           return 0;
23
}
 
Q47. What is Round-robin algorithm? Write a code for Round Robin Scheduling.
Ans: Round-robin Algorithm is one of the algorithms employed by process and network schedulers in
computing in order to evenly distribute resources in the system.
The following code will execute Round Robin Scheduling
1 #include&lt;stdio.h&gt;
2   
3 int main()
4 {
5       int i, limit, total = 0, x, counter = 0, time_quantum;
6       int wait_time = 0, turnaround_time = 0, arrival_time[10], burst_time[10], temp[10];
7       float average_wait_time, average_turnaround_time;
8       printf("nEnter Total Number of Processes:t");
9       scanf("%d", &amp;limit);
10      x = limit;
11      for(i = 0; i&lt;limit; i++)
12      {
13            printf("nEnter Details of Process[%d]n", i + 1);
14            printf("Arrival Time:t");
15            scanf("%d", &amp;arrival_time[i]);
16            printf("Burst Time:t");
17            scanf("%d", &amp;burst_time[i]);
18            temp[i] = burst_time[i];
19      }
20  
21      printf("nEnter Time Quantum:t");
22      scanf("%d", &amp;time_quantum);
23      printf("nProcess IDttBurst Timet Turnaround Timet Waiting Timen");
24      for(total = 0, i = 0; x != 0;)
25      {
26            if(temp[i] &lt;= time_quantum &amp;&amp; temp[i] &gt; 0)
27            {
28                  total = total + temp[i];
29                  temp[i] = 0;
30                  counter = 1;
31            }
32            else if(temp[i]&gt;0)
33            {
34                  temp[i] = temp[i] - time_quantum;
35                  total = total + time_quantum;
36            }
37            if(temp[i] == 0 &amp;&amp; counter == 1)
38            {
39                  x--;
40                  printf("nProcess[%d]tt%dtt %dttt %d", i + 1, burst_time[i], total - arrival_time[i], total -
41arrival_time[i] - burst_time[i]);
42                  wait_time = wait_time + total - arrival_time[i] - burst_time[i];
43                  turnaround_time = turnaround_time + total - arrival_time[i];
44                  counter = 0;
45            }
46            if(i == limit - 1)
47            {
48                  i = 0;
49            }
50            else if(arrival_time[i + 1] &lt;= total)
51            {
52                  i++;
53            }
54            else
55            {
56                  i = 0;
57            }
58      }
59  
60      average_wait_time = wait_time * 1.0 / limit;
61      average_turnaround_time = turnaround_time * 1.0 / limit;
      printf("nnAverage Waiting Time:t%f", average_wait_time);
62
      printf("nAvg Turnaround Time:t%fn", average_turnaround_time);
63
      return 0;
64
}
//Output

 
Basic C Programming Viva Questions
1) What do you mean by Hardware and Software?
All the electronic/electrical components and circuits used in a computer system are called hardware. A
computer is actuated and controlled with the help of computer programs called software.

2) Mention the main components of a computer and their funtions.


CPU (cenral processing unit) – to process the data
Input Device – to enter the dat into the computer.
Output Device – to display / print results by the computer.

3) What is Operating System(OS) ?


An operating system is a collection of programs used to connect the user with the hardware It has the
set of programs which controls the operations of the hardware components such as CPU, main
memory, keyboard, monitor, printer and so on.

4) What is Algorithms?
An algorithms refer to the step by step instructions written to solve any problem.
 
5) What is Flowchart ?
A flowchart is a diagrammatic or symbolic representation of an algorithms. It uses various symbols to
represent the operations to be performed.
 
6) Name the four basic data types in “C” language?
The four basic data types in “c” language are as follows
char – a character
int – an integer, in the range -32,767 to 32,767
long int – a larger integer (up to +-2,147,483,647)
float – a floating-point number
double – a floating-point number, with more precision and perhaps greater range than float
 
7) Describe at least five different format specifiers?
%d: -An integer whole number
%f: -a floating point number
%c: -a single character
%s: -a string of value of characters.
 
8) Define and explain scanf () function?
The Scanf () function can be used to get input into a program and it requires two arguments. First a
format specifier defines the type of data to be entered, then the name of the variable in which the input
will be stored. This scanf () function is responsible for giving input into the program.
 
9) Define and explain printf () function?
The printf() function is used to display/output values of variable in the monitor. The printf function
has general form: printf (“format specifiers”,variables)
 
10) What are the maximum and minimum possible ranges of values for long and short type?
If the int variable is created by default as a ‘long’ type it typically will have a possible range of values
from a maximum of +214748347 and a minimum of -2147483648. For ‘short’ type these are the
maximum and minimum values +327676 and minimum -32768.
(While answering this question you can specify the approximate value raised to power).
 
11) What is preprocessor?
The preprocessor is a program which is executed before the compilation of a source program written
by the user. The preprocessor directives begines with hash (#) followed by the command. e.g #include
– it is a directive to include file.
 
12) What exactly is a ‘variable scope’, ‘local variables’ and ‘global variables’?
The extent to which a variable is accessible in a program is called the ‘variable scope’. Variables
declared internally inside a function are known as ‘local’ variables.
Variables declared externally outside a function are known as ‘global’ variables.
 
13) What are signed values?
When an int variable is declared it can by default contain either positive of negative integer values.
These are known as ‘signed’ values. The range of positive values is determined by your system.
 
14) Define reserved words.
C programs are constructed from a set of reserved words which provide control and from libraries
which perform special functions. The basic instructions are built up using a reserved set of words,
such as main, for, if,while, default, double, extern, for, and int, to name just a few.
 
15) What is the purpose of type declaration in C ?
All variables used in a C program are declared using the appropriate data types to enable the compiler
to allocate the required number by bytes in RAM to store values of these variables in memory
 
16) What is identifier ?
An identifier is a name used to identify a variable, function, symbolic constsnt and so on.
 
17) Mention the different types of operators used in C ?
1. Arithmetic operator
2. Relational operators
3. Logical Operators
4. Increment and decrements operators
5. 5.Assignment operators
6. 6.Conditional operator
7. Bitwise oprators
 
18) What is Loop control statements ?
Loop control structures are used to execute and repeat a block of statements depending on the
value of a condition. There are 3 types of loop control statements in C
1. for loop
2. while loop
3. do – while loop
 
19) explain while loop .
A while loop has one control expression, and executes as long as that expression is true. The
general syntax of a while loop is
while( expression ){
statements
}
we use a while loop when a statement or group of statements which may have to be executed
a number of times to complete their task. The controlling expression represents the condition
 
20) explain for loop .
A for loop is used to execute and repeat a block of statements depending on a condition. The
syntax of a for loop is
for( ; ; )
{
statements
}
 
21) What do mean by network ?
Computer networking refers to connecting computers to share data, application software and
hardware devices. Networks allow sharing of information among various computers and
permit users to share files
 
22) List a few unconditional control statement in C.
1.  break statement
2.  continue statement
3.  goto statement
4. exit() function
 23) What is an array?
An array is a collection of values of the same data type. Values in array are accessed using
array name with subscripts in brackets[]. Synatax of array declaration is
data type array_ name[size];
 
24) What is Multidimensional Arrays?
An array with more than one index value is called a multidimensional array. To declare a
multidimensional array you can do follow syntax
data type array_ name[] [] []….;
 
25) Define string?
An array of characters is known as a string.for example
char st[8]; this statement declares a string array with 80 characters .
 
26) Mention four important string handling functions in C languages .
There are four important string handling functions in C languages .
1. strlen();
2.  trcpy();
3. strcat();
4. strcmp();
The header file #include is used when these functions are called in a C program.
 
27) Explain about the constants which help in debugging?
A #if directive test can be offered with #else and #else if directives. This allows conditional
branching of the program to run sections of the code according to the result. Constants
defined with a #define directive can be undefined with the #undef directive. The #ifdef
directive has a companion directive #ifndef. These commands can be useful when debugging
problem code to hide and unhide sections of the program.
 
28) Define and explain about ! Operator?
The logical operator ! NOT is a unary operator that is used before a single operand. It returns
the inverse value of the given operand so if the variable “c” had a value of true then! C would
return value of false. The not operator is very much useful in C programs because it can
change the value of variables with successful iterations. This ensures that on each pass the
value is changed.
 
29) What is operator precedence?
Operator precedence defines the order in which C evaluates expressions.
e.g. in the expression a=6+b*3, the order of precedence determines whether the addition or
the multiplication is completed first. Operators on the same row have equal precedence.

 30) Explain about the functions strcat() and strcmp()?


This function concatenates the source string at the end of the target string. Strcmp() function
compares two strings to find out whether they are the same or different. The two strings are
compared character by character until there is a mismatch or end of one of the strings is
reached, whichever occurs first. If in case two strings are identical, a value of zero is
returned. If there is no matches between two strings then a difference of the two non
matching values are returned according to ASCII values.
 
31) Define function
A function is a module or block of program code which deals with a particular task. Each
function has a name or identifier by which is used to refer to it in a program. A function can
accept a number of parameters or values which pass information from outside, and consists of
a number of statements and declarations, enclosed by curly braces { }, which make up the
doing part of the object
 
32) Differentiate built-in functions and user – defined functions.
Built – in functions are used to perform standard operations such as finding the square root of
a number, absolute value and so on. These are available along with the C compiler and are
included in a program using the header files math.h, s tring.h and so on.
User defined functions are written by the user or programmer to compute a value or perform
a task. It contains a statement block which is executed during the runtime whenever it is
called by the main program.
 
33) Distinguish between actual and formal arguments.
Actual arguments are variables whose values are supplied to the function in any function call.
Formal arguments are variables used to receive the values of actual arguments from the
calling program.
 
34) Explain the concept and use of type void.
A function which does not return a value directly to the calling program is referred as a void
function. The void functions are commonly used to perform a task and they can return many
values through global variable declaration.
 
35) What is recursion?
A function calling itself again and again to compute a value is referref to as recursive
function or recursion. Recursion is useful for branching processes and is effective where
terms are generated successively to compute a value.
 
36) Mention the types of network.
A simple network consist of computers connected using nework interface cards, networking
software and network cables. There are two main networking arrangents
i) client / server – a powerful computer is used as the server which works as the
interpreter between the clients and helps sharing files.
ii)peer to peer – there is no server and all the workstations are treated equally.
 
37) What are Library functions?
Library functions are built in programs available along with the compiler which perform
some standard mathematical operations.

 38) How does the type float differ from double in C language ?
Float data type refers real number in single precision and has 6 decimal digits. It takes 4 bytes
in memory to refer values ranging from 3.4e-38 to 3.4e+38
Double data type also refers to real number but in double precision and has 12 decimal digits.
It takes 8 bytes of memory to refer values ranging from 1.7e-308 to 1.7e+308

 39) What is an operator and operand?


An operator performs an operation like addition, subtraction and so on and produce a value.
Variables and constants upon which operations are performed are called operands.
 
40) What is RAM ?
RAM – Random Access Memory is a temporary storage medium in a computer. RAM is a
volatile memory i.e all data stored in RAM will be erased when the computer is switched off.
 
41) What is ROM ?
ROM – Read Only Memory is permanent storage medium which stores start up programs
(operating system programs) and BIOS programs which are recorded by the manfacturer of
the compiler system. ROM is a non-volatile memory.
 
42) Define system software.
System software is a collection of programs which are used to assist the user to handle the
computer hardware like printer, disk and so on and execute the application programs.
 
43) Define application software
application softwares are programs which are used to solve specific problems /tasks.
Examples include railway reservation, banking and so on.
 
44) What are control ststements ?
All the statements written in a program are executed from top to bottom one by one. Control
statements are used to execute / transfer the control from one part of the program to another
depending on conditions.
 
45) What is Parallel Computation?
Computations that use multi-processor computers and/or several independent computers
interconnected in some way, working together on a common task.
 Examples: CRAY T3E, IBM-SP, SGI-3K, Cluster of Workstations.
 46) Why use Parallel Computation?
 Computing power (speed, memory)
 Cost/Performance
 Scalability
 Tackle intractable problems
47) What does OpenMP stand for?
Short version: Open Multi-Processing
Long version: Open specifications for Multi-Processing via collaborative work between
interested parties from the hardware and software industry, government and academia.
48) Explain increment and decrements operators .
++ increment operator which add one to the value,
example : i++ (which adds one to i and results is scored back to)
— decrement operator which subtracts one from the value
example — i ( which subtracts one from i)
 
49) Mention the types of memory
Two major types of memory storage is primary memory and secondary memory. Primary
storage (or main memory or internal memory), often referred to simply as memory, is the
only one directly accessible to the CPU.
Secondary memory (or external memory) differs from primary storage in that it is not directly
accessible by the CPU. Some of the example for secondary memory includes floopy disks,
flash memory, mengetic tape, hard drives etc.
 
50) What are input and output device?
Input and Output Devices: Input devices are the hardware that are used for providing
information to the computer like mouse and keyboard and output devices are the hardware
that are used for receiving information from computer like monitor, printer or the sound
system.

You might also like