Break and Continue in C language | part 9 =total programming

                     C break and continue

Hello Guys, in this post I am going to show you C Break and Continue,

So, Let get started =


C break


Definition = The break statement ends the loop immediately when it is encountered.

Syntax       =  break;

Flowchart =



Example =

#include<stdio.h>
#include<conio.h>
void main()

{
   int i;
   double number, sum = 0.0;

   for (i = 1; i <= 10; ++i) {
      printf("Enter n%d: ", i);
      scanf("%lf", &number);

      // if the user enters a negative number, break the loop
      if (number < 0.0) {
         break;
      }

      sum += number; // sum = sum + number;
   }

   printf("Sum = %.2lf", sum);
   
}



C continue


Definition  = The continue statement skips the current iteration of the loop and continues with the next                         iteration.

Syntax        = continue;

Flowchart  =










Example =

#include<conio.h>
#include<stdio.h>
void main() 
{
   int i;
   double number, sum = 0.0;

   for (i = 1; i <= 10; ++i) {
      printf("Enter a n%d: ", i);
      scanf("%lf", &number);

      if (number < 0.0) {
         continue;
      }

      sum += number; // sum = sum + number;
   }

   printf("Sum = %.2lf", sum);

}




Switch Case in C language | part 8 = total programming

                                                            Switch Case in C language

SWITCH CASE =

  DEFINITION = Switch Case is a statement in C language. The switch statement in C tests the value of a variable and compares it with multiple cases. Once the case match is found a block of statements associated with that particular case is executed.

    SYNTAX = The general syntax for Switch Case is as follows =

                                     switch( expression )

{
	case value-1:
			Block-1;
			Break;
	case value-2:
			Block-2;
			Break;
	case value-n:
			Block-n;
			Break;
	default:
			Block-1;
			Break;
}
Statement-x; 

 KEYWORDS IN SWITCH CASE = switch, case, break, and default.


FLOWCHART OF SWITCH CASE =



Example =

#include <conio.h>
#include <stdio.h>
void main()
{
   int x = 2;
   switch (x)
   {
       case 1: printf("Choice is 1");
               break;
       case 2: printf("Choice is 2");
                break;
       case 3: printf("Choice is 3");
               break;
       default: printf("Choice other than 1, 2 and 3");
                break
   }

}

Calculator Program in C language | part 7 = total programming

                                                                    Calculator Program

Hello guys, in this post I am going to give you a practice program which is an ATM program it is very simple which not include any graphics.

so let us move on to the program.

Source code =

#include<stdio.h>

#include<conio.h>

void main()

{

      

        float ch,ad1,ad2,sb1,sb2,mt1,mt2,di1,di2;

    

        printf("\n\t\nplease enter what you want to do in calculator");

    

        printf("\n\t1.Addition");

        printf("\n\t2.Subtraction");

        printf("\n\t3.Multiplication");

        printf("\n\t4.Division");

    

        printf("\n\n\tEnter your Choose= ");

        scanf("%f",&ch);

    

        if (ch==1)

        {

            printf("\n\tenter the first digit= ");

            scanf("%f",&ad1);

        

            printf("\n\tenter the second digit= ");

            scanf("%f",&ad2);

        

            float ans1=ad1+ad2;

        

            printf("\n\tAnswer= %f",ans1);

            printf("\n\tAddition is done");

        

        }else if (ch==2)

        {

            printf("\n\tenter the first digit= ");

            scanf("%f",&sb1);

        

            printf("\n\tenter the second digit= ");

            scanf("%f",&sb2);

        

            float ans2=sb1-sb2;

        

            printf("\n\tAnswer= %f",ans2);

            printf("\n\tSubtraction is done");

        

        }else if (ch==3)

        {

            printf("\n\tenter the first digit= ");

            scanf("%f",&mt1);

        

            printf("\n\tenter the second digit= ");

            scanf("%f",&mt2);

        

            float ans3=mt1*mt2;

        

            printf("\n\tAnswer= %f",ans3);

            printf("\n\tMultiplication is done");

            

        }else if (ch==4)

        {

            printf("\n\tenter the first digit= ");

            scanf("%f",&di1);

        

            printf("\n\tenter the second digit= ");

            scanf("%f",&di2);

        

            float ans4=di1/di2;

        

            printf("\n\tAnswer= %f",ans4);

            printf("\n\tDivision is done");

        }

    

}


my youtube video for more information =




ATM program in C language | part 6 = total programming

                                                                     ATM  Program

Hello guys, in this post I am going to give you a practice program which is an ATM program it is very simple which not include any graphics.

so let us move on to the program.

Source code =

#include<stdio.h>

#include<conio.h>

void main()

{

    float p,t;

    float r=7.5;

    int pas;


    printf("\n\n\t\t\t\t\t\t Welcome to our bank");

    

    printf("\n\n\t Please insert your card");

    

    printf("\n\n\t Card is inserted");

    

    printf("\n\n\t enter the password= ");

    scanf("%d",&pas);

    

    if(pas==1234)

    {

        printf("\n\t password is correct");

    }else

    {

        printf("\n\t password is invalid");

        exit(0);

    }

    

    printf("\n\n\t enter the amount you want to take on loan= ");

    scanf("%f",&p);

    

    printf("\n\t Rate of interest= %f",r);

    

    printf("\n\n\t enter the time in years= ");

    scanf("%f",&t);

    

    float si=(p*r*t)/100;

    float ans=si+p;

    

    printf("\n\tamount will be return by you after given time= %f",ans);

    

    printf("\n\n\t\t\t\t\t\t|| thank u visit again ||");

    

}   


my youtube video for more information =



 


Scanf function in C language | Part 5= total programming,C language

                                                   Scanf  function in C language

                                                 

*SCAN F=

            DEFINITION = Scanf function allows the users to put the value for their data in run time.

            SYNTAX = scanf("format string",argument_list); 

            EXAMPLE =

               #include<conio.h>

               #include<stdio.h>    

               void main()

               {    

                        int number;    

                        printf("enter a number:");    

                        scanf("%d",&number);    

                        printf("cube of number is:%d ",number*number*number);     

                 }


My YouTube related to scanf ,please watch=


                                                                                                                  

Loops in C language | Part 4 = total programming,C language

                                                          Loops in C Language


So, hello guys today's topic is LOOP.lets talk about the loop=

A block of looping statements in C are executed for number of times until the condition becomes false.


'C' programming provides us
 
1) while = A "WhileLoop is used to repeat a specific block of code an unknown number of times until a condition is met. 

2) do-while = do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time.
 
3) for loop =while loop in C programming repeatedly executes a target statement as long as a given condition is true. Syntax.


*for loop example=

//example for loop

#include <stdio.h>
#include<conio.h>
void main() 
{
    int n, i;
    printf("Enter an number which multiplication table u want: ");
    scanf("%d", &n);
    for (i = 1; i <= 10; ++i) 
    {
        printf("%d * %d = %d \n", n, i, n * i);
    }
}


*do while loop example=
// do while loop

#include<stdio.h>
#include<conio.h> 
void main() 
{
    int a = 10;

do {
      printf("value of a: %d\n", a);
      a = a + 1;
   }while( a < 20 );
 
}

*while loop example=

// Print numbers from 1 to 5

#include<stdio.h>
#include<conio.h>
void main()
{
    int i = 1;
    
    while (i <= 5)
    {
        printf("%d\n", i);
        i++;
    }
}


all these three type of loop i explained in my YouTube video,please watch it.=



Flowchart = for loop





Flowchart = while loop



Flowchart = do while loop



Datatypes in C language | part 3 total programming = C language

                                                        Datatypes in C language


Hello, guys welcome to part 3 of total programming so today we are going to learn a new topic that is datatypes. so let's a startup to date stopping that is datatypes.

So there are two types of data types=
1] Primitive.
2] Derived. 
*the primitive data type is independent.
*the derived data type is dependent on the primitive data but a little bit to twist of the primitive data type.


I have all information related to this in my YouTube video, please watch it.=






Break and Continue in C language | part 9 =total programming

                           C break and continue Hello Guys, in this post I am going to show you C Break and Continue, So, Let get started = ...