help in understanding the c programming

Status
Not open for further replies.

pratti

Member level 3
Joined
Jun 15, 2013
Messages
56
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
471
Code:
if(condition1)
{
 if(condition2)
   {
     functioncall1();
  }
  elseif(condition2)
   {
   functioncall2();
   }
  else
     {
     functioncall3();
    }
}
end
if the intial condition of 1st if fails after sometime after entering into loop by once fullfilling the condition,does the whole loop terminate immediatly?
 
Last edited by a moderator:

Code:
if(condition1)
{
 if(condition2)
   {
     functioncall1();
  }
  elseif(condition2)
   {
   functioncall2();
   }
  else
     {
     functioncall3();
    }
}
end

You should not use "end" in the end. This close bracket means the end of if clause.
 

if i want to continuously check the 1st condition and terminate if not fullfilled then how should i do coding?plz suggest me
 

if i want to continuously check the 1st condition and terminate if not fullfilled then how should i do coding?plz suggest me

use while condition instead of if condition

Code:
while(condition1)
{
 if(condition2)
   {
     functioncall1();
  }
  elseif(condition2)
   {
   functioncall2();
   }
  else
     {
     functioncall3();
    }
}
 

if i want to continuously check the 1st condition and terminate if not fullfilled then how should i do coding?plz suggest me

Hi dude...
Look... If I understand what you want to do, I would do as following:
Code:
while(condition1)
{
     if(condition2)
     {
        functioncall1();
        if(!condition1) break;
     }
     elseif(condition2)
     {
        functioncall2();
        if(!condition1) break;
     }
     else
     {
        functioncall3();
        if(!condition1) break;
     }
}

so... it will check condition to enter in the while loop and every step it will check if condition one is true... if not true.. it will break while loop and continues program from the last bracket in the code I sent.
 

while using "while"condition if our 1st situation didnt meet then can the whole process be terminated even if it is in processing of functioncall2??

- - - Updated - - -

thnx aveztruz
but in that condition also can the processing of the function call 2 be immediately stoped if 1st condition doesnt meet?can the whole process be immediately stopped if 1st contion doesnt meet even though it is in processing of called function?
 

while using "while"condition if our 1st situation didnt meet then can the whole process be terminated even if it is in processing of functioncall2??

yes if condition of while is false the whole process will be terminated
 


pratti... You know that C language is procedural.. it means that the program will be executed line by line as it was written... so if you want something to interrupt the code, it needs to be verified all the time... once it is inside "while" it will execute all code inside unlees the program reaches a "break". That is why you need to check all the time.

maybe if you explain better the situation... what about is this program and more details we can help you to find a easier solution.

regards.
 


just explain the exact need of this...
looping and if conditions can be used by several ways...
A clear need can only solve your problem...
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…