C Exercises

Feb 10, 2020

C program to print following numbers series 7.5 9.5 15.5 27.5 47.5.......

Ex: Write a C program to print following numbers series 7.5 9.5 15.5 27.5 47.5...How to write a C program to print following numbers series 7.5 9.5 15.5 27.5 47.5.....C program to print following numbers series 7.5 9.5 15.5 27.5 47.5.


Input from user:
Enter a number: 5

Expected output:
7.5 9.5 15.5 27.5 47.5





Program:

#include<stdio.h>
void main()
{
int i,no;
float z=7.5;

printf("Enter a number:\n");
scanf("%d",&no);
//First print current value of z
printf("%f ",z);
for(i=1;i<no;i++)
{
z=(z)+i*(i+1);
printf("%f ",z);
}

}

Above Program show's the following output:







No comments:

Post a Comment

If you have any doubts, please discuss here...