pages

Sunday, 30 May 2021

c-program to calculate the sum of five number by using pointer in c-programming| c-language

program to calculate the sum of all five number by using pointer in c-programming.

In this program ,we will now  takes input five numbers by the user and print the sum of all five number by using pointer in c-programming.



#include<stdio.h>
#include<conio.h>
void main()
{
         int i,a[5],sum=0;
         int *p;
         p=&a[0];
         printf("enter the five numbers:-");
         for(i=0;i<=4;i++){
                  scanf("%d",p);
                  p++;
         }
         p=&a[0];
         printf("\n the number are follow:-");
         for(i=0;i<5;i++){
                  printf("%d ",*p);
                  sum=sum+*p;
                  p++;
         }
         printf("\n the sum of the numbers is %d",sum);
         getch();
}

output-





For more c-programming:-


No comments:

Post a Comment