Wednesday, December 31, 2014

Basic input & output(1)

1:
#include <stdio.h>
///***input operation:
int main(){
   
      int a;
      scanf("%4d",&a);
      printf("%d",a);
     
      return 0;
}

input: 123456

output:1234

2:
#include<stdio.h>
///***printf rules:
int main(){
   
      int a=5,b=6;
      printf("%d %d %d",b,a,a+b);
      return 0;
}

output: 6 5 11

3:
#include<stdio.h>
///***printf function works from the right side
int main(){
   
      int a,b;
      printf("%d %d %d",a+b,b=5,a=4);
      return 0;
}

output:9 5 4

4:

#include<stdio.h>
///***printf function works from the right side
int main(){
   
      int a,b;
      printf("%d %d %d",b=5,a=4,a+b);
      return 0;
}

output: 5 4 garbage
///***because printf function works from the right side


No comments:

Post a Comment