click on this link......

LinkGrand.com

Friday, 11 January 2013

To print even number series from 0,2,4,6,8,10,12,14.....n using 'for' loop

#include<stdio.h>
#include<conio.h>
void main()
{
             int i,num;
            printf("Enter the last number:");
           scanf("%d",&num);
             for(i=0;i<=num;i=i+2)
             {
                      printf("\n%d",i);
            }
            getch();
}

program for even number series
program for even number series
Output for even number series
Output for even number series

       

To print series from 1,4,9,16,25,36,49,64,81,100.

#include<stdio.h>
#include<conio.h>
void main()
{
             int i;
            
             for(i=1;i<=10;i++)
             {
                      printf("\n%d",i*i);
            }
            getch();
}

program to print series 1,4,9,16,25......,100


output for series 1,4,9,16,25......,100

       

To print odd number series from 1,3,5,7,9,11.....n using 'for' loop

#include<stdio.h>
#include<conio.h>
void main()
{
             int i,num;
            printf("Enter the last number:");
           scanf("%d",&num);
             for(i=1;i<=num;i=i+2)
             {
                      printf("\n%d",i);
            }
            getch();
}

pogram to print odd number series
pogram to print odd number series
output for odd number series
output for odd number series

      

To print series from n to 1 using 'for' loop

#include<stdio.h>
#include<conio.h>
void main()
{
             int i,num;
            printf("Enter the last number:");
           scanf("%d",&num);
             for(i=num;i>=1;i--)
             {
                      printf("\n%d",i);
            }
            getch();
}

program to print series n to 1 using for loop
program to print series n to 1 using for loop
output for series n to 1 using for loop
output for series n to 1 using for loop

       

To print series 1 to n using 'for' loop

#include<stdio.h>
#include<conio.h>
void main()
{
             int i,num;
            printf("Enter the last number:");
           scanf("%d",&num);
             for(i=1;i<=num;i++)
             {
                      printf("\n%d",i);
            }
            getch();
}

program to print series from 1 to n using for loop
program to print series from 1 to n using for loop

output for series from 1 to n using for loop
output for series from 1 to n using for loop
       

Program on ternary operator

#include<stdio.h>
#include<conio.h>
void main()
{
              int a,b;
              printf("Enter the two numbers");
              scanf("%d %d",&a,&b);
              c=(a>b)?a:b;
              printf("The value of ternary operation on c is %d",c);
             getch();

           

Wednesday, 2 January 2013

program to explain the concept of postincrement, postdecrement,predecrement, preincrement operator

#include<stdio.h>
#include<conio.h>
void main()
{
                int a=3;
                printf("Value of a: %d",a);
                printf("Value of post-increment of a: %d",a++);
                printf("Value of a: %d",a);
                printf("Value of pre-increment of a: %d",++a);
                printf("Value of a: %d",a);
                printf("Value of post-decrement of a: %d",a--);
                printf("Value of a: %d",a);
                printf("Value of pre-decrement of a: %d",--a);
                printf("Value of a: %d",a);
                getch();
}

Output:-
 Value of a:3
Value of post-increment of a:  3
Value of a: 4
Value of pre-increment of a: 5
Value of  a: 5
Value of post-decrement of a: 5
Value of  a: 4
Value of pre-decrement of a: 3
Value of  a: 3