C Programming Language

Mar 27 • Engineering Sample Papers, Notes • 3703 Views • 3 Comments on C Programming Language

C Programming Language given with solution those who want to increase the skills of C Programming Language learn and practice with this page.These questions are very important for interview point of view also,here we covered all the principal and concept in C Programming Language.

C Programming Language Questions with Answers

C Language Question Bank

C Programming Language Sample Paper

 

Q.1 Answer the following questions:

(a) What do you mean by a programming language?

 Ans:– A programming language is a set of instructions which are given to a system to perform a specific task to find the required output.

(b) What is the evolution of C?

Ans:- The C language was developed in 1970’s at Bell laboratories by Dennis Ritchie. Initially it was designed for programming in the operating system called UNIX. After the advent of C, the whole UNIX operating system was rewritten using it.

(c) What do you mean by function?

Ans:- A function is a self contained subprogram that is meant to do some specific, well-defined task.

 (d) What is return statement?

Ans:– The return statement is used in a function to return a value to the calling function. It may also be used for immediate exit from the called function to the calling function without returning a value.

 (e) What is Actual argument?

Ans:- The arguments which are mentioned in the function call are known as actual arguments, since these are values which are the values which are actually sent to the called function.

fun(x)

func(a*b, c*d+k)

(f) How many types of functions are available in C?

Ans:- Four types.

  1. Functions with no arguments and no return value
  2. Functions with no arguments and a return value
  3. Functions with arguments and no return value
  4. Functions with arguments and a return value

 (g) What are the library functions?

Ans:- The library functions are formally not a part of the C language, but they are applied with every C compiler. The source code of the library functions is not given to the user. These functions are precompiled and the user gets only the object code.

 (h) What is the output of the following program?

           #include<stdio.h>

            main()

               {

                  Int  x=8;

                  Printf(“x=%d”, ++x);

                  Printf(“x=%d”, –x);

               }

Ans:- x=9, x=8

(i) What do you mean by an array?

Ans:- An array is a collection of similar type of data items and each data item is called an element of the array. The data type of the elements maybe any valid data type like char, int or float.

(j) What are the advantages of preprocessor in C?

Ans:- Advantages of preprocessor in C are

  1. Readability of the program is increased.
  2. Program modification becomes easy.
  3. Makes the program portable and efficient.

2. Write down the structure of a C program.

Ans:- C program is the collection of one or more functions. Every function is a collection of statements and performs some specific task. The general structure of C program is:-

Comments

Preprocessor directives

Global variables

main()  function

{

Local variables

Statements

————

}

Comments can be placed anywhere in a program and enclosed between the delimiters.

Preprocessor directives are processed through preprocessor before the C source code passes through the compiler. The commonly used preprocessor directives are #include and #define. #include is used for including header files. #define is used to define symbolic constants and macros.

Execution starts from main() function.

 

3. WAP to find largest number from three given numbers.

Ans:- #include<stdio.h>

main()

{

int a, b, c, larger;

printf(“Enter three numbers.”);

scanf(“%d%d%d”, &a,&b,&c);

if(a>b)

{

if(a>c)

larger=a;

else

larger=c;

}

else

{

if(b>c)

larger=b;

else

larger=c;

}

printf(“Larger number is %d”, larger);

return 0;

}

 

4. WAP to find out the factorial of any number.

Ans:- #include<stdio.h>

main()

{

int n, num;

long fact=1;

printf(“Enter the number:”);

scanf(“%d”, &n);

num=n;

if(n<0)

printf(“No factorial of negative number”);

else

{

while(n>1)

{

fact=fact*n;

n–;

}

printf(“ Factorial of %d is= %d”, num, fact);

}

return 0;

}

5. WAP to print the pascal triangle.

Ans:- #include<stdio.h>
#define MAX 15
main()
{
int a [MAX][MAX];
int  i, j, n;
printf(“Enter  n”);
scanf(“%d”, &n);
for(i=0;i<=n;i++)
{
for(j=0;j<=i;j++)
if(j==0Iii==j)
a[i][j]=1;
else
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
printf(“%5d”, a[i][j]);
printf(“\n”);
}
return 0;
}

 

6. What do you mean by dynamic memory allocation? Give an example.

Ans:- The process of allocating memory at the time of execution is called dynamic memory allocation. The allocation and release of this memory space can be done with the help of some built in functions whose prototypes are found in alloc.h and stdlib.h.

Example:-

#include<stdio.h>
#include<alloc.h>
main()
{
int *p, n, i;
printf( “Enter the number of integers to be entered.”);
scanf(“%d”, &n);
p=(int *)malloc(n*sizeof(int));
if(p==NULL)
{
printf(“Memory not available”);
exit(1);
}
for(i=0;i<n;i++)
{
printf(“Enter an integer”);
scanf(“%d”, p+1);
}
for(i=0;i<n;i++)
printf(“%d”, *(p+i));
}
return 0;
}

7.  Can we write a C program without using main() function?

Ans:- We can write a c program without using main function. We can compile it but we cannot execute a program without a main function. Since in C execution of any program start from main function.  Examples of c program without a main is all the c library functions.  Function printf() is an example of library function which has been written and complied without using main function. To use or run such functions we write other program using main function and call those functions.

Related Search

Functions in C Language

C Language Aptitude Question

Interview Question With Answer

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

3 Responses to C Programming Language

  1. Prema says:

    B tech

  2. Prema says:

    B tech

  3. GATE Syllabus of Computer Science and Information Technology 2014 says:

    […] coding and way of keeping things &  arrange data in a systematic manner. It include topics- Programming in C ; Recursion, Functions , Parameter passing, Binding,Scope; Abstract data types, Arrays, Queues, […]

« »