ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Science & Programming

sum of first 10 natural numbers using c programming

Updated on March 22, 2010

In computer programming, C language is very effetive. In the sense, using 'c', we can see the hard disk address with the help of pointers. I will publish some simple pointer progarammes later.

#include<stdio.h>

#include<conio.h>

void main()

{

clrscr();

int i,sum=0;

for(i=1;i<=10;i=i+1) // starting for loop, this loop will execute until the value of i reaches 10.

{

sum=sum+i; // add the values of sum with i and save it to sum itself.

}

printf("Sum of first 10 natural numbers is %d", sum);

getch();

}

--------------------------------------------------------

NB: stdio.h & conio.h ----> header files

clrscr() ---> for clearing the screen

printf() ----> for printing the result.

getch() ----> screen will wait until a key is pressed.

------> for running the program press Ctrl + F9 key together, it will compile & run the program

----------------------------------------------------------

thanks a lot.

hope u get the result. :-)

Comments

    0 of 8192 characters used
    Post Comment

    • profile image

      anandhan 20 months ago

      thank

    • profile image

      Sanjay Netriwal 2 years ago

      Thank You

    • profile image

      ankit 2 years ago

    • profile image

      shubhendu 2 years ago

      why did we take sum=0;

    • profile image

      Shubham 3 years ago

      THANK U

    • profile image

      parri 3 years ago

      Thanks a lot to solving my problem..

      Thanku very much

    • profile image

      ArUn 3 years ago

      Thnx a lot solving my problm.Bcz i was in big confused 0 is prime number or natural number. ..

      Here i saw,nd my problem is solved....

      Thanks.......

    • profile image

      iqra 3 years ago

      how to find this problem

      take two numbers, a and b as input and find axb(their product)without using the operator

    • profile image

      prsad joshi 3 years ago

      i want its algorithm.......

    • profile image

      biswajit majumder 3 years ago

      Thanks a lot for preparing Easyly

    • profile image

      saba 3 years ago

      nice

    • profile image

      muthu 3 years ago

      thank u for urgood presentation

    • profile image

      rofi 4 years ago

      thank u

    • profile image

      reud 4 years ago

      big fake

    • profile image

      reud 4 years ago

      big fake

    • profile image

      harish 4 years ago

      dear sir,

      please send program

      1.to add 10 number

      2.to add 10 number and find averaqge using arrays

      3.to sort the n number using array

      4.add 10 number using ponter with arrays

      5.sort the n number using ponters

      my email id is blinkingstars405@gmail.com

    • profile image

      bhavani 4 years ago

      It's nice

    • profile image

      swetha. 5 years ago

      easy to understand..thanks

    • profile image

      bilal ahmed 5 years ago

      i like it

    • profile image

      siri 5 years ago

      dear sir,plz send me the programe for replacing the string by using files............

    • profile image

      your code is incorrect 5 years ago

      your code is incorrect

    • profile image

      Shivendra 7 years ago

      www.shivendragupta.blogspot.com