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

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more