Sum of all no using integer array

 #include <stdio.h>

int main(){


int numval;

printf("plese enter number of value that you want to add\n");

scanf("%d", &numval);

int values[numval];

int counter;

int value;

int result = 0;

for (counter = 0 ; counter < numval ; counter++){

    printf("please enter value %d \n", counter+1);

    scanf("%d", &value);

    values[counter] = value;


}

for (counter = 0 ; counter < numval ; counter++){

    result = result + values[counter];


}

 printf("total = %d\n" , result);






return 0;}

Comments

Popular posts from this blog

Factors : using C

Cross shaped pattern

Factorial ! calculation