CCP A4
CCP A4
CCP A4
h>
int main()
{ int sum,i,n;
sum=0;
printf("Enter the number of natural for their sum\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{ sum=sum+i;}
printf("Sum%d",sum);
return 0;
}
#include <stdio.h>
int main()
{ int sum,i,n;
sum=0;
printf("Enter the number of natural for their sum\n");
scanf("%d",&n);
while(i<=n)
{ sum=sum+i;
i++;
}
printf("Sum%d",sum);
return 0;
}
#include <stdio.h>
int main()
{ int sum,i,n;
sum=0;
printf("Enter the number of natural for their sum\n");
scanf("%d",&n);
do
{ sum=sum+i;
i++;
}while(i<=n);
printf("Sum%d",sum);
return 0;
}
#include <stdio.h>
int main()
{ float sum,i,n,k,avg;
sum=0;
printf("Enter the number of natural for their sum\n");
scanf("%f",&n);
for(i=1;i<=n;i++)
{printf("Enter the no");
scanf("%f",&k);
sum = sum + k;
}
avg = sum/n;
printf("Sum%f\n",sum);
printf("Average%f",avg);
return 0;
}
#include <stdio.h>
int main()
{ float c,i,n;
printf("Enter the number for their cube\n");
scanf("%f",&n);
for(i=0;i<=n;i++)
{
c=c*i*i*i;
printf("Cube :-%f\n",c);
c=1;
}
return 0;
}