1.write a program segment that computes 1+2+3+...+(n-1)+n, where n is a data value. follow the loop body with an if statement that compares this value to (n*(n+1)) /2 and displays a message that indicates whether the value are the same or different. what message do you think will be displayed.
this my code please i need help whether am right or not.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int count=0,sum=0;
int n,items;
int sum_2=0;
printf("enter the data value n>>");
scanf("%d",&n);
printf("enter the item to compute>>");
scanf("%d",&items);
do{
sum_2 = ((n *(n + 1))/ 2);
sum +=items;
count +=1;
}while(count < n);
printf("\n\nthe sum is %d\n\n",sum);
if(sum == sum_2)
{
printf("the two sums are the same");
}
else
{
printf("the two values are different \n\n");
}
system("PAUSE");
return 0;
}