C Technical Upto Data Types
C Technical Upto Data Types
#include<stdio.h>
void main()
{
char ch=’a’;
rollnum=10001;
name=”Sumanth”;
printf(“ %d %s”,rollnum,name);
}
Answers:
a. 10001 Sumanth b.10001 c.error d.Sumanth
printf(“\n %d”,x);
}
res=x,y,z;
x,y,z=10,20,30;
printf(“\n %d %d %d”,x,y,z);
}
Answers:
a. 10 20 30 b.10 10 10 c. error d.unknown values
x=5; y=10;
y=x++;
printf(“\n %d %d”,x,y);
}
Answers:
a. 5 10 b. 5 6 c. 6 5 d. 6 6
9. What will be the output of the following.
#include<stdio.h>
void main()
{
int x,y;
x=5;
x=x++ + x++;
printf(“\n %d”,x);
}
Answers:
a. 11 b. 7 c. 12 d. 13
x=5;
x=++x + ++x;
printf(“\n %d”,x);
}
Answers:
b. 13 b. 12 c. 14 d. 7
x=5;
12. Write a C program to input a float value, then print only the fractional portion of the given number;
Ex: 346.65
Output must be : 65
}
Answer:
a. 0 5 b. 0 4 c. error d. 0 0
printf((x>7)?”%d”:”%c”,i);
}
Answers:
a. compilation error b. c c. z d. 107
printf(“\n %d”,x);
Answers:
a. 5 b. 1 c.0 d.error
#include <stdio.h>
void main()
{
float x = 5;
int y=4;
printf("\n %d %f",x,y);
}
Answers:
a. 5 4.000000 b.5.000000 4 c.5.000000 4.000000 d.0 0.000000
19.
#include <stdio.h>
void main()
{
char c1='a',c2='b',c;
c=c1+c2;
if(c>'c')
printf("\n True ");
else
printf("\n False");
}
20.
#include <stdio.h>
void main()
{
signed char ch;
printf("\n %d ",ch=128);
/* output will be -128, because
equallent binary of 128 is : 1000 0000
here (msb)1 000 000 0(lsb)
-128 -> 2's complement notation
abs(-128) =128
1000 0000
0111 1111 (1's complement)
+1
------------
100 0000 */
21.
#include <stdio.h>
void main()
{
if(sizeof(int)>-1)
// result of sizeof (int) is 4, which is signed int which is comparing with unsigned int -1
printf("\n True ");
else
printf("\n False "); */
22.
#include<stdio.h>
void main()
{
float f=0.1;
if(f==0.1)
// here f is float type and 0.1 is higher degree of float i.e double
// with large precession float with 6 digits precession and double is with
10 digits of precession
printf("\n True ");
else
printf("\n False "); */
}
23.
#include<stdio.h>
{
int a,b=1,c=1;
a=sizeof(c=++b +1);
// here, sizeof operator is compile time operator which will found the
//size of c during compilation the expression will not be executed hence b remains 1
24.
#include<stdio.h>
void main()
{
char ch;
printf("%d",ch=255);
}
(ascii codes uses 0-128, -128, -127……-1)
25.
#include<stdio.h>
void main()
{
float f=12.50; // separate rupees and paise
int rs=(int)f;
int ps=((int)(f*100)%100);
printf("\n %d %d ",rs,ps);
}