Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +917541905230, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Wednesday, November 18, 2020

C Interview questions and answers-5

C Interview questions and answers | welcome2protec


What is control statements in C?

Control statements are used in C or other programming language to regulate the flow of program execution, i.e. whether or not a set of statements will be executed based on certain conditions or how many times a certain block of cedes is to be executed, again based on condition.

For Example:

/*Control statements in C*/
int x = 2;
int y = 3;

/*If condition is true, this code block will be executed*/
if((x + y) % 5 == 0){
 // Do whatever
}

/*if condition is false, this code block will be executed*/
else{
 //Do something else 
}
-------------------OR----------------------------
int i;
for(i = 0; i < 10; i++){
 /* Do anything that you want. This code block will be 
  * executed until i becomes > or = to 10 */
}

What is if---else statements in C?

The if---else statement in C is used to perform the operation based on some specific condition. The if statement is executed if the statement inside the condition evaluates to true, otherwise the statement inside the else block is executed.

/*Syntax of if---else statement.*/
if(Condition){
 // Block-1 statement
}

/*if condition is false, this code block will be executed*/
else{
 //Blcok-2 statement 
}

What is nested if...else in C?

Nested if...else: Having more than one if...else statement inside the body of another if...else statement is called nested if...else statement.

Syntax | More details.

if(condition) {
    //Nested if else inside the body of "if"
    if(condition2) {
       //Statements inside the body of nested "if"
    }
    else {
       //Statements inside the body of nested "else"
    }
}
   else {
    //Statements inside the body of "else"
   }


Waht is if...else...if ladder statement in C?

It is used in the scenario where there are multiple cases to be performed for different conditions. In if-else-if ladder statement, if a condition is true then the statements defined in the if block will be executed, otherwise if some other condition is true then the statements defined in the else-if block will be executed, at the last if none of the condition is true then the statements defined in the else block will be executed. There are multiple else-if blocks possible. It is similar to the switch case statement where the default is executed instead of else block if none of the cases is matched.

Syntax

if(condition1){  
//code to be executed if condition1 is true  
}else if(condition2){  
//code to be executed if condition2 is true  
}  
else if(condition3){  
//code to be executed if condition3 is true  
}  
...  
else{  
//code to be executed if all the conditions are false  
}  



To be updated soon...

--

--




Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Help others by sharing this page.

Ahmad Irshad

Author & Editor

I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP

0 Comments:

Post a Comment

Please don't enter any spam link in the comment box.


Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec
Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec
Contact Us