printf - C Wrong Answer when squaring -
i'm learning c using c example. there question need take input integer , square , print screen. i'm having strange error, when no matter int enter give me output:
please enter number. 5 number = 2686764 square of number = 2686760
here program wrote.
#include <stdio.h> #include <conio.h> //for getch() main(){ int number, square; printf("please enter number. \n"); scanf("%d", &number); square = number*number; printf("\n number = %d ", &number); printf("\t square of number = %d", &square); getch(); }
to add above answers ... @ example:
int number = 5; printf(" %d\n", number); // prints value of 'number'. printf(" %p\n", &number); // prints address of 'number'. printf(" %d\n", *(&number)); // prints value @ address of 'number' ...
Comments
Post a Comment