Switch statement

August 19, 2019


Read any month number and display Month name in word
using of switch statement



Hello friends, in this blog we see the use of switch statement. Switch statement is also known as switch case because in this cases are executed according to user choices. This is multiple or multiway branching statement. Switch statement checks whether an expression matches any one of the constant value or not if not the control is transfer to the next statement. If none of any case matches the control is transfer to default condition.

Syntax:
                   switch(expression)
                         {case 1:
           statement 1;
           break;
                                  case 2:
           statement 2;
           break;
                                 case 3:
          statement 3;
          break;
.
.
.

       case n:
          statement n;
           break;
                                  default:
           statement;
                                 }
C program for read any month number and display Month name in word

#include<stdio.h>
#include<conio.h>
void main()
{
int n; //declar integer n
clrscr(); //to clear output screen
printf("Enter the month No:-> ");
scanf("%d",&n);  //store the input in n variable
   switch(n) //pass the value of n in switch case
   {
          case 1:
          printf("January\n");//if n=1 the Jaunary will print
                 break;
                 //to break or stop the execution and pointer goes to next step
          case 2:
          printf("February\n");
                 break;
          case 3:
          printf("March\n");
                 break;
          case 4:
          printf("April\n");
                 break;
          case 5:
          printf("MAy\n");
                 break;
          case 6:
          printf("June\n");
                 break;
          case 7:
          printf("July\n");
                 break;
          case 8:
          printf("August\n");
                 break;
          case 9:
          printf("September\n");
                 break;
          case 10:
          printf("October\n");
                 break;
          case 11:
          printf("November\n");
                 break;
          case 12:
          printf("December\n");
                 break;
          default:
          //if all 12 conditions are returns false then default will execute
          printf("Invalid Month number\nPlease try again ....\n");
                 break;
      }
getch();
}
________________________________________________________

Output:
Enter the month No:0
Invalid Month number
Please try again ....

Enter the month No:7
July

Enter the month No:3
March

Enter the month No:1
January

Enter the month No:9
September

Enter the month No:13
Invalid Month number
Please try again ....


Switch statement Switch statement Reviewed by Amit Waghmare on August 19, 2019 Rating: 5

Volume of cylinder C language

August 14, 2019
C program for volume of Cylinder

          Hello friends, in this blog we see the c program for finding the Volume of cylinder. To find the volume of a cylinder we must know the formula for calculating the area of cylinder i.e. vol = pie * r * r * h.
In this formula the value of is in float i.e. 3.14, so we are using float datatype and for store fractional value we use %f. By using the following program, we find the area of the cylinder.

C language code for Volume of cylinder:
#include<stdio.h>
#include<conio.h>

void main()
{
    float vol,pie=3.14;

    float r,h;

    clrscr();

    printf("ENTER THE VALUE OF RADIUS:");

    scanf("%f",&r);

    printf("ENTER THE VALUE OF HEIGHT:");

    scanf("%f",&h);

    vol = pie * r * r * h;

    printf("VOLUME OF CYLINDER IS : %f ",vol);

    getch();

}
Output:­
ENTER THE VALUE OF RADIUS: 7
ENTER THE VALUE OF HEIGHT :3
VOLUME OF CYLINDER IS: 461.58

ENTER THE VALUE OF RADIUS: 4.6
ENTER THE VALUE OF HEIGHT: 6.8
VOLUME OF CYLINDER IS: 451.80832



Volume of cylinder C language Volume of cylinder C language Reviewed by Amit Waghmare on August 14, 2019 Rating: 5

Area of circle in C language

August 14, 2019


C program for area of circle

          Hello friends, in this blog we see the c program for finding the area of the circle. To find the area of the circle we must know the formula for calculating the area of circle i.e. area = 3.14 * radius * radius.
In this formula, the value of is in float i.e. 3.14, so we are using float datatype and for store fractional value we use %f. By using the following program we find the area of the circle.

C language code for Area of Circle:
#include<stdio.h>
#include<conio.h>

void main()
{
   float radius, area;/* to accept floating number*/

   printf("\nEnter the radius of Circle : ");
           //take input from the user

   scanf("%f", &radius);
      /* to store the floating number,
       &radius is used to store the number in radius variable*/

   area = 3.14 * radius * radius;
    // formula and answer store in area variable

   printf("\nArea of Circle : %f  sq.unit", area);  // display answer
   getch();
}
_____________________________________________________________
Output:
Enter the radius of Circle:3
Area of Circle:28.26

Enter the radius of Circle:9.54
Area of Circle: 285.776424





Area of circle in C language Area of circle in C language Reviewed by Amit Waghmare on August 14, 2019 Rating: 5

Consonant and vowels

August 12, 2019




Count Consonant and Vowels

            Hello friends, here we are seeing the c program for the count the number of the vowel and consonant in the given string. We know a, e, i, o, u are five vowels. But how we check how many times the vowels and consonant have come in the sentence. So by using the following c program we easily count the number of vowels and consonant in the given string.


C language code for count the consonant and vowel:
#include<stdio.h>
#include<conio.h>
void main()
{
            int c=0,count=0;
            char s[1000];
            int i;
            clrscr();

printf("Enter the string:"); //for take a string from user

gets(s);//this function is use to store the string

    for(i=0;s[i]!='\0';++i); //for accessing each character from the string and count the character

    printf("Length of given string: %d\n", i);//print the no of character including space

while(s[c]!='\0')//string is not null
            {

              if(s[c]=='a' || s[c]=='A' || s[c]=='e'|| s[c]=='E' || s[c]=='i' ||
              s[c]=='I' || s[c]=='o' || s[c]=='O' || s[c]=='u' || s[c]=='U')
              //compares vowels with each and every character

              count++;// for counting the vowels

              c++; //go to next character

            }

            printf("The no of vowels in the given string is:%d\n",count);
            // no of vowels in a given string

            printf("Number of Consonent with spaces in the given string:%d\n",i-count);
            //no of the consonant in the given string

            getch(); //this function holds the output screen
}

Output:
Enter the string: c language
Length of given string:10
The no of vowels in the given string is:4
Number of Consonant with spaces in the given string:6



Consonant and vowels Consonant and vowels Reviewed by Amit Waghmare on August 12, 2019 Rating: 5

Number of vowels

August 11, 2019


Check the number of vowels in the given string


                 Hello friends, here we are seeing the c program for the count the number of the vowel in the given string. We know a, e, i, o, u are five vowels. But how we check how many times the vowels have come in the sentence. So by using the following c program we easily count the number of vowels in the given string.

C language code for count the vowel:

#include<stdio.h>

#include<conio.h>

void main()

{
int c=0,count=0;
char s[1000];
clrscr();
printf("Enter the string:");
gets(s);
while(s[c]!='\0')
            {
              if(s[c]=='a' || s[c]=='A' || s[c]=='e'|| s[c]=='E' || s[c]=='i' ||
              s[c]=='I' || s[c]=='o' || s[c]=='O' || s[c]=='u' || s[c]=='U')

            count++;
              c++;
            }
            printf("The no of vowels in the given string is:%d\n",count);
            getch();
}
______________________________________________
Output:
Enter the string: ccpptutoriallands_blogspot_com
The no of vowels in the given string is:8


Number of vowels Number of vowels Reviewed by Amit Waghmare on August 11, 2019 Rating: 5

Introduction to python

August 11, 2019

python

Introduction to Python Programming 

Hello friends, in this blog we see what is Python programming? With examples. First, we see what is the background of python, means the history of Python.
            Python is a high-level programming language and this language is developed by Guido van Rossum. The first version of Python language is developed and released in 1991. Python is developed for programming because other programming languages are large in size, so to find an error in that large programs is so difficult, to overcome this Python is developed.
Features of python programming:
1.       High level programming language: This language is closely related to human-readable language rather than Machine language.

2.       Python is a free and open-source language: The python setup is free to download, so it is free and open-source language.

3.       Python is simple: Python code is very small or compact as compared to other languages like c, c++, JAVA.

4.       Error checking and high-level data type: Python offers more effective error checking mechanism than C. Python is having a built-in high-level data type for example dictionaries and flexible arrays.

5.       Platform independent language: It means you can write your Python program in one machine and run that same code on another machine which has python. Python runs on any OS like Windows, Unix, DOS, etc.

6.       User friendly: Python language is having the feature of abstraction and hiding of the details which makes it more user-friendly. We can divide the program into modules that you can be used in other python programs.

7.       Extensible: If you are writing an application in C and you are linking the python interpreter into an application then you can use it as an extension or command language for that application.

8.       Python is object-oriented: Python supports the object-oriented programming concept, but OOPS is optional in python. When you/we are using or writing a python program that time we feel like we write the program in python.


Friends these features are used when we are writing the code in python. In next blog we see the actual programs of python.

Introduction to python Introduction to python Reviewed by Amit Waghmare on August 11, 2019 Rating: 5