Calculate Sum and Average of N Numbers using Arrays: C Program

Lets write a C program to calculate Sum and Average of N numbers using Arrays and using macros and for loop.

Related Read:
Calculate Sum and Average of N Numbers without using Arrays: C Program

Formula To Calculate Sum and Average

int a[5] = {2, 4, 6, 5, 9};

sum = 2 + 4 + 6 + 5 + 9;
average = sum / 5.0;

Result
sum = 26;
average = 5.2;

Important Note:
Look at the formula for calculating average. If you divide any number by integer number, it’ll only return integer value and discard the digits after decimal point. So make sure to divide the number by floating point value. To convert integer to float, make use of typecasting syntax.

Typecasting

int N = 5;

sum = 2 + 4 + 6 + 5 + 9;
average = sum / (float)N;

Since N is integer type variable, dividing any number by N would give us integer data. For some input it’ll result in wrong result. To fix it, we make use of typecasting and cast the type of N to float using above syntax.

Example: Expected Output

Enter 5 integer numbers
5
2
6
4
3

Sum of 5 numbers: 20

Average of 5 numbers: 4.000000

array with size 5

Video Tutorial: Calculate Sum and Average of N Numbers using Arrays: C Program


[youtube https://www.youtube.com/watch?v=K5Q4i7jyrAo]

YouTube Link: https://www.youtube.com/watch?v=K5Q4i7jyrAo [Watch the Video In Full Screen.]

Source Code: Calculate Sum and Average of N Numbers using Arrays: C Program

Method 1

#include<stdio.h>

#define N 5

int main()
{
    int a[N], i, sum = 0;
    float avg;

    printf("Enter %d integer numbers\n", N);
    for(i = 0; i < N; i++)
        scanf("%d", &a[i]);

    for(i = 0; i < N; i++)
    {
        sum = sum + a[i];
    }

    avg = sum / (float)N;

    printf("\nSum of %d numbers: %d\n", N, sum);
    printf("\nAverage of %d numbers: %f\n", N, avg);

    return 0;
}

Output 1:
Enter 5 integer numbers
2
5
6
8
10

Sum of 5 numbers: 31

Average of 5 numbers: 6.200000

Output 2:
Enter 5 integer numbers
1
2
3
4
5

Sum of 5 numbers: 15

Average of 5 numbers: 3.000000

Logic To Calculate Sum and Average of Array Elements

We ask the user to input N integer numbers. N is a macro and we’ve assigned 5 to it. Integer numbers input by the user is stored inside array variable a[N]. N being the size of the array.

SUM
We use for loop and iterate N times to fetch all the array elements. Variable i is assign a initial value of 0 and for loop iterates until i < N. Inside for loop we add the value of individual array element(a[i]) to previous value of variable sum. Once i < N condition is false, control exits for loop.

AVERAGE
Outside for loop we calculate average by using the formula:
average = sum / (float)N;

Once sum and average are calculated we output the result on to the console window.

Source Code: Calculate Sum and Average of N Numbers using Arrays: C Program

Method 2: Improved Source Code

#include<stdio.h>

#define N 5

int main()
{
    int a[N], i, sum = 0;
    float avg;

    printf("Enter %d integer numbers\n", N);
    for(i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
        sum = sum + a[i];
    }

    avg = sum / (float)N;

    printf("\nSum of %d numbers: %d\n", N, sum);
    printf("\nAverage of %d numbers: %f\n", N, avg);

    return 0;
}

You could even calculate sum inside the for loop which is used to accept input from the user. Whenever user inputs a number it is immediately added to the previous value of variable sum.

Advantages of using above source code
We don’t iterate through the array to fetch individual elements of the array and then add it to calculate sum. We calculate sum inside first for loop itself which is used to accept input by user. This method is faster and cheaper on resource usage.

Important Notes:

1. Make use of macros to assign size of array.
2. Make sure to declare variable avg(to calculate average) as float or double.
3. Make sure to divide variable sum by floating point or double type value and not by integer. In order to convert a integer variable or macro, make use of typecasting.

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

Using Macros Find Area and Perimeter of Triangle, Square, Circle: C Program

Problem State: Write macro definitions with arguments for calculation of area and perimeter of a triangle, a square and a circle.

Store these macro definitions in a file called “areaperi.h”. Include this file in your program, and call the macro definitions for calculating area and perimeter for different squares, triangles and circles.

Related Read:
Switch Case Default In C Programming Language
Macros With Arguments: C Program
do-while Loop In C Programming Language

Problem Statement Analysis

1. We need to write macro definitions which accept arguments.
2. We need to write macro definitions to calculate area and perimeter of triangle, square and circle.
3. We need to write macro definition inside a separate file called areaperi.h and then include this header file into our source file and make use of the macro definitions to calculate area and perimeter of Triangle, Square and Circle for various user inputs.

Video Tutorial: Using Macros Find Area and Perimeter of Triangle, Square, Circle: C Program


[youtube https://www.youtube.com/watch?v=lR50ONlpDNw]

YouTube Link: https://www.youtube.com/watch?v=lR50ONlpDNw [Watch the Video In Full Screen.]

Source Code: Using Macros Find Area and Perimeter of Triangle, Square, Circle: C Program

areaperi.h

#include<math.h>

#define TRI_PERI(a, b, c) (a + b + c)
#define SP(a, b, c) ( (a + b + c) / 2.0 )
#define TRI_AREA(a, b, c) ( sqrt( SP(a,b,c) * \
                                 ( SP(a,b,c) - a ) *\
                                  (SP(a,b,c) - b) * \
                                  (SP(a,b,c) - c)) )

#define SQR_PERI(s) (4 * s)
#define SQR_AREA(s) (s * s)

#define C_PERI(r) (2 * M_PI * r)
#define C_AREA(r) (M_PI * r * r)

main.c

#include<stdio.h>
#include "areaperi.h"

int main()
{
    float a, b, c, side, radius;
    int choice, repeat;

    do
    {
        printf("1. Area of Triangle\n");
        printf("2. Perimeter of Triangle\n");
        printf("3. Area of Square\n");
        printf("4. Perimeter of Square\n");
        printf("5. Area of Circle\n");
        printf("6. Perimeter of Circle\n");

        printf("\nEnter your choice\n");
        scanf("%d", &choice);

        switch(choice)
        {
            case 1: printf("Enter 3 sides of a Triangle\n");
                    scanf("%f%f%f", &a, &b, &c);
                    printf("Area of Trianlge is %0.2f\n", TRI_AREA(a,b,c));
                    break;
            case 2: printf("Enter 3 sides of a Triangle\n");
                    scanf("%f%f%f", &a, &b, &c);
                    printf("Perimeter of Trianlge is %0.2f\n", TRI_PERI(a,b,c));
                    break;
            case 3: printf("Enter length of side of Square\n");
                    scanf("%f", &side);
                    printf("Area of Square is %0.2f", SQR_AREA(side));
                    break;
            case 4: printf("Enter length of side of Square\n");
                    scanf("%f", &side);
                    printf("Perimeter of Square is %0.2f", SQR_PERI(side));
                    break;
            case 5: printf("Enter Radius of Circle\n");
                    scanf("%f", &radius);
                    printf("Area of Circle is %0.2f\n", C_AREA(radius));
                    break;
            case 6: printf("Enter Radius of Circle\n");
                    scanf("%f", &radius);
                    printf("Circumference of Circle is %0.2f\n", C_PERI(radius));
                    break;
            default: printf("\nPlease enter valid choice\n");
        }

        printf("\n\nDo you want to continue? Ans: 0 or 1\n");
        scanf("%d", &repeat);

        printf("\n");

    }while(repeat);

    return 0;
}

Output:
1. Area of Triangle
2. Perimeter of Triangle
3. Area of Square
4. Perimeter of Square
5. Area of Circle
6. Perimeter of Circle

Enter your choice
1
Enter 3 sides of a Triangle
5
6
9
Area of Trianlge is 14.14

Do you want to continue? Ans: 0 or 1
1

1. Area of Triangle
2. Perimeter of Triangle
3. Area of Square
4. Perimeter of Square
5. Area of Circle
6. Perimeter of Circle

Enter your choice
2
Enter 3 sides of a Triangle
5
6
9
Perimeter of Trianlge is 20.00

Do you want to continue? Ans: 0 or 1
1

1. Area of Triangle
2. Perimeter of Triangle
3. Area of Square
4. Perimeter of Square
5. Area of Circle
6. Perimeter of Circle

Enter your choice
3
Enter length of side of Square
5
Area of Square is 25.00

Do you want to continue? Ans: 0 or 1
1

1. Area of Triangle
2. Perimeter of Triangle
3. Area of Square
4. Perimeter of Square
5. Area of Circle
6. Perimeter of Circle

Enter your choice
4
Enter length of side of Square
5
Perimeter of Square is 20.00

Do you want to continue? Ans: 0 or 1
1

1. Area of Triangle
2. Perimeter of Triangle
3. Area of Square
4. Perimeter of Square
5. Area of Circle
6. Perimeter of Circle

Enter your choice
5
Enter Radius of Circle
5.5
Area of Circle is 95.03

Do you want to continue? Ans: 0 or 1
1

1. Area of Triangle
2. Perimeter of Triangle
3. Area of Square
4. Perimeter of Square
5. Area of Circle
6. Perimeter of Circle

Enter your choice
6
Enter Radius of Circle
5.5
Circumference of Circle is 34.56

Do you want to continue? Ans: 0 or 1
0

Formulas To Calculate Area and Perimeter

We’ve written the formula to calculate area and perimeter inside areaperi.h file, as macro expansion. Below we list all the formulas we’re using in our program:

Perimeter of a Triangle: ( a + b + c)
where: a, b, and c are lengths of sides of the triangle.

Semi-perimeter of a Triangle: ( (a + b + c) / 2 )
where: a, b, and c are lengths of sides of the triangle.

Area of a Triangle: sqrt( S x (S – a) x (S – b) x (S – c) )
where: a, b, and c are lengths of sides of the triangle.
S is the semi-perimeter.

Perimeter of Square: ( 4 x side )
where: side is the length of side of the square.

Area of Square: ( side x side)
where: side is the length of side of the square.

Perimeter or Circumference of Circle: ( 2 x PI x r )
Area of a Circle: ( PI x r x r )
where: r is radius of the circle.
PI is approximately equal to 3.14

Note: M_PI is a macro present inside math.h library file and has value of PI.

Related Read:
C Program To Find Area, Perimeter and Semi-perimeter: Valid Triangle
C Program To Calculate Perimeter, Diagonal of a Square using its Side
C Program To Find Area and Circumference of Circle using Pointer

Logic

We’ve included areaperi.h into main.c file. Now we can make use of all the macros we’ve defined inside areaperi.h

Users are provided with options to select the preferred operations like:
1. Area of Triangle
2. Perimeter of Triangle
3. Area of Square
4. Perimeter of Square
5. Area of Circle
6. Perimeter of Circle

Based on user selection appropriate block of code inside switch-case is executed, wherein we place the relevant macro template to get the desired result.

Note: We can continue writing macro expansion in next line by making use of macro continuation operator(\). You can see that we’ve broken the line and written the code in next line inside macro expansion of TRI_AREA.

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Calculate Area of a Triangle using Pointers

Lets write a C program to calculate area of a Triangle when their sides are input by the user. Lets use pointers and functions.

Problem Statement

If the lengths of the sides of a Triangle are denoted by a, b and c, then area of Triangle is given by:

Heron's or Hero's Formula

where, s = (a + b + c) / 2. Write a function to calculate the area of triangle.

Here s is semi-perimeter of the Triangle.

Related Read:
Find Area of a Triangle Using Its Sides: C Program
Basics of Pointers In C Programming Language

Formula To Calculate Area of a Triangle When its Sides are Given

area = sqrt( S * (S – a) * (S – b) * (S – c) );

where a, b and c are lengths of sides of the Triangle.
S = (a + b + c) / 2.0;
S – Semi-perimeter.

Very Important Note:

Any address preceded by a * (Indirection operator) will fetch the value present at that address.

Video Tutorial: C Program To Calculate Area of Triangle using Pointers


[youtube https://www.youtube.com/watch?v=cfQhWAoP6u8]

YouTube Link: https://www.youtube.com/watch?v=cfQhWAoP6u8 [Watch the Video In Full Screen.]


Source Code: C Program To Calculate Area of Triangle using Pointers

#include<stdio.h>
#include<math.h>

void cal_area(float, float, float, float*);
int  validate(float, float, float);

int main()
{
    float a, b, c, area;

    printf("Enter values of 3 sides of a Triangle.\n");
    scanf("%f%f%f", &a, &b, &c);

    if( validate(a, b, c) )
    {
        cal_area(a, b, c, &area);
        printf("Area of Triangle is %0.2f\n", area);
    }
    else
    {
        printf("Please enter valid values for sides of Triangle.\n");
    }

    return 0;
}

void cal_area(float x, float y, float z, float *A)
{
    float S;

     S = (x + y + z) / 2.0;

    *A = sqrt(S * (S - x) * (S - y) * (S - z));
}

int validate(float x, float y, float z)
{
    int flag = 0;

    if(x > y && x > z)
    {
        flag = ( x < (y + z) );
    }
    else if(y > z)
    {
        flag = ( y < (x + z) );
    }
    else
    {
        flag = ( z < (x + y) );
    }

    return(flag);
}

Output 1:
Enter values of 3 sides of a Triangle.
10
20
30
Please enter valid values for sides of Triangle.

Output 2:
Enter values of 3 sides of a Triangle.
50
30
0
Please enter valid values for sides of Triangle.

Output 3:
Enter values of 3 sides of a Triangle.
15
14
2
Area of Triangle is 12.53

Output 4:
Enter values of 3 sides of a Triangle.
14.6
14
0.7
Area of Triangle is 2.58

Output 5:
Enter values of 3 sides of a Triangle.
4
5
6
Area of Triangle is 9.92

In Output 1: the largest side is 30. So the other side is 10 and 20. Adding 10 and 20 gives 30, which is not greater than the largest side. So these three values can’t form a valid triangle.

In Output 2: we’ve a 0. No side of a Triangle can have a length of 0. So it’s a invalid Triangle.

Logic To Calculate Area of a Triangle using Pointers

We ask the user to enter/input values of 3 sides of a Triangle. We pass these three values along with the address of variable area to a function called cal_area().

Inside cal_area() function we calculate the semi-perimeter using below formula:

S = (x + y + z) / 2.0;

Note: While calculating Semi-perimeter make sure to divide by 2.0 and not by 2. Because sum of sides of triangle might be a floating point number. Division by integer will give integer value as result. So it’s always better to avoid division by integer value.

Calculate Area of Triangle using Heron’s or Hero’s Formula

To calculate Area of a Triangle when all 3 of its sides are known, we make use of Heron’s or Hero’s Formula:

*A= sqrt( S * (S – a) * (S – b) * (S – c) );

We are storing the result inside a pointer variable. Variable A has the address of variable area i.e., A = &area. *A is the value present at address A or &area.

When we modify the value present at an address it reflects everywhere in the program. Hence we are able to display the result of area inside main method, without literally returning any value from cal_area() funtion.

Logic To Validate The Sides of Triangle

A Triangle is said to be valid if the sum of two sides is greater than the largest of the three sides.

For Example:
If a, b and c are 3 sides of the Triangle. If c is the largest side. Then for the Triangle to be valid, value of (a+b) must be greater than c.

(a+b) > c

Triangle Valid or Not based On Sides: C Program

In function validate() we first find the largest side of the triangle and check if its value is less than the sum of other 2 sides of the triangle. If true we return 1 else we return 0.

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Calculate Amount In Compound Interest

When interest compounds q times per year at an annual rate of r % for n years, the principal p compounds to an amount a as per the following formula:

a = p (1 + r / q) nq

Write a C Program to read 10 sets of p, r, n & q and calculate the corresponding a‘s.

Related Read:
Basic Arithmetic Operations In C
For Loop In C Programming Language
C Program to Calculate the Compound Interest

Video Tutorial: C Program To Calculate Amount In Compound Interest


[youtube https://www.youtube.com/watch?v=7q8yFP6S3MA]

YouTube Link: https://www.youtube.com/watch?v=7q8yFP6S3MA [Watch the Video In Full Screen.]


Logic To Find Compounded Amount

We ask the user to enter values for floating point variables p, n, r and q. We use the formula:

a = p (1 + r / q) nq

And display the result to the console window.

where,
p – principal amount;
n – number of years.
r – rate of interest;
q – number of times interest compounds per year.

Note: We need to convert the user entered interest into percentage by dividing the integer number by 100.

Source Code: C Program To Calculate Amount In Compound Interest

 
#include<stdio.h>
#include<math.h>

int main()
{
    float p, n, r, q, a;
    int count;

    for(count = 1; count <= 10; count++)
    {
        printf("Enter principal amount\n");
        scanf("%f", &p);

        printf("Enter number of years\n");
        scanf("%f", &n);

        printf("Enter rate of interest\n");
        scanf("%f", &r);

        r = r / 100;

        printf("Enter no of times you compound per year\n");
        scanf("%f", &q);

        a = p * pow( (1 + (r/q)), n * q );

        printf("Compounded amount is %f\n\n", a);
    }

    return 0;
}

Output
Enter principal amount
5000
Enter number of years
2
Enter rate of interest
8
Enter no of times you compound per year
4
Compounded amount is 5858.296875

Enter principal amount
1000
Enter number of years
7
Enter rate of interest
5
Enter no of times you compound per year
1
Compounded amount is 1407.100464

Enter principal amount
2000
Enter number of years
5
Enter rate of interest
12
Enter no of times you compound per year
12
Compounded amount is 3633.393311

Enter principal amount
5000
Enter number of years
5
Enter rate of interest
5
Enter no of times you compound per year
5
Compounded amount is 6412.160156

Enter principal amount

Note: Above program keeps on iterating 10 times and asks the input 10 times.

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Calculate Approximate Level of Intelligence of a Person

According to a study, the approximate level of intelligence of a person can be calculated using the following formula:

i = 2 + ( y + 0.5x )

Write a C program that will produce a table of values of i, y and x, where y varies from 1 to 6, and, for each value of y, x varies from 5.5 to 12.5 in steps 0.5.

Related Read:
Basic Arithmetic Operations In C
Compound Assignment Operators in C
Nested For Loop In C Programming Language

Logic To understanding the problem statement

1. Problem statement snippet: “..y varies from 1 to 6”. That means, we can accomplish it using a looping statement. So we can take a for loop and initialize variable y to 1 and iterate the for loop until y is less than or equal to 6.

2. Problem statement snippet: “..for each value of y, x varies from”. That means we should write a nested for loop here.

3. Problem statement snippet: “..for each value of y, x varies from 5.5 to 12.5 in steps 0.5”. That means, we need to write a nested for loop and initialize x value to 5.5 and iterate through the for loop until x value is less than or equal to 12.5 And for each iteration of the inner for loop we need to increment the value of x by 0.5

Video Tutorial: C Program To Calculate Approximate Level of Intelligence of a Person


[youtube https://www.youtube.com/watch?v=wRfgDzMMIvY]

YouTube Link: https://www.youtube.com/watch?v=wRfgDzMMIvY [Watch the Video In Full Screen.]


Source Code: C Program To Calculate Approximate Level of Intelligence of a Person

#include<stdio.h>

int main()
{
    int y, count = 1;
    float i, x;

    for(y = 1; y <= 6; y++)
    {
        for(x = 5.5; x <= 12.5; x += 0.5)
        {
          i = 2 + (y + 0.5 * x);

          printf("%d. i = %0.2f,\t x = %0.2f,\t y = %d\n", count++,i, x, y);
        }
    }

    return 0;
}

Output:

1. i = 5.75,     x = 5.50,       y = 1
2. i = 6.00,     x = 6.00,       y = 1
3. i = 6.25,     x = 6.50,       y = 1
4. i = 6.50,     x = 7.00,       y = 1
5. i = 6.75,     x = 7.50,       y = 1
6. i = 7.00,     x = 8.00,       y = 1
7. i = 7.25,     x = 8.50,       y = 1
8. i = 7.50,     x = 9.00,       y = 1
9. i = 7.75,     x = 9.50,       y = 1
10. i = 8.00,    x = 10.00,      y = 1
11. i = 8.25,    x = 10.50,      y = 1
12. i = 8.50,    x = 11.00,      y = 1
13. i = 8.75,    x = 11.50,      y = 1
14. i = 9.00,    x = 12.00,      y = 1
15. i = 9.25,    x = 12.50,      y = 1
16. i = 6.75,    x = 5.50,       y = 2
17. i = 7.00,    x = 6.00,       y = 2
18. i = 7.25,    x = 6.50,       y = 2
19. i = 7.50,    x = 7.00,       y = 2
20. i = 7.75,    x = 7.50,       y = 2
21. i = 8.00,    x = 8.00,       y = 2
22. i = 8.25,    x = 8.50,       y = 2
23. i = 8.50,    x = 9.00,       y = 2
24. i = 8.75,    x = 9.50,       y = 2
25. i = 9.00,    x = 10.00,      y = 2
26. i = 9.25,    x = 10.50,      y = 2
27. i = 9.50,    x = 11.00,      y = 2
28. i = 9.75,    x = 11.50,      y = 2
29. i = 10.00,   x = 12.00,      y = 2
30. i = 10.25,   x = 12.50,      y = 2
31. i = 7.75,    x = 5.50,       y = 3
32. i = 8.00,    x = 6.00,       y = 3
33. i = 8.25,    x = 6.50,       y = 3
34. i = 8.50,    x = 7.00,       y = 3
35. i = 8.75,    x = 7.50,       y = 3
36. i = 9.00,    x = 8.00,       y = 3
37. i = 9.25,    x = 8.50,       y = 3
38. i = 9.50,    x = 9.00,       y = 3
39. i = 9.75,    x = 9.50,       y = 3
40. i = 10.00,   x = 10.00,      y = 3
41. i = 10.25,   x = 10.50,      y = 3
42. i = 10.50,   x = 11.00,      y = 3
43. i = 10.75,   x = 11.50,      y = 3
44. i = 11.00,   x = 12.00,      y = 3
45. i = 11.25,   x = 12.50,      y = 3
46. i = 8.75,    x = 5.50,       y = 4
47. i = 9.00,    x = 6.00,       y = 4
48. i = 9.25,    x = 6.50,       y = 4
49. i = 9.50,    x = 7.00,       y = 4
50. i = 9.75,    x = 7.50,       y = 4
51. i = 10.00,   x = 8.00,       y = 4
52. i = 10.25,   x = 8.50,       y = 4
53. i = 10.50,   x = 9.00,       y = 4
54. i = 10.75,   x = 9.50,       y = 4
55. i = 11.00,   x = 10.00,      y = 4
56. i = 11.25,   x = 10.50,      y = 4
57. i = 11.50,   x = 11.00,      y = 4
58. i = 11.75,   x = 11.50,      y = 4
59. i = 12.00,   x = 12.00,      y = 4
60. i = 12.25,   x = 12.50,      y = 4
61. i = 9.75,    x = 5.50,       y = 5
62. i = 10.00,   x = 6.00,       y = 5
63. i = 10.25,   x = 6.50,       y = 5
64. i = 10.50,   x = 7.00,       y = 5
65. i = 10.75,   x = 7.50,       y = 5
66. i = 11.00,   x = 8.00,       y = 5
67. i = 11.25,   x = 8.50,       y = 5
68. i = 11.50,   x = 9.00,       y = 5
69. i = 11.75,   x = 9.50,       y = 5
70. i = 12.00,   x = 10.00,      y = 5
71. i = 12.25,   x = 10.50,      y = 5
72. i = 12.50,   x = 11.00,      y = 5
73. i = 12.75,   x = 11.50,      y = 5
74. i = 13.00,   x = 12.00,      y = 5
75. i = 13.25,   x = 12.50,      y = 5
76. i = 10.75,   x = 5.50,       y = 6
77. i = 11.00,   x = 6.00,       y = 6
78. i = 11.25,   x = 6.50,       y = 6
79. i = 11.50,   x = 7.00,       y = 6
80. i = 11.75,   x = 7.50,       y = 6
81. i = 12.00,   x = 8.00,       y = 6
82. i = 12.25,   x = 8.50,       y = 6
83. i = 12.50,   x = 9.00,       y = 6
84. i = 12.75,   x = 9.50,       y = 6
85. i = 13.00,   x = 10.00,      y = 6
86. i = 13.25,   x = 10.50,      y = 6
87. i = 13.50,   x = 11.00,      y = 6
88. i = 13.75,   x = 11.50,      y = 6
89. i = 14.00,   x = 12.00,      y = 6
90. i = 14.25,   x = 12.50,      y = 6

Note: Inner for loop executes from 5.5 to 12.5 with a 0.5 step increment for each loop. So its 15 iterations. Outer for loop executes 6 times. So total iterations equals 15 x 6 = 90 times. So 90 values will be printed to the console window.

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert