Please help me with bebugging this code, I am trying to find the product of first 10 Natural numbers but it is printing 0 in output. My Code:  #include int main() { int p=0; for(int i=1;i<=10;i++){ p = p*i; } printf("%d",p); return 0; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question

Please help me with bebugging this code, I am trying to find the product of first 10 Natural numbers but it is printing 0 in output.

My Code: 

#include <stdio.h>

int main()
{
int p=0;
for(int i=1;i<=10;i++){
p = p*i;
}
printf("%d",p);
return 0;
}

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning