Line Break Tag

Image
Line Break Tag Line Break टैग, या `<br>` टैग, HTML का एक inline टैग है जिसका उपयोग टेक्स्ट या सामग्री को एक लाइन से दूसरी लाइन पर ले जाने के लिए किया जाता है। जब आप `<br>` टैग का इस्तेमाल करते हैं, तो वहां जहां यह टैग होता है, वहां का टेक्स्ट या सामग्री एक नई लाइन पर आता है। यहां एक उदाहरण है: ```html <p>यह एक लाइन है।<br>यह दूसरी लाइन है।</p> ``` इस उदाहरण में, `<br>` टैग का उपयोग से "यह एक लाइन है।" और "यह दूसरी लाइन है।" को अलग-अलग लाइनों पर दिखाया जाएगा, जबकि `<p>` टैग से दोनों को एक पैराग्राफ के रूप में प्रदर्शित किया जाएगा। इस टैग का उपयोग किसी भी स्थिति में किया जा सकता है जब आपको टेक्स्ट या सामग्री को अलग लाइनों पर रखना हो, जैसे कि पता, कविता, या गाने के बोल। 

C Program to find sum of first n natural numbers

C Program to find the Sum of First n Natural numbers

Program to find the sum of first n natural numbers. We will see two C programs to calculate the sum of natural numbers. In the first C program we are using for loop for find the sum and in the second program we are doing the same using while loop.
To understand these programs, you should be familiar with the following C Programming Concepts:

  1. C Programming for loop
  2. C Programming while loop

Example 1: Program to find sum of natural numbers using for loop

The user enters the value of n and the program calculate the sum of first n natural numbers using for loop.

#include <stdio.h>
int main()
{
    int n, count, sum = 0;

    printf("Enter the value of n(positive integer): ");
    scanf("%d",&n);

    for(count=1; count <= n; count++)
    {
        sum = sum + count;
    }

    printf("Sum of first %d natural numbers is: %d",n, sum);

    return 0;
}

Output:

Enter the value of n(positive integer): 6
Sum of first 6 natural numbers is: 21

Example 2: Find the sum of natural numbers using while loop

#include <stdio.h>
int main()
{
    int n, count, sum = 0;

    printf("Enter the value of n(positive integer): ");
    scanf("%d",&n);

    /* When you use while loop, you have to initialize the
     * loop counter variable before the loop and increment
     * or decrement it inside the body of loop like we did 
     * for the variable "count"
     */
    count=1;
    while(count <= n){
    	sum = sum + count;
    	count++;
    }

    printf("Sum of first %d natural numbers is: %d",n, sum);

    return 0;
}

Output:

Enter the value of n(positive integer): 7
Sum of first 7 natural numbers is: 28

Comments

Popular posts from this blog

What is HTML Element

O"Level Syllabus Update 2020

What is WWW?