Tell me the output

1
2
3
4
5
6
int main()
{
int i=300;
int j=400;
printf("%d..%d);
} 


I am getting garbage value but i read somewhere that printf takes first two assignments of the program.According to it i should get output as:
300..400
but i am getting output as:
420080..420080
printf() is not psychic. You have to tell it which values to print:

1
2
3
4
5
6
int main()
{
    int i=300;
    int j=400;
    printf("%d..%d", i, j);
} 
Last edited on
I am sure you have this but you need to include the stdio header file, also you can declare both int variables on the same line, and as Galik said above, you need to tell C what variables to use in the print function:

1
2
3
4
5
6
7
8
9
#include <stdio.h>

int main()
{
int i = 300, j = 400;
printf("%d..%d", i, j);
getch();
return 0;
}
Topic archived. No new replies allowed.