What us conditional instruction in c language ? CONDITIONAL INSTRUCTION Sometimes we want to watch comedy videos on Youtube if the day is Sunday Sometimes we order junk food if it is our friend’s birthday in the hostel You might want to buy an umbrella if its raining and you have the money you order the meal if dal or your favorite bhindi is listed on the menu. All these are decisions which depend on a condition being met. In c language too, we must be able to execute instructions on a condition being met. learn c programming Ques1 :-What are decision making instructions in c? Decision Making Instructions in C if-else statement switch statement Ques 2 : -What is if-else statement in c ? if-else statement The syntax of an if-else statement in C look like: if (condition to be checked) { statement-if-condition- true; } else{ statement-if-condition-false; ] code example:- int a= 23; if (a>18){ printf(”you can drive\n”); } Note that else block is ...
Why loops Sometimes we want our programs to execute a few sets of instructions over and over again for ex. printing 1 to 100, the first 100 even number, etc. Hence Loops make it easy for programmers to tell the computer that a given set of instructions must be executed repeatedly. Types of loops:- Primarily, there are three types of loops in C language: 1. While loop 2. do-while loop 3. for-loop We will look into this one by one while loop while(Condition is true) { // code //code => The block keeps executing as long as the condition is true } An example int i=0 while (i<10) printf ("The value of i is %d",i); i++; NOTE: If the condition never becomes false, the while loop keeps getting executed. Such a Loop is known as an infinite loop. Increament and decreament operators i++ ----> i is decreased by 1. i-- ...
Hello guys this is the first chapter of c programming , In this chapter we will learn about basics of c programming ; Here we go to learn c language, Chapter 1 Variable, contest &keywords Variable :- A Variable is a container which stores a 'value' Like in kitchen we use containers storing rice ,Dal,Suger etc. Similarly, To that Variable in c Stores Value of a constast . Example: A=3; //a is assinged"3" b=4.7; //b is assigned "4.7" c='A' ; //c is assinged "a" Rules of naming variable in C :- 1. First character must be an alphabet or underscore(_). 2. No commas , blanks allowed 3. No special symbol other than (_) allowed. 4. variable names are case sensitive We Must create meaningful variable names in our programs. This enhance raedabibly of our programs. Ques: What is variab...
Comments
Post a Comment