Wednesday, August 17, 2022

[FIXED] Why is my printf function to calculate polynomial not shown in the the command output?

Issue

I'm just learning the C programming language . Could you explain to me why isn't my output produced?

#include <stdio.h>
int main (void)
{
    int x , total ;
    printf("Enter the value of x : ");
    scanf("%i\n", x);
    total = (3 * x * x * x * x * x) + (2 * x * x * x * x) - (5 * x * x * x) - (2 * x * x) + (7 * x) - 6;
    printf("Total value of the polynomial is %i\n", total);
    return 0 ;
}


Solution

Change the scanf to:

   scanf("%i", &x);

You need to pass in the address of x to assign it a value from the scanf function. Also no \n



Answered By - OldProgrammer
Answer Checked By - Mildred Charles (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.