Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

C Language Thoery

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

*Define terms:

1)call by value:

1]In this method,the value of actual parameter is passed to the formal parameters.

2]Any changes made by the function to the value of the formal parameters does not affect the value
of corresponding actual parameters.

3]In this method,actual parameter can be lateral,constant or some expression or some function call.

In all cases it will pass the value of actual parameter to corresponding formal parameters.

2]call by reference:

1]In this method,instead of passing the value of the actual paramters it passes the address(pointer)
and therefore function will recieve the address of the formal parmeters.

2]In this method the formal parameters must be pointer variable of appropriate type.

3]As function receive the address of actual parameters and hence any changes made by function to
the value of formal parameter will affect to the actual parameters.

*Features of c language programs.

Ans:

1]C language is a case sensitive language i.e., c-compiler will differentiate between upper and lower
case.

2]Entire c language program written in lower case.

3]The extension of the c language source file should be .c

4]Whenever c program is compiled it will translate the c language program into executable
file(machine language program).

5]The extension of executable file is .exe(on windows) or .out(on linux)

prg1.c ------->c-compiler-------->p1.exe------->cpu-------->output

source file executable

file
*What is comment?

1]A comment is some helpful note of the program or program elements.

2]The comment will help later to understand the certain detail of the programming.

3]They are not part of the program.

4]Compiler ignores the comment.

5]C language program comment text should be enclose in /* and */.

6]A comment may spam on multiple lines.

7]Writting appropriate comment within a program is good programming practice.

*What is main function?

Ans:

1]A function represents a block of code i.e.,the group of statement enclosed within[{}]curly bracket.

2]Each function is identified by some name.

3]Function may contain zero or more statement.

4]Each statement must be end with[;]semicolon.

5]The number of statement within a function we depend on what task function is performing.

6]C language program is a sequence of one or more functions.

7]Execution of c language program always begins from main.

8]In a program Function may be define in any order but exexcution always begins from main.

*What is #include?

Ans:

1]There are certain statement in c language which begins with # sign all such statement are called as
preprocessor statement.

2]Preprocessor is a part of c-compiler which process preprocessor statement before the compilation
and as a result certain c language code will be added or generated in a source program.

3]#include statement will add the code of header file in source program and then program will be
compiled.

5]There can be several input satement written one after another to include various library file.

6]Some of the library file are stdio.h,string.h,math.h,alloc.h,conio.h,stdlib.h,etc.

7]library file is also called as header file.


8]Some other preprocessor statement are #define,#if,#endif,#elseif,#pragma.

*what is decision making structure?

Ans:

1]C program executes program sequentially.sometimes,a program requires of checking certain


condition in a program execution.

2]A c provides key statements to check and execute statement according conditional criteria.

3]These statement are called 'selection' or 'conditional statement.'

4Follwing are decision making statement:

1]if statement,

2]if-else statement,

3]switch statemnet,

4]nested if else statement.

*What is loop?

Ans:

1]A Loop is a part of code of a program which executed repeatedly.

2]A loop is used using condition.The repetititon is done until condition becomes contion true.

3]A loop declarartion and execution can be done in following ways:

1)Check condition to start a loop.

2)Intialize loop with declaring a variable.

3)Executing statements inside loop.

4)Increment or decrement of value of a variable.

*What is the purpose of goto statement?

Ans:
1]It is well known as 'Jumping ststement'.

2]The goto statement is used to change the normal sequence of program execution by transferring
control to the other part of the program.

3]The general format of target statement is:

label:statements;

4]The general format is,

goto label;

5]It is primarily used to transfer the control of execution to any place in a program.It is useful to
provide branching within a loop.

*What is for loop?explain the working of for loop.

Ans:

1]This is an entry controlled looping statement.

2]In for loop structure,more than one variable can be initialized.

3]One of the most important feature of this loop is that the three actions are taken at a time such as
initialization,condition checking and increment or decrement.

4]For loop syntax:

for(initialization;test-condition;increment/decrement)

statements;

5]In above syntax,there are three expression are separated by semicolon(;).

working of for loop:

1]Initial expression is initialized at the begining of the for loop.then,the test expression is checked by
the program,if it is false then, for loop is terminated.

2]But,if test expression is true,then the codes are executed and expression is updated.again,the test
expression is checked,if it is false ,loop is terminated and if it is true,the same process repeates until
test expression is false.

*What is while loop?explain the working of the while loop.


Ans:

1]This is an entry controlled lopping statement.

2]It is used to repeat a block of statements until condition becomes true.

3]Syntax for while loop:

while(condition)

statements;

incerement/decrement;

working of while loop:

1]In above syntax,the condition is checked first.if it is true,then the program control flow goes inside
the loop and executes the block of statements associated with it.

2]At the end of loop increment or decrement is done to change in variable value.This process
continues until test condition satisfies.

*What is do-while loop?explain working of do-while loop.

Ans:

1]This is an exit controlled looping statement.

2]Sometimes,there is need to execute a block of statement first then to check condition.At that timw
such type of loop is used.

3]In do-while,block of statements executed first and condition is checked.

do

statements;

(increment/decrement);

}while(condition);

working of do-while loop:


1]In above syntax,first block of statements can be executed.At the end of loop,while statement is
executed.If the resultant condition is true then program control goes to evalute the body of a loop
once again.This process continues till condition becomes true.when it becomes false,then the loop
terminates.

2]At first codes inside the test expression is checked.if it is true,code inside of do are executed again
and the process continues until test expression becomes false(zero).Notice,there is semicolon in the
end of while();in do ...while loop.

You might also like