Viva Question: All Questions Are Compulsory (10 X 3)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

END TERM PRACTICAL EXAMINATIONS, JUNE, 2019

MASTER of COMPUTER APPLICATION (MCA)


"C" COMPUTER LAB (OMC-121)
MAX MARKS: 70
Note: Choose any two programs from the following: 35 X 2
• Write a find the maximum/minimum number in a given array.

• Write a program to calculate the sum of digits of a given number.


• Write a program to find the sum of n terms of the series: n-n*2/2!+n*3/3!-n*4/4!+
………..

• Write a program to check whether a number is an Armstrong number.

Viva Question: All questions are compulsory (10 x 3)


• What are the key features in C programming language?

• What are the basic data types associated with C?

• Describe the header file and its usage in C programming?

To find the maximum/inimum number in a given array,

• Enter the number of elements in array


• 5
• Enter 5 integers
• 4
• 5
• 6
• 8
• 2
• Maximum element is present at location 4 and it's valur is 8.

maximum/minimum array
1. #include <stdio.h>
2. int find_maximum(int[], int);
3. int main() {
4. int c , array[100], size, location, maximum;
5. printf("Input number of elements in array\n");
6. scanf("%d,&size);
7. printf("Enter %d integers\n", size);
8. for (c=0;c< size;c++)
9. scanf("%d",&array[c]);
10. location= find_maximum(array, size);
11. maximum =array[location];
12. printf("Maximum element location = %d and value = %d.\n", location +1, maximum);
13. return 0;
14. }
15. int find_maximum(int a[], int n {
16. int c, max, index;
17. max = a[0];
18. index =0;
19. for (c=1; c< n; c++){
20. if (a[c]> max {
21. index = c;
22. max =a[c];
23. }
24. }
25. return index;
26. }

• Write a program to calculate the sum of digits of a given number.

1. #include <stdio.h>
2. int main()
3. {
4. int n, t, sum=0,remainder;
5. printf("Enter an integer\n");
6. scanf("%d",&n);
7. t = n;
8. while (t!= 0)
9. { remainder=t%10;
10. sum=sum+remainder;
11. t = t /10; }
12. printf("Sum of digits of %d =%d\n",n,sum);
13. return0;
14. }
• What are the key features in C programming language?

To solve the computing problem, its solution must be specified in terms of sequence of
computational steps such that they are effectively solved by a human agent or by a digital
computer.

C's ability to communicate directly with hardware makes it a powerful choice for system
programmers. In fact, popular operating systems such as Unix and Linux are written entirely in
C. Additionally, even compilers and interpreters for other languages such Fortran, Pascal, and
Basic are written in C. However C's scope is not just limited to developing system programs. It is
also used to develop any kind of application, including complex business ones.Some areas where
C language is used:
• Embedded Systems
• Systems programming
• Artificial Intelligence
• Industrial Automation
• Computer Graphics
• Space Research

Keyfetures of C language
• C is simple
• There are only 32 keywords so C is very easy to master. Keywords are words that have
special meaning in C language.
• C programs run faster than programs written in most other languages.
• C enables easy communication with computer hardware making it easy to write system
programs such as compilers and interpreters.

• What are the basic data types associated with C?


Data types: A C language programmer has to tell the system before- hand, the type of numbers or
characters he is using in his program. These are data types. There are many data types in C
language. A C programmer has to use appropriate data type as per his requirement. C language
data types can be broadly classified as

1. Primary data type


2. Derived data type
3. User defined data type

Primary data type are integer, character (used to store character), float,double etc, these are
fundamental datatypes of C language.

Derived data typpes- these are nothing but primary data types, these are some different and
grouped together for example array, structure and union.

user defined data type- as the name implies these are defined by user itself.

Describe the header file and its usage in C programming?

Header files are special files which stores library functions that are predefined.
We are using printf() & scanf() functions in our program then we have to include
#include<stdio.h> header file. It is for standard i/o. If we don't include the the header files we
can't run your program. Therefore we have to include the header files.

Another header file is #include<conio.h> which is for console i/o. This header file stores clrscr()
& getch() functions. clrscr() is for clearing the screen & getch() is holding the screen until we
press any single character from keyboard.

Also we have lots of different header files which stores different functions

for example
#include<math.h> (for mathematic functions)

#include<graghics.h> (for graphical functions)

#include<string.h> (this is for string functions)

header file are compulsary part of a program . we can create our own header file also.

etc.

You might also like