Sunday, 30 January 2022

" switch " Statement Full Explanation :

 ** switch Statement :-

                                       switch Statement is used when there is a choice as to which code to execute , depending on the value of a constant expression. Different cases are presented, and are checked one by one to see if one case matches the value of the constant Expression. If a case matches, its block of code is executed. If none of the cases match, the default code is executed.    

  • Syntax of the switch statement :-

  switch(integer or character expression)                                                                                                        

{                       

                                                                                                                                             case constant_1:                                                                                                                                                  

         statement sequence 1;                                                                                                                                  

         break;                                                                                                                                                    

case constant_2:                                                                                                                                                  

        statement sequence 2;                                                                                                                                  

            break;                                                                                                                                                    

case constant_n:                                                                                                                                                  

        statement sequence ;                                                                                                                                      

          break;                                                                                                                                                   

 default :                                                                                                                                                                           

          statement sequence ;                                    //end of switch statement                                     

   }                           

  •     The Flowchart of switch Statement :

                                                      Operation of switch                                                      

  •  Some Programs Using switch Statement :                                                                                                                                                                              
 Q )  Make a Calculator using switch Statement :

Main program :-

#include <stdio.h>

int main()
{
  float a,b,c;
  char ch;
  printf("enter the 1st number");
  scanf("%f",&a);
  printf(" enter the operator [+,-,*,/]\n");
  scanf(" %c",&ch);
  
  printf("enter the 2nd number");
  scanf("%f",&b);
  switch (ch)
  {
    case'+':c=a+b;
      printf("sum of it's=%f",c);
      break;
    case'-':c=a-b;
      printf("subtraction of it's=%f",c);
      break;
    case'*':c=a*b;
      printf("Multiplication of it's=%f",c);
      break;
     case'/':c=a/b;
      printf("division of it's=%f",c);
      break;
     default:
       printf("invalid operator");
       break;    
}

}

Input :


Output :-



  IF YOU HAVE ANY QUARRIES SO YOU CAN DIRECTLY CONTACT WITH US,GO INTO THE CONTACT   INFORMATION PAGE AND THEN TYPE YOUR QUARRIES .

 THANKS FOR VISITING . IF YOU LOVE PROGRAMMING THEN YOU CAN FOLLOW OUR WEBSITE .....

            

Saturday, 29 January 2022

Factorial Program in C full explanation :

 **Factorial Program in C :- 

Factorial program in C: Factorial of n is the product of all positive descending integers. Factorial of  n is denoted by n!. 

 *For example :    (i)  5! = 5*4*3*2*1 = 120

                              (ii)  3! = 3*2*1 = 6

            Here, 5! is pronounced as "5 factorial", it is also called "5 bang" or "5 shriek". The factorial is normally used in mathematics.

           There are many way to write the factorial program in C language. Let's see the 2 ways to  write the factorial program. 

*(i) Factorial Program using loop :-

Main source :-

  #include <stdio.h>

  int main()

 {

  int a, i, f=1;

  printf("\nenter a number to calculate the factorial");

  scanf("%d",&a);

  for(i=1;i<=a;i++)

    {

         f= f*i;

         printf("the factorial of%d=%d"a,f);

     }

  return 0;

}

Input :-

Output :-


(ii) Factorial Program using Recursion in C :-

Main source :-

#include<stdio.h>  

  long factorial(int n);

   int main()  

{  

  int number;  

  long fact;  

  printf("Enter a number: ");  

  scanf("%d", &number);   

   fact = factorial(number);  

  printf("Factorial of %d is %ld\n", number, fact);  

  return 0;  

}

long factorial(int n)  

{  

  if (n == 0)  

    return 1;  

  else  

    return(n * factorial(n-1));  

}

Input :-



Output :-


  IF YOU HAVE ANY QUARRIES SO YOU CAN DIRECTLY CONTACT WITH US,GO INTO THE CONTACT   INFORMATION PAGE AND THEN TYPE YOUR QUARRIES .

 THANKS FOR VISITING . IF YOU LOVE PROGRAMMING THEN YOU CAN FOLLOW OUR WEBSITE .....

            

Friday, 28 January 2022

Write a program in C to check the number is Armstrong Number or not :

 **What  is  Armstrong  Number  :-

                                                    Before going to the Armstrong program , Let's understands what is  Armstrong number and the answer is Armstrong Number is a number that is equal to the sum of cubes of it's digits . Now begin the examples of an Armstrong numbers are 0, 153, 370,371,407 etc Let's try to understand why 371 is an Armstrong Number ....

371  =  (3*3*3)+(7*7*7)+(1*1*1)

Where :

(3*3*3)  =  27

(7*7*7) = 343

(1*1*1) = 1

So :

27+343+1 = 371

Let's see the program :

Main Program :-

#include<stdio.h>  

 int main()    

{    

int n,r,sum=0,temp;    

printf("enter the number=");    

scanf("%d",&n);    

temp=n;    

while(n>0)    

     {    

        r=n%10;    

        sum=sum+(r*r*r);    

        n=n/10;    

      }    

if(temp==sum)    

        printf("armstrong  number ");    

else    

        printf("not armstrong number");    

return 0;

}

Input  :-                                                                                                                                                   


Output :-                                                                                                                                                     

Number is Armstrong                                                                                                                                   

Number is Not Armstrong Number                                                                                                           


                                                                                                                                                                                                                         
  IF YOU HAVE ANY QUARRIES SO YOU CAN DIRECTLY CONTACT WITH US,GO INTO THE CONTACT   INFORMATION PAGE AND THEN TYPE YOUR QUARRIES .

 THANKS FOR VISITING . IF YOU LOVE PROGRAMMING THEN YOU CAN FOLLOW OUR WEBSITE .....

Thursday, 27 January 2022

Write a program to generate the prime numbers in C

   **What is Prime number :-

                                         Prime number is a number that is greater than 1 (>1) and Divided by 1 or  as same. We can't Divide this number with other numbers like 2,3,4.................n .The examples of Prime numbers are 2,3,5,7,11,13,19,17,23,29 etc.

   Let's see the Prime number program in C . In this C program we take an input for   understand the Range . 

   *Let's see the program---


 #include <stdio.h>

int main()

{


   int i, num, n, count;

   printf("Enter the range: \n");

   scanf("%d", &n);

   printf("The prime numbers in between the range 1 to %d:",n);

   for(num = 1;num<=n;num++){

      count = 0;

      for(i=2;i<=num/2;i++){

         if(num%i==0){

            count++;

         break;

      }

   }

   if(count==0 && num!= 1)

      printf("%d ",num);

   }


  return 0;

}

INPUT :-


OUTPUT:-




 IF YOU HAVE ANY QUARRIES SO YOU CAN DIRECTLY CONTACT WITH US,GO INTO THE CONTACT   INFORMATION PAGE AND THEN TYPE YOUR QUARRIES .

 THANKS FOR VISITING . IF YOU LOVE PROGRAMMING THEN YOU CAN             FOLLOW OUR WEBSITE.


Wednesday, 26 January 2022

C Program to Check Whether a Number is Palindrome or Not Palindrome :-

 MAIN PROGRAM:-
                     
  #include <stdio.h>

  void main()
 {
  int a, b, c, d=0;
  printf("enter any number");
  scanf("%d",&a);
  b=a;
  while (a>0)
  {    
     c=a%10;
     d=c+(d*10);
     a=a/10;
  }
  if(b==d)
  {  
     printf("Palindrome");
  }
  else
  {
     printf("not");
  }
  return 0;
}
        INPUT :-

                         

   OUTPUT :-
                     
                              



              




                                                                  --THANK YOU--


Tuesday, 25 January 2022

Write a Program to Find Largest Number Among Three Numbers entered by users :-

MAIN PROGRAM :-

 #include <stdio.h>

int main()

{

  float a,b,c,large;

  printf("enter the 1st no=\n");

  scanf("%f",&a);

  printf("enter the 2nd no=\n");

  scanf("%f",&b);

  printf("enter the 3rd no=\n");

  scanf("%f",&c);

  

  if(a>b&&a>c)

  {

    large=a;

  }

  else if(b>a&&b>c)

  {

    large=b;

  }

  else

  {

    large=c;

  }

  printf("the largest number is=%f", large);

  

  return 0;

INPUT :-

               


OUTPUT :-





                                                      --THANKS FOR VISITING--

Write a C program to read temperature in centigrade and display a suitable message according to temperature state below :-

 MESSAGES ARE SHOWN BELLOW :-

Temp < 0 then Freezing weather

 Temp 0-10 then Very Cold weather 

Temp 10-20 then Cold weather

 Temp 20-30 then Normal in Temp

Temp 30-40 then Its Hot 

Temp >=40 then Its Very Hot .

MAIN PROGRAM :-

#include <stdio.h>

int main()

{

  int temp;

  printf("enter the temparature in centigrade scale=");

  scanf("%d",&temp);

  if(temp<0)

  {

    printf("Freezing weather");

  }

  else if(temp>=0&&temp<10)

  {

    printf("Very Cold weather");

  }

  else if(temp>=10&&temp<20)

  {

    printf("Cold weather");

  }

  else if(temp>=20&&temp<30)

  {

    printf("Normal in Temp");

  }

  else if(temp>=30&&temp<40)

  {

    printf("Its Hot");

  }

  else if(temp>=40)

  {

    printf(" Its Very Hot");

  }

  return 0;

}

 

     INPUT :- 

                     



                OUTPUT:-

                 




                                             --THANKS FOR VISITING THIS WEBSITE--

Monday, 24 January 2022

C program to enter student marks and find percentage and grade :-

A college has the following rules for the grading system:

 1. Below 25 – F

2. 25 to 45 – E

 3. 45 to 50 – D 

4. 50 to 60 – C 

5. 60 to 80 – B

 6. Above 80 – A

MAIN PROGRAM :-

#include <stdio.h>

int main()

{

  int a;

  printf("enter the student marks=");

  scanf("%d",&a);

  if(a<25)

  {

    printf("F");

  }

  else if(a>=25&&a<45)

  {

    printf("E");

  }

  else if(a>=45&&a<50)

  {

    printf("D");

  }

  else if(a>=50&&a<60)

  {

    printf("C");

  }

  else if(a>=60&&a<80)

  {

    printf("B");

  }

  else if(a>=80&&a<=100)

  {

    printf("A");

  }

  else

{

  printf("invalid marks");

}

  return 0;

}

INPUT :-




OUTPUT :-

                                                              



                                              --THANKS FOR VISITING THIS WEBSITE--

Infosys Process Executive Recruitment 2022 | Apply Now

  Infosys Process Executive Recruitment 2022 | Apply Now  Infosys Process Executive Recruitment 2022 |Infosys Recruitment 2022 | Work From H...