Find the output of the following program
1) #include<stdio.h>
int main()
{
printf("ss coading") ;
return 0;
}
2) #include<stdio.h>
void main()
{
{
printf("ss" "coading") ;
}
3) what is the
difference between question no 1 and 2
4) #include<stdio.h>
int main()
{
printf("Indians\b is great\n");
printf("ss \rcoading\n");
return 0;
return 0;
}
(5) #include<stdio.h>
int main()
{
int s=10;
printf("s=%d\t",s);
printf("s=%o\t",s);
printf("s=%x",s);
return 0;
return 0;
}
6) #include<stdio.h>
int main()
{
int s=10;
printf("s=%d\t",s);
printf("%c",s);
printf("s=%x",s);
return 0;
return 0;
}
7) #include<stdio.h>
int main()
{
int a=200;
unsigned int 200;
printf("a=%d,b=%u",a,b);
return 0;
return 0;
}
8) #include<stdio.h>
int main()
{
char ch;
printf("enter a character");
scanf("%c",&ch);
printf("%d",ch);
return 0;
return 0;
}
9) #include<stdio.h>
int main()
{
char ch='c ';
printf("%d",ch);
return 0;
return 0;
}
10) #include<stdio.h>
int main()
{
float b=122.1235;
printf("%f\n",b);
printf("%.3f\n",b);
printf("%.2f\n",b);
return 0;
return 0;
}
11) #include<stdio.h>
int main()
{
int a=1.5,b=2,c=0x10,d=010;
printf("a=%d\tb=%d\tc=%d\td=%d",a,b,c,d);
return 0;
return 0;
}
12) #include<stdio.h>
int main()
{
int a=678,b=3456,c=12345;
printf("%3d, %4d, %5d\n",a,b,c);
printf("%5d, %5d, %5d\n",a,b,c);
return 0;
return 0;
}
13) #include<stdio.h>
int main()
{
int a=98;
char ch='c';
printf("%c %d\n",a,ch);
return 0;
return 0;
}
14) #include<stdio.h>
int main()
{
float a1,b1,a2,b2;
a1=2; b1=6.8; a2=4.2; b2=3.57;
printf("%3.1f,%4.2f\n",a1,b1);
printf("%5.1f,%6.2f\n",a2,b2);
return 0;
return 0;
}
(15) #include<stdio.h>
int main()
{
printf("%12s\n","practice");
printf("%6s\n","sscoading");
printf("%.2s\n","sscoad");
printf("%5.4s\n","daily");
return 0;
return 0;
}
ANSWER
1. ss coading
2. sscoading
hint: you will get a warning.
hint: you will get a warning.
3. main function having void return type(in question no 2) i.e it doesn’t return any value to OS whereas int return type returns an integer value to OS.
4. Indian is great
coading
5. s=10 s=12 s=a
6. s=10
s=a
hints: ASCII for newline(‘\n’) is 10
7. compilation error
hints: b undeclared
8. It will print ASCII value for the entered character. E.g a=97, b=98 etc
9. Error
hints : Warning:multi-character character constant
10. 122.123497
122.123
122.12
11. a=1 b=2 c=16 d=8
hints: 0x for hexadecimal
0 for octal
12. 678, 3456, 12345
678, 3456, 12345
hints: for second-line it will take two extra space
13. b 99
14. 2.0,6.80
4.2, 3.57
15. practice
sscoading
ss
dail
No comments:
Post a Comment
For any doubt or suggestion you can write here