C Basic Questions
C Basic Questions
Data Types, Constants & Variables, Playing with Operators & Expressions
[Q001] Determine which of the following are VALID identifiers. If invalid, state the
reason.
(a) sample1
(b) 5sample
(c) data_7
(d) return
(e) #fine
(f) variable
(g) 91-080-100
(h) name & age
(i) _val
(j) name_and_age
[Q002] Determine which of the following are VALID character constants. If invalid, state
the reason.
(a) 'y'
(b) '\r'
(c) 'Y'
(d) '@'
(e) '/r'
(f) 'word'
(g) '\0'
(h) '\?'
(i) '\065'
(j) '\''
(k) ' '
[Q003] Determine which of the following are VALID string constants. If invalid, state the
reason.
(a) 'Hi Friends'
(b) "abc,def,ghi"
(c) "Qualification
(d) "4325.76e-8"
(e) "Don\'t sleep"
(f) "He said, "You\'re great"
(g) ""
(h) " "
(i) "Rs.100/-"
[Q004] Determine which of the following numerical values are valid constants. If a
constant is valid, specify whether it is integer or real. Also, specify the base for each valid
integer constant.
(a) 10,500
(b) 080
(c) 0.007
(d) 5.6e7
(e) 5.6e-7
(f) 0.2e-0.3
(g) 0.2e 0.3
(h) 0xaf9s82
(i) 0XABCDEFL
(j) 0369CF
(k) 87654321l
(l) 87654321
[Q005] Determine which of the following floating-point constants are VALID for the
quantity (5 * 100000).
(a) 500000
(b) 0.5e6
(c) 5E5
(d) 5e5
(e) 5e+5
(f) 500E3
(g) .5E6
(h) 50e4
(i) 50.E+4
(j) 5.0E+5
(k) All of the above
(l) None of these
int main()
{
int i=5,j=5;
i=i++*i++*i++*i++;
printf("i=%d ",i);
j=++j*++j*++j*++j;
printf("j=%d",j);
return(0);
}
int main()
{
int i=5;
printf("%d %d %d %d %d",++i,i++,i++,i++,++i);
return(0);
}
int main()
{
int a=1,b=2,c=3;
c=(--a,b)-c;
printf("%d %d %d",a,b,c);
return(0);
}
int main()
{
int a=1,b=2,c=3,d=4,e;
e=(a,a)+(b,c)+(c,d)-(d,b);
printf("%d",e);
return(0);
}
[Q018] What will be the output of the following program :
int main()
{
float val=2.;
printf("%.2",val);
return(0);
}
int main()
{
int a=5;
int b=6;;
int c=a+b;;;
printf("%d",c);;;;
return(0);
int main()
{
printf();
return(0);
}
int main()
{
printf("%%",7);
return(0);
}
int main()
{
printf("//",5);
return(0);
}
unsigned int
char
float
[q024] What is the maximum value of an unsigned char?
255
256
128
[Q025] The following code is not well-written. What does the program do ?
int
main(
){int a=1,
b=2,c=3,d=4;printf("%d %d",
a,b);printf(
" %d %d",c,d);
return(0);
}
1. Write a simple program to read three numbers and find the sum and average.