Posts

Showing posts from April, 2020

data type & declaration

Image
Basic data type The basic data types are datatypes already defined in the programing language Youtube tutorial: Declaring variable All varaiable present in the program must be declared before it is used. The generalform is data-type variable list; Initializing variables  The process of assigning initial value to variable during declaration is called initializing variable The general form is, data-type variable = initial value; Example int a = 10; Assigning value to variables giving values to variable is called assigning values to variable The general form is variable-name = value; Example a=10; cd=25; Declaring variable as constants A constant is quality whose value does not change during program execution The general form is const data-type variable = value; where    const  -- keyword    data-type -- int,float,etc.. Exa...

switch-statement

Image
Switch statement  switch statement is an extension of if...else statement. This permits any number of branches. The general form is switch(expression) { case 1 statement block-1; break; case 2 statement block-2; break; .............. .............. .............. case n statement block-n; break; default  default statement; break; } next statement; the value of the expression will check with the case 1, case2,...casen if any case will matches then execute that case statement.then it moves to the next statement. flow diagram: Example program: #include<stdio.h> #include<conio.h> void main() { int number; clrscr(); printf("Enter your exam mark"); scanf("%d",&number); switch(number) { case 35: printf("low mark"); break; case 50: printf("better mark"); break; case 90: printf(...

for-loop

Image
For statement For statement is used to execute a statement or a group of statement for a known number of times. the general form for(control-variable;condition;increment/decrement) { body of the loop } next statement; If the value of the condition is true then the body of the loop will be executed, then the value of the control-variable will be incremented or decremented.when the conditionis false then the control is transferred to the next statement Block diagram of for-loop Example program #include<stdio.h> #include<conio.h> void main() { int i,sum=0; clrscr(); for(i=1;i<=10;i++) { sum=sum+1; } printf("sum=%d",sum); getch(); } Switch statement   switch statement is an extension of if...else statement.This permits any number of branches. the General fornm is  switch(expression) { case 1 statement block-1; brea...

do-while

Image
Do …while –loop T his statement is executed the body of the loop is will execute first. The general form is do { Body of loop } While(condition); Next statement; when this statement is executed the body of the loop will be executed first then the condition is evaluated. if the value will be true then the body of the loop will be executed. if the value will be false then it will move to next statement. Block diagram of do...while loop example program: #include<stdio.h> #include<conio.h> void main() { int i=1; do { printf("hello world!"); i++; } while(i<5); getch(); } youtube tutorial: For-Loop for statement is used to execute a statement or a group of statement for a known number of times. the general form for(control-variable;condition;increment/decrement) { body of the loop } next statement; Read   Mor...

looping statement

Image
looping statements loop structure are used to execute a group of statements repeatedly until the condition is satisfied. They are     While -loop Do…while-loop For-loop While-loop This will be a simple loop statement.  The general loop structure is While(condition) { body of the loop; } Next statement; When the statement is executed then it will checks the condition is false or not? If it is false then move to next statement or it is true then the loop body will be execute. When the condition becomes false then the control is transferred to next statement Flowchart : Example code for c program #include<stdio.h> #include<conio.h> void main() { int i =1; while (i<=5)   {     printf(“hello world\n”);     i++;   } getch(); } youtube tutorial ...

nested-if

Image
Nested if condition The block of code following the else statement is executed as the condition present in the if statement is false. nested-if. Nested if statements means an if statement inside another if statement syntax if(condition-1) {     if (condition-2)        {         statement        }     else        {         statement block-2;        } } else  {    statementblock-3;  } Flow chart Example for nested if condition in [c-program] #include< stdio.h> void main() {   int a,b,c;   printf("Enter three number");   scanf("%d%d%d",&a,&b,&c);     if(a>b)       {         if(a>c)         ...

else-if

Image
if...else if condition The if-else-if Ladder. A common programming construct that is based upon nested ifs is the if-else-if ladder. It looks like this. The conditional expressions are evaluated from the top downward. As soon as a true condition is found, syntax if(condition1) {    statement } else if(condition2) {    statement } -------------------------- -------------------------- else {   default statement } Flow chart Example for if...else if condition in[c-program] #include< stdio.h > /* header file */ #include< conio.h > /* header file */ void main() /* main function start*/ {   int mark;   clrscr();   printf("enter the mark \n ");   scanf("%d",&mark);   if(mark<=30)   {          printf("fail & very low mark\n");   }    el...

if-else

Image
IF..else CONDITION if...else statement is used to execute one group of statement.If the boolen value is equal to true then, the if statement is execute . Otherwise the Else statement will be execute Syntax if(condition) {    true-statement } else {    false-statement } Flow chart for if...else Example for if...else condition in[c-program] #include< stdio.h >           /* header file */ #include< conio.h >           /* header file */ void main()                   /* main function start*/ { int a=10,b=5;                 /*declaring a value*/ clrscr(); printf("the value of a is %d",a); printf("\n the value of b is %d",b); if(a>b)         ...

If condition

Image
IF CONDITION Decision making statement are used to jump or execute a group of statement. If condition is used to execute or skip a group of statment for a condition syntax if(condition) {       statement block; } other statement; flow chart for if condition Example code for if condition in [c-program] #include< stdio.h >   /* header file */ #include< conio.h >   /* header file */ void main()   /* main function start*/ {    int a=10,b;    clrscr();    if(a==10)     {      b=a+a;     }    printf("%d",b);     getch(); } youtube tutorial

if,else-if nested-if

Image
If conditon statement if condition statement An if statement is a programming conditional statement that, if proved true, performs a function or displays information. Below is a general example of an if statement, not specific to any particular programming language.... Read   More If...else condition statement If...else condition statement The else statement specifies a block of code to be executed if the condition is false: if (condition) { // block of code to be executed if the condition is true. } else { // block of code to be executed if the condition is false.... Read More else if ladder condition statement    else if ladder condition statement The if-else-if Ladder. A common programming construct that is based upon nested ifs is the if-else-if ladder. It looks like this. The conditional expressions are evaluated from the top downward. As soon as a true ...