answersLogoWhite

0


Best Answer

if (n%2==0) sum=n/2*(n+1);

else sum=(n+1)/2*n;

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Find the sum of 1 plus 2 plus 3 plus . plus n nos using c program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Using while loop write a program which calculates the product of digits from 1 to 5 and also show these nos vertically?

Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.


To enter n nos without using arrays in c?

Use a linked-list.


Write a c program to sort three integer numbers using nested if statement?

// HI THIS IS MAYANK PATEL /*C Program to find Maximum of 3 nos. using Nested if*/ #include<stdio.h> #include<conio.h> void main() { int a,b,c; // clrscr(); printf("Enter three number\n\n"); scanf("d%d",&a,&b,&c); if(a>b) { if(a>c) { printf("\n a is maximum"); } else { printf("\n c is maximum"); } } else { if(b>c) { printf("\n b is maximum"); } else { printf("\n c is maximum"); } } getch(); }


Could u draw me a flowchart for this C program question 1.sum of nos. from 1 to n Check the no. in odd or even?

1. Read in 'n'2. Output n*(n+1)/2> Check the no. in odd or even?Both possible, has no significance.


Program to sort numbers in c plus plus?

/* Bubble sort: code snippet only nos to be sorted are in the array named 'n' of size 'N' for(int i=0;i<N-1;i++) for(int j=i+1;j<N-1-i;j++) if(n[j]>n[j+1]) swap(n[j],n[j+1]); */ /* insertion sort int v,j; for(int i=1;i<N;i++) { v=n[j]; for(int j=i-1;j>0&&n[j]>v;j--) n[j+1]=n[j]; n[j+1]=v; } */

Related questions

Find the greater no between two nos using pointer in c plus plus programming?

if (*&a > *&b) *&max = *&a; else *&max = *&b;


How do you print nos from 10-0 then only even nos are printed in a program flowchart?

10


Coding in c plus plus to swap two nos using pointer?

void swap (int &pa, int &pb) { *pa ^= *pb; *pb ^= *pa; *pa ^= *pb; }


Using while loop write a program which calculates the product of digits from 1 to 5 and also show these nos vertically?

Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.


How do you use super Nos Pump to lose weight?

How do you lose weight using super nos pump


Differtiate window NOS over unix NOS?

If both Windows and Unix are using TCP/IP as their primary NOS there isn't much difference to speak of.


C program for summation of n nos using recursion?

int sum (int n) { if (n<=1) return n; else return n + sum (n-1); }


How do you find the sum of nos in a series?

It depends on the series.


What is the best place to get nos?

There are quite a few places to obtain nos. You can try dougstubes,kcanostubes or thegearpage, These are all great sources to find nos tubes at a great price. Hope this helps you out.


What does a ver que nos encontramos mean?

To see what we find.


Write a c program to print the 100 to 1 nos?

Write a c program to print the 100 to 1 nos


How would you answer in spanish using the person Miguel Quien les sirvio el pescado asado?

Miguel nos/se lo sirvio. ('Nos' - us. 'Se' - them)