Tech Study

Write a C program to print all natural numbers from 1 to n

Introduction

Write a C program to print all natural numbers from 1 to n

#include <stdio.h>

int main()
{
    int i, num;
    //Reading number
    printf("Enter any number: ");
    scanf("%d", &num);

    printf("Natural numbers from 1 to %d \n", num);

    /* Starting loop from i=1 & priting value of i
     to get natural numbers */
    for(i = 1; i <= num; i++)
    {
        printf("%d\n", i);
    }

    return 0;
}

Result

TaggedWrite a C program to print all natural numbers from 1 to n

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more