-->

program to print/display all ascii values of letters from A to Z and a to z..

//program  to print/display all ascii values of letters from A to Z and a to z..

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char k='A';
while(k<='Z')
{
printf("chracter=%c and ascii value=%d | \t character=%c and ascii value=%d\n",k,k,k+32,k+32);
k++;
}
getch();
}

note:
logic applied:
we have printed character and its asciii value.
ASCII value of 'A' is 65 and 'a' is 97.
We can see difference of both is 32 so we can get ascii value by adding 32 to respective values and charcaters.

program to print/display all characters from a to z.

//program  to print/display all characters from a to z.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=97;

while(k<=122)
   {
           printf("%c,",k);
      
    k++;
   }
getch();
}

logic applied:
1)You should know ascii value of all characters then apply that in loop.
ascii value of 'a' is 97 and z is 122.
so apply this value in a loop and print as a character(%c).
or
2)You can use all characters stored in a string and then display one by one.
e.g.
int j;
char string[]="abcdefghijklmnopqrstuvwxyz";
for(j=0;string[j]!='\0';j++)
{
  printf("%c\n",string[j]);
}

put this code in side void main and execute them . you get output.

program to get/sum of all even numbers lying between 1 to n natural numbers

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

-----------------------------
we can also write this program as shown below.
-------------------------------------
//program  to get/sum of all even numbers lying between 1 to n natural numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int k=0,n,sum=0;                         
printf("enter value of 'n'\n");
scanf("%d",&n);
while(k<=n)
   {
            sum=sum+k;
      
    k=k+2;
   }
printf("the sum=%d",sum);
getch();
getch();
}


program to get sum of 1 to 10 natural numbers.

//program to get sum of 1 to 10 natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,sum=0;   //initialization
printf("enter value of 'n'\n");
scanf("%d",&n);
while(k<=n)
   {
      sum=sum+k;
      k++;
   }
printf("the sum=%d,",sum);
getch();
}

note:
here I have used 'n' as an input. We  can input any value, may be 10 or 20 or 100.
If you want to use 10 in loop directly then you can use and there would be no input(no scanf(..))

program to print/display 1,11,111,1111,11111,.... to nth term.

//program to print/display 1,11,111,1111,11111,.... to nth term.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int k=1,m=1,n;
printf("enter value of 'n'\n");
scanf("%d",&n);
while(m<=n)
   {
      printf("%d\n",k);
      
      k=k+pow(10,m);
      m++;
   }
getch();
}

logic applied:

1,11,111,1111...
can be written as
1,10+1,100+11,1000+111....
can be written as
1,10 1+1,10 2+11,10 3+111
converting it into formula
k=k+pow(10,m);

program to print/display 1,6,11,16....nth term.

//program to print/display 1,6,11,16....nth term.
#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=k+5;
   }
getch();
}

program to display multiplication table of a number .

//program to display multiplication table of a number .
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n;
printf("enter value of 'n'(as a number)\n");
scanf("%d",&n);
while(k<=10)
   {
      printf("%d*%d=%d\n",n,k,n*k);
      k++;
   }
getch();
}
-------------------------------- note:
1)You can directly print instead given format.
put
printf("%d\n",n*k);

2) you can use nested loop for this as well.
 like
for(i=1;i<=1;i++)
  {
    for(k=1;k<=10;k++)
      {
          printf("%d\n",i*k);
       }
   }
you can put i =n if you enter this.
------------------------------------------------------------------------------
let's see the program using nested loop
//program to display multiplication table of a number using nested loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
printf("enter value of 'n'(a number for multiplication table)\n");
scanf("%d",&n);
for(i=n;i<=n;i++)
  {
    for(k=1;k<=10;k++)
      {
          printf("%d\n",i*k);
       }
          printf("\n");
   }
getch();
}
-----------------------------------------------------------------------------------------
let's see the program to get multiplication table of numbers using nested loop
//program to display multiplication table of  numbers using nested loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n;
printf("for how many numbers, you want t o go for multiplication table\n");
scanf("%d",&n);                       // from 1 to n
for(i=1;i<=n;i++)
  {
    for(k=1;k<=10;k++)
      {
          printf("%d\n",i*k);
       }
          printf("\n");
   }
getch();

}