#include<stdio.h> main() { int a=4123; float b=2.3; char c[]="CCIT"; printf("\n%d",a); printf("\n%f",b); printf("\n%s",c); printf("\n%10d",a); printf("\n%10f",b); printf("\n%10s",c); }
4123 2.300000 CCIT 4123 2.300000 CCIT
#include<stdio.h> main() { int a=4123; float b=2.3123; char c[]="CCIT"; printf("\n%d",a); printf("\n%f",b); printf("\n%s",c); printf("\n%.2d",a); printf("\n%.2f",b); printf("\n%.2s",c); }
4123 2.312300 CCIT 4123 2.31 CC
#include<stdio.h> main() { int a=4123; float b=2.3123; char c[]="CCIT"; printf("\n%10d only",a); printf("\n%10f only",b); printf("\n%10s only",c); printf("\n%-10d only",a); printf("\n%-10f only",b); printf("\n%-10s only",c); }
4123 only 2.312300 only CCIT only 4123 only 2.312300 only CCIT only
#include<stdio.h> main() { int a=4123,b=-322; printf("\n%d",a); printf("\n%d",b); printf("\n%+d",a); printf("\n%+d",b); }
4123 -322 +4123 -322
#include<stdio.h> main() { int a,b,c; printf("Enter Data: "); scanf("%d %d %d",&a,&b,&c); printf("a=%d b=%d c=%d",a,b,c); printf(“\nEnter Data: "); scanf("%3d %2d %1d",&a,&b,&c); printf("a=%d b=%d c=%d",a,b,c); }
Enter Data: 123456 8765 887 a=123456 b=8765 c=887 Enter Data: 123456 8765 887 a=123 b=45 c=6