Pages

Thursday, October 21, 2010

ADDITION

#include<stdio.h>
#include<conio.h>

void main()
{
    int T, I, A, N;
    clrscr();

    printf("\n\tInput the value for N:");
    do
     {
       gotoxy(31,2);scanf("%d",&N);
       if (N < 0)
         {
           gotoxy(15,4);printf("INVALID INPUT ");
           gotoxy(31,2);printf("        ");
         }
     }
    while (N < 0);
    gotoxy(15,4);printf("                       ");

    printf("\n\t\t  ***||  ADDITION TABLE  ||***");
    printf("\n\n\n");
    for(T = 1; T <= N; T++)
           {
        if (T == N)
           printf("  |  %d |",T);
        else
           printf("  |  %d", T);
           }
    printf("\n");

    for(I = 2; I <= N; I++)
        {
        printf("\t|  %d  |", I);
        for(T = 2; T <= N; T++)
              {
            A = I+T;
            if(A > 9)
              printf("  %d |",A);
            else
              printf("  %d  |",A);
              }
        printf("\n");
        }
    getch();
}

No comments:

Post a Comment