Output Tips and Tricks

Statements

 Results

The user input  abc 123?

 float x=9;
scanf("%f",&x);
printf("%f",x);

9.000000

putchar('ab');

a

int a=9;

++a=9;

printf("%d",a);

9;

long a=9;
a=9;
printf("%l",a);

%l

Printf (“sum is “, sum)

No output

int a=88;

printf ("%d",a=77);

77

printf ("enter two integers");

Scanf ("\n", &a, &b);

No error

printf("%d",&a);

Output will be the address of a .

for ( int i=0; i <5; i++)

 scanf(" val %d ",& i) ;

Will not read the values

for ( int i=0; i <5; i++)

 scanf("  %d val ",& i) ;

 

Normal -- NO ERROR

for ( int i=0; i <5; i++)

scanf(" %d  ", (* d + i )) ;

Will read 1 more value , if the sapce is in the beginning NORMAL

processor fault

Check the array bounds.  
wrong output

int num;

char s[20];

printf("%s",s);

printf("%d",&num);