-->

program to print/display 1,8,27... to 10th term.

//program to print/display 1,8,27... to 10th term.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n;

while(k<=10)
   {
      printf("%d,",k*k*k);
      k++;
   }
getch();
}

second method:
//program to print/display 1,8,27... to 10th term.
#include<stdio.h>
#include<conio.h>
#include<math.h>void main()
{
int k=1,n;

while(k<=10)
   {
      printf("%d,",pow(k,3);// it means get power 3 of k. pow() is  a function stored in 'math.h'
      k++;
   }
getch();
}


note:
If you want to display 'n' number of times then simply put
  int n;declare this.
printf("enter value of n\n");
scanf("%d",&n) 
put above two lines before while loop.

program to input your name and address and to display them 40 times.

//program  to input your name and address and to display them 40 times.
#include<stdio.h>
#include<conio.h>
void main()
{
char name[40],address[40];
int k=0;printf("enter your name\n");
gets(name);
printf("enter your address");
gets(address);
while(k<=40)
   {
      puts(name);
      puts(address);
      k++;
   }
getch();
}

note:
1)
     you can also use printf(  ) instead 'puts'.(without single quote)   and scanf("%^[\n]",name) instead 'gets' function.
2)
   If you want to display 'n' number of times then enter value of 'n' with its declaration.

program to print/display 100 to 1 natural numbers.

//program  to print/display 100 to 1 natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=100;
while(k>=1)
   {
      
       printf("%d,",k);
      
    k--;
   }
getch();
}

note:
If you want to display numbers from 'n' to 1 then
   input 'n' and keep all others same.

program to print/display all odd numbers lying between 1 and 100.

first with while loop
// program  to print/display all odd numbers lying between 1 and 100.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1;
while(k<=100)
   {
      if(k%2!=0)
      {      
         printf("%d,",k);
      }
    k++;
   }
getch();
}

now with for loop

//program  to print/display all odd numbers lying between 1 and 100.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
for(k=1;k<=100;k++)
   {
     if(k%2!=0)
      {      
       printf("%d,",k);
      }
    
   }
getch();
}

now using do..while loop

//program  to print/display all odd numbers lying between 1 and 100.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n;
do
  {
       if(k%2!=0)
       {
          printf("%d,",k);
      } 
         k++;

   }
   while(k<=100);
getch();
}


We can also use some other methods as shown below using different loop.

//program  to print/display all odd numbers lying between 1 and 100.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1;
while(k<=100)
   {
      printf("%d,",k);
      
    k=k+2;
   }
getch();
}
You now try same using other loops.

program to print/display all even numbers lying between 1 to n natural numbers.


first with while loop
//program  to print/display all even numbers lying between 1 to n natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n;
printf("enter value of 'n'\n");
scanf("%d",&n);
while(k<=n)
   {
      if(k%2==0)
      {      printf("%d,",k);
      }
    k++;
   }
getch();
}

now with for loop

//program  to print/display all even numbers lying between 1 to n natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
printf("enter value of 'n'\n");
scanf("%d",&n);
for(k=1;k<=n;k++)
   {
     if(k%2==0)
      {      printf("%d,",k);
      }
    
   }
getch();
}

now using do..while loop

//A program  to print/display 1 to n natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n;
printf("enter value of 'n'\n");
scanf("%d",&n);
do
  {
       if(k%2==0)
       {
          printf("%d,",k);
      } 
         k++;

   }
   while(k<=n);
getch();
}


We can also use some other methods as shown below using different loop.

//program  to print/display all even numbers lying between 1 to n natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=0,n;
printf("enter value of 'n'\n");
scanf("%d",&n);
while(k<=n)
   {
      printf("%d,",k);
      
    k=k+2;
   }
getch();
}
You now try same using other loops.

program to print/display 1 to n natural numbers.

first with while loop
//A program  to print/display 1 to n natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n;
printf("enter value of 'n'\n");
scanf("%d",&n);
while(k<=n)
   {
      printf("%d,",k);
      k++;
   }
getch();
}

now with for loop

//A program  to print/display 1 to n natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
printf("enter value of 'n'\n");

scanf("%d",&n);
for(k=1;k<=n;k++)
   {
      printf("%d,",k);
   }
getch();
}

now using do..while loop

//A program  to print/display 1 to n natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n;
printf("enter value of 'n'\n");

scanf("%d",&n);
do
  {
       printf("%d,",k);
       k++;

   }
   while(k<=n);
getch();
}

A program to print/display 1 to 10 natural numbers.

first with while loop
//A program to print/display 1 to 10 natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1;
while(k<=10)
   {
      printf("%d,",k);
      k++;
   }
getch();
}

now with for loop

//A program to print/display 1 to 10 natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k;
for(k=1;k<=10;k++)
   {
      printf("%d,",k);
   }
getch();
}

now using do..while loop

//A program to print/display 1 to 10 natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1;
do
  {
       printf("%d,",k);
       k++;

   }
   while(k<=10);
getch();
}