Adsense 728 * 15

Search

Custom Search

Write Program to Print 1 to 100 numbers using loop

Write a program to print 1 to 100 numbers using a loop. This is very simple program for beginners to understand how loop works.

Basic programs for practice

Print ASCII value of input character

Add two numbers

Program to Print 1 to 100 numbers using loop


1. Using For loop to print 1 to 100 numbers.


#include<stdio.h>

int main(){
 
    int i;
   
    for(i = 1; i <= 100; i++){
     
      printf("%d ",i);
    }

    return 0;
}





2. Using while loop to print 1 to 100 numbers.

 


#include<stdio.h>

int main(){

    int i=1;
 
    while( i  <= 100){
   
    printf("%d ", i);
    i++;
    }

    return 0;
}


No comments:

Post a Comment