Saturday, September 17

C program to Print a number table

Write a program to display the following format:
Nosum
11
23
36
410
515

Logic:

First column contains natural numbers serially..
second column contains  ( Current first column element+ previous second column element)
2+1=3
3+3=6
4+6=10
5+10=15




#include<stdio.h>
main()
{
      int j=0,z,i,n;
      printf("Enter the Limit...  :  ");
      scanf("%d",&n);
      printf("\n----------------\n
printf("no\tsum");
printf("\n------------------\n");
     
      for(i=1;i<=n;i++)
      {
      printf("\n%d",i);
      j+=i;
      printf("\t%d",j);
      }
      getch();
      }
     
     
     





0 comments :

Post a Comment