While Loop Programs in C

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Program for while loop 
#include<stdio.h>
#include<conio.h>
int main()
{
      system("cls");
         int i=1; // intilization
         int limit;
         printf("Enter the limit");
         scanf("%d",&limit);
         while(i<=limit) // condition
         {
            printf("%d  ",i);
             i++;     // increment
         }
      return 0;
}

Program 2

// Program for Table of number
#include<stdio.h>
#include<conio.h>
int main()
{
        system("cls");
         int n,i;
         printf("Enter the number");
         scanf("%d",&n);
           i=1;
           while(i<=10)
           {
               printf("%d\n",n*i);
               i++;
           }
   
      return 0;
}

Program 3

// Program for Series
#include<stdio.h>
#include<conio.h>
int main()
{
        system("cls");
         int limit,i;
         printf("Enter the limit");
         scanf("%d",&limit);
           i=1;
           while(i<=limit)
           {
               printf("%d\n",i*i);
               i++;
           }
   
      return 0;
}

Program 4

// Program for Series
#include<stdio.h>
#include<conio.h>
int main()
{
     int i=10;
     while(i)  
     {
        printf("\n%d",i);
        i--;
     }  
      return 0;
}

 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *