6/28/21

C Switch Statement in C Programming Language.

In this tutorial, we are going to learn about Switch Statement in the C programming language. We have already seen if, if-else, nested if-else, condition, etc. If you haven’t read those tutorials then first go and read those tutorials then read them. 

Topics that cover today.

  1. C switch statement
  2. C Switch Syntax
  3. Flow chart of C Switch Statement
  4. Example of C switch statements

So let’s go with our today’s topic. 

C Switch Statement

The C switch statement is used to execute a code block among many alternatives statements. The Switch statement allows the variable to be tested with the statement( Values) also known as Case written in the switch statement and if the statement is verified(true) with a statement then the code written between that statement will execute and then the rest of the code will start executing.

The same thing is also done by the if-else condition. But the syntax of the switch condition is easier to read and understandable for the programmers.

C Switch Statements Syntax.

switch (expression)

{
    case constant-expression1 :

    statements;
    break;                      /* The break function is optional  */
 
    case constant-expression1 :

    statements;
    break

 
    .
    .
    .
    .
     default:

     default statements;

}

Note: - The Break statement in the switch is not compulsory (optional) to add to the program. If the programmer wanted to execute the default statement then the break statement is not added to the program.

If none of the statements matched with the expression then by default statement is automatically displayed on the output screen.

Flow chart of the Switch Statement

Example of Switch Statement

Program to find whether a number is even, odd or negative.

#include<stdio.h>
int main()

{
  int number;

 
  printf("Enter a number: ");

  scanf("%d",&number);

 
  switch( number%2 )

  {
    case 0:

      printf("%d is even.", number);

      break;

    case 1:

      printf("%d is odd.", number);

      break;

    default:

        printf("Sorry...Number is Negative");

  }
 
  return 0;

}

Output:-




People Also Read : Nested IF-Else in C Programming

People Also Read : C Instruction With Example in C Language.

Continue Reading →

6/25/21

CSS Margin Property :- CSS Tutorials

CSS Margin

 CSS Margin property is used to give space around Html elements. You can give some space to your Html elements using this CSS property. It is completely transparent you can’t see any background color when you give this property to elements.

You can also provide margins of Html elements independently such as left, right, bottom and top.   

You can provide the margin of an Html element by using values like - auto, %, length, etc. we can talk about it after some time with a full example. 

The Margin CSS Property basically have 5 property these are: - 

  1. Margin: - This CSS property will apply when the user wants to give margin value in one declaration
  2. Margin-left: - This CSS property will only apply on the left side of the Html element.
  3. Margin-top: - This CSS property is used to set the margin on the top side of the Html element.
  4. Margin-bottom: - This CSS property is used to set a margin on the bottom side of the Html element.
  5. Margin-right: - This CSS property will only apply on the right side of the Html element.

Now, the margin CSS Property also has a different value these values are: -

  1. Auto: - This margin value is set by the browser automatically
  2. Length: - This margin value is set by the user in px, cm, pt, etc
  3. %: - This margin value is set into %( percentages ) Like :- 25%, 30% etc
  4. Inherit: - This margin value is used to inherit margin from its parent element.

Let’s see through An amazing example of this topic.


<html>

<head>
    <title> CSS Margin Property </title>
    <style>
        .container{
            displayflex;
        }
       .box
        width216px;
        height209px;
        margin30px 30px 30px 30px;
       }
       #box1 {
            border3px solid red;
            background-colorrgb(204157157);
       }
       #box2{
            border3px solid green;
            background-colorrgb(157204182);
       }
       #box3{
            border3px solid blue;
            background-colorrgb(219230121);
       }
       #box4{
            border3px solid purple;
            background-colorrgb(163158233);
       }
    </style>
</head>

<body>
  <div class = "container">
      <p class=  "box" id="box1"> Box 1 </p>
      <p class = "box" id="box2"> Box 2 </p>
      <p class = "box" id="box3"> Box 3 </p>
      <p class = "box" id="box4"> Box 4 </p>
  </div>
</body>

</html>

Output :-


In the above example, we have seen the margin CSS property. We provide margin property to all the boxes in a single declaration. Now we are going to give different CSS property to all boxes.

But before the example let see an example in which we didn't give any margin in the Html document. Look at the image below in this image you will see that all the boxes are combined together. There is no space between them. 


Now, look at the example below. In this example, we applied different margin properties to the different boxes. 

Example: - 
<html>
<head>
    <title> CSS Margin Property </title>
    <style>
        *{
            margin0%;
            background-colorrgb(209190190);
        }
        .container{
            displayflex;
        }
       .box
        width216px;
        height209px;
        margin-left30px;
       }
       #box1 {
            border3px solid red;
            background-colorrgb(204157157);
       }
       #box2{
            border3px solid green;
            background-colorrgb(157204182);
            margin-right50px;
       }
       #box3{
            border3px solid blue;
            background-colorrgb(219230121);
            margin-top100px;
       }
       #box4{
            border3px solid purple;
            background-colorrgb(163158233);
       }
    </style>
</head>

<body>
  <div class = "container">
      <p class=  "box" id="box1"> Box 1 </p>
      <p class = "box" id="box2"> Box 2 </p>
      <p class = "box" id="box3"> Box 3 </p>
      <p class = "box" id="box4"> Box 4 </p>
  </div>
</body>
</html>

Output: -


People Also Read: - CSS Tutorial : CSS Border Radius Property

People Also Read: -  CSS Tutorials :- CSS Background Property

Continue Reading →

6/21/21

How to Make a Jpg image to pdf?

Converting an image into pdf is very easy but some people don’t know how to make a pdf of an image. So friend’s today tutorial based on it. I know a lot of people already know about it. If you know that great, but friend here, there are many other people who don’t know how to convert. In this tutorial, I am going to tell you many methods to convert an image into pdf. So Let’s Begin…

OFFLINE METHOD

In Window & laptop using MS Word

As we have written in our title you can make a pdf through MS Word. Here is the Step to make pdf through MS Word.

1. Open MS Word


2. Go to the Insert menu & Click on the picture option given on it.


3. Now Select the image which you want to convert into pdf. 


4. After it, press f12 key from your keyboard. 

5. Select the location where you want to save your pdf.

6. Now select the save as type as .pdf and then press Enter to Save.

Using PowerPoint

You can also convert an image to pdf using PowerPoint. You just need to follow the same procedure in PowerPoint as you followed in MS word.

ONLINE METHOD

If you have internet connectivity on your laptop or computer. Then you don’t need to follow the above steps. You just need to go to the website given below and just select the convert jpg to pdf option from the given options. And just drag the image on the window screen and press convert your image is successfully converted into pdf.  

Let’s see an example below.

Steps:- 

1. Open Google Chrome and go to the Search bar. 

2. Type “Image to pdf Converter” and press Enter.


3. Now you can see there is a lot of websites which is converting image to pdf. But my favorite is ilovepdf.com. Open the link in the new tab.




4. Now drag the image or open the image which you want to convert into pdf. 



5. Choose the pdf style (Portrait or landscape). And Also the Margin of the pdf. 



6. After it clicks on the Convert to pdf option


For me, the online method is the easiest method. You just need to drag the image and press the convert button and your pdf will ready to download. But when you stuck in a situation where you haven’t internet access in your laptop, pc, & mobile. You should go with the first method and make your pdf without the internet.


These are the two methods to making an image to pdf. We have discussed these two methods (Online & Offline). Hope you guys are understood well. 


Continue Reading →

6/19/21

C Program to Convert the ASCII code to Character.

C Program to Convert the ASCII code to Character.


#include<stdio.h>

void main()
{
int a;
char ch;
printf("Enter any ch ASCII Code=");
scanf("%d",&a);
ch=a;
printf("Code is %d is %c",a,ch);
getch();
}

Output:-





Continue Reading →

6/17/21

CSS Border Radius Property :- CSS Tutorials

Hey Friends, in the last tutorial we had seen the CSS Border Property. There are 4 attributes in CSS border property. We have already discussed the first 3 attributes (color, width, and style). If you haven’t read then read the previous one first then read this tutorial. Now we are going to discuss the CSS Border Radius property. So let’s Begin….

CSS Border Radius Property 

This CSS property is used to set the rounded corner of the Html elements. It defines the radius of the element. We can change all four corners of the box with different values. The Value of this property can be defined in percentage and length units. This CSS Property has four attributes. These are:- 

  1. Border-top-left-radius
  2. Border-top-right-radius
  3. Border-bottom-left-radius
  4. Border-bottom-right-radius

Let see an amazing example of it. 

Example:- 

<html>
<head>
    <title> CSS Border Radius Property </title>
    <style>
        *{
            margin30px;
        }
        body{
            displayflex;
        }
       .box{
           padding23px;
           height20%;
           width20%;
           border-stylesolid;
           border-radius23%;
       }
       #box1{
           background-colorburlywood;
       }
       #box2{
           background-colorcornflowerblue;
       }
       #box3{
           background-colordarkgray;
       }
       #box4{
           background-colordarkorchid;
       }
        
    </style>
</head>
<body>
  <p class="box" id="box1"> Box 1</p>
  <p class="box" id="box2"> Box 2</p>
  <p class="box" id="box3"> Box 3</p>
  <p class="box" id="box4"> Box 4</p>
</body>
</html>

Output:-

In this example, you saw how all the corners of the box got rounded. If the user want to corner only the left side of the box. Then you have to select the border-top-left-radius attribute. Now the below example will show you to change all the box corner with different values. 

Example:-

<html>
<head>
    <title> CSS Border Radius Property </title>
    <style>
        *{
            margin30px;
        }
        body{
            displayflex;
        }
       .box{
           padding23px;
           height20%;
           width20%;
           border-stylesolid;
       }
       #box1{
           background-colorburlywood;
           border-top-left-radius20px;
           border-top-right-radius30px;
           border-bottom-left-radius40px;
           border-bottom-right-radius50px;
       }
       #box2{
           background-colorcornflowerblue;
           border-top-left-radius5px;
           border-top-right-radius10px;
           border-bottom-left-radius15px;
           border-bottom-right-radius20px;
       }
       #box3{
           background-colordarkgray;
           border-top-left-radius56px;
           border-top-right-radius72px;
           border-bottom-left-radius33px;
           border-bottom-right-radius33px;
       }
       #box4{
           background-colordarkorchid;
           border-top-left-radius40px;
           border-top-right-radius35px;
           border-bottom-left-radius25px;
           border-bottom-right-radius15px;
       } 
    </style>
</head>
<body>
  <p class="box" id="box1"> Box 1</p>
  <p class="box" id="box2"> Box 2</p>
  <p class="box" id="box3"> Box 3</p>
  <p class="box" id="box4"> Box 4</p>
</body>
</html>

Output:-


People Also Read:- CSS Background Property

People Also Read:- CSS Selectors and Different types of Selectors

Continue Reading →

6/16/21

CSS Border Property :- CSS Tutorials


Hey Friends, in the last tutorial we have seen about the CSS background property. Now, this tutorial is based on CSS Border Property. So let’s begin...

CSS Border Property

The CSS border property is a property that is used to set the border of Html elements. This property is used to specify the color, style and the size of the border of an element. There are some border property shown below:-

  1. Border-color
  2. Border-style
  3. Border-radius
  4. Border-width

Now we are going to discuss these properties in detail.

1) Border Color CSS Property

This border property is used to specify the color of the border. There are 3 methods to set the color of the border these are:- 

  1. Name:- It Specifies the name of the color. For Example:- “Red”, “Yellow” etc
  2. RGB :- It Specifies the RGB value of the color. For Example :- rgb(0,0,0,0), rgb(1,8,6,2.5) etc
  3. Hex :- It Specifies the hex decimal value of the color. For Example :- #ff000, #f2f2f2 etc

Example:- 

    
<style>
        body{
            displayflex;
            
        }
        div{
            margin10px;
        }
        #first {
            border-stylesolid;
           border-colorred;
            width23%;
            height20%;
        }

        #second {
            border-stylesolid;
            border-colorrgb(00,0);
            width23%;
            height20%;
        }

        #third{
            border-stylesolid;
            border-color#7f23d4;
            width23%;
            height20%;
        }
    </style>

Output:- 

2) Border Style CSS Property 

This CSS Border Style Property is used to specify the border type which you want to display in your Html file. There is a lot of border-style value from where you can select the different types of border style to border an element. 

  • None
  • Dotted
  • Dashed
  • Solid
  • Double
  • Groove
  • Inset
  • Outset
  • Ridge

Example:-

<html>
<head>
    <title> CSS Border Property </title>
<style>
    p.none {border-stylenone;}  
    p.dotted {border-styledotted;}  
    p.dashed {border-styledashed;}  
    p.solid {border-stylesolid;}  
    p.double {border-styledouble;}  
    p.groove {border-stylegroove;}  
    p.ridge {border-styleridge;}  
    p.inset {border-styleinset;}  
    p.outset {border-styleoutset;}  
    p.hidden {border-stylehidden;}
</style>
</head>

<body>
    <p class="none">No border.</p>  
    <p class="dotted">A dotted border.</p>  
    <p class="dashed">A dashed border.</p>  
    <p class="solid">A solid border.</p>  
    <p class="double">A double border.</p>  
    <p class="groove">A groove border.</p>  
    <p class="ridge">A ridge border.</p>  
    <p class="inset">An inset border.</p>  
    <p class="outset">An outset border.</p>  
    <p class="hidden">A hidden border.</p>  
</body>
</html>

Output:- 

3) Border Width CSS Property

This property is used to set the width or the border. It is set in pixels. You can also select from pre-defined values like - thin, thick, and medium

Note: - This property is not worked alone means you have to use border-style property first then you can set the width of the border.

Example:- 

<html>
<head>
    <title> CSS Border Property </title>
    <style>
        body{
            displayflex;
            
        }
        div{
            margin10px;
        }
        #first {
            border-stylesolid;
           border-colorred;
           border-width1px;
            width23%;
            height20%;
        }

        #second {
            border-stylesolid;
            border-colorrgb(00,0);
            border-widththick;
            width23%;
            height20%;
        }

        #third{
            border-stylesolid;
            border-color#7f23d4;
            border-width10px;
            width23%;
            height20%;
        }
    </style>
</head>

<body>
    <div id="first">
        Lorem ipsum dolor sit, id, ab aspernatur officiis, hmagnam atque pariatur alias iure itaque facere placeat
        nesciunt enim odit corporis? Provident.
    </div>
    <br>
    <br>
    <div id="second">
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab pariatur modi amet deleniti, quisquam alias
        accusantium ipsa veritatis! Voluptate delectus nihil veritatis facere autem voluptatum et!
    </div>
<br><br>
    <div id="third">
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta, qui. 
    </div>
</body>
</html>

Output:- 

So Friend that’s all for this tutorial as you can see I have told only three property border-style, border-color, & border-width the last property is border-radius. We will discuss it in the next tutorial because the content of this property is very large so I thought that I have to make a separate tutorial on this topic.  

People Also Read :- CSS Background Property 

People Also Read :- How to Add CSS in HTML File.

Continue Reading →

6/12/21

CSS Background Property Part - 2 :- CSS Tutorials


3) CSS Background Repeat

If your image is small then by default image is repeated horizontally and vertically. Sometimes the user does not want to repeat its background image. Then in this situation, you can set the no-repeat value in the background-repeat CSS property. 

But if the user wanted to repeat it background image only horizontally not vertically then you have to use the repeat-x value in the background-repeat CSS property. And it also applies vertically you just need to change x and change it to y. x is used horizontally and y is used vertically.

Let us see through an example

Example:-

For no-repeat CSS Value 

<html>
<head>
    <title> CSS Background Property </title>

 

    <style>
        body{

            background-image: url(ex.jpg);

            background-repeatno-repeat;

        }
        }
    </style>
</head>
<body>
   <h1> CSS Background Color Property.</h1>
   <h2> This is 2nd Heading.</h2>
   <p> This is a Paragraph. </p>
</html>

Output :-  

For Repeat

Example :-

<html>
<head>
    <title> CSS Background Property </title>
    <style>
        body {

            background-imageurl(ex.jpg);

            background-repeatrepeat;

        }
    </style>
</head>
<body>
    <h1> CSS Background Color Property.</h1>
    <h2> This is 2nd Heading.</h2>
    <p> This is a Paragraph. </p>
</body>
</html>

Output :- 


4) Background Attachment

This Background CSS property is used when the user doesn’t want to scroll the background image. He just wanted to scroll only the content written on the Html document. You can either scroll the image of the background or fixed it in that position. 

Let’s us see through Example 

Example:- 

 <style>
        body {

            background-image: url(ex.jpg);
            background-repeat: no-repeat;
            background-attachment:fixed;
        }
    </style>

Output :-  


5) Background Position

This Background CSS Property is used to position the background image on the browser. You can place the background image anywhere in the browser you just need to write the background-position property. Let’s see it through an example.

Example :- 

<html>
<head>
    <title>
CSS Background Property </title>
    <style>
        body {

            background-image: url(ex.jpg);
            background-repeat: no-repeat;
            background-attachment:fixed;
            background-position: center; 
        }
    </style>
</head>
<body>
    <h1>
CSS Background Color Property.</h1>
    <h2> This is 2nd Heading.</h2>
    <p> This is a Paragraph. </p>
    <P>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quidem deleniti rerum, nobis ipsum neque eveniet ullam et ab voluptate cum quod, dicta beatae sed rem? Nam distinctio quis obcaecati sit.
</body>
</html>

Output:- 


Continue Reading →

Follow on Twitter

Linkedin

Categories

Mad About Computer. Powered by Blogger.
This site is in no way affiliated with or endorsed by specified business. It exists as a compendium of supporting information intended for informational purposes only. If you want to buy this website, please don't hesitate to contact us via e-mail: "d e n a c c 9 7 7 (at) g m a i l (dot) c o m" (delete spaces) or you can find and buy it on Afternic domain auctions.