Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Test expression



Working with switch case



Iterative statement



" ; " after loop



Comment




Print 1 3 6 10 15 21 ........ this series




// AHF C PROGRAM SOLVING

//solving here ITERATIVES STATEMENTS type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int n,j,sum=0; //taking the number to continue loop pf("Enter the first number: "); scanf("%d",&n); for(j=1;j<=n;j++) { //number is added and assigning in sum variable sum+=j; //printing all the value of sum variable pf("%d ",sum); } return 0; }
OUTPUT:


© 2018 - All rights reserved