WELCOME TO MY BLOG BY SHABEEB.K

C,C++ PROGRAMMING: 08/05/13

Search This Blog

Monday, 5 August 2013

ARITHMATIC PROGRESSION OPERATION.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
int option;
long term1,d,limit,i;
long sum;

clrscr();

next :

clrscr();
printf("\nENTER FIRST TERM OF AN A.P\n");
scanf("%lu",&term1);
printf("\ENTER DIFFERENCE\n");
scanf("%lu",&d);
printf("\nENTER LIMIT LENGTH OF A.P\n");
scanf("%lu",&limit);
sum=limit/2*(2*term1+(limit-1)*d);
printf("\n SUM : %lu\n",sum);
printf(" %lu ",term1);

for(i=1;i<limit;i++)
{
term1=term1+d;
printf(" %lu ",term1);
}
printf("\n DO YOU WISH TO CREATE MORE A.P?\n");
printf("\n 1 : TO CONTINUE\n 2 : TO EXIT \n ");
scanf("%d",&option);

switch (option)
{
case 1 : goto next;
break;
case 2 : printf("\n PRESS ENTER TO EXIT\n");
break;
default : printf("\n U HAVE ENTERED AN INVALID\n");
break;
}
getch();
}


                                                                        OUTPUT