Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

C Programming :: Basic Concepts

Home > C Programming > Basic Concepts > General Questions

11. What will be the output of the below C program.

#include
int main()
{
printf("%d", out);
return 0;
}
int out=100;

Answer: Option A

Explanation:

The rule is that a variable is available for use from the point of declaration. Even though a is a global variable, it is not available for main. Hence an error.

Workspace


Tags:  No Tags on this question yet!

12. What will be the output of the below C program.

#include
int main()
{
extern int i; i=20;
printf("%d",sizeof(i));
return 0;
}

Answer: Option B

Explanation:

extern declaration specifies that the variable i is defined somewhere else. The compiler passes the external variable to be resolved by the linker. So compiler doesn't find an error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.

Workspace


Tags:  No Tags on this question yet!

13. What will be the output of the below C program.

#include
int main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
return 0;
}

Answer: Option C

Explanation:

Unary + is the only dummy operator in C. Where-ever it comes you can just ignore it just because it has no effect in the expressions (hence the name dummy operator).

Workspace


Tags:  No Tags on this question yet!

14. What will be the output of the below C program.

#include
int main()
{
int i=-1;
-i;
printf("i = %d, -i = %d \n",i,-i);
return 0;
}

Answer: Option A

Explanation:

-i is executed and this execution doesn't affect the value of i. In printf first you just print the value of i.
After that the value of the expression -i = -(-1) is printed.

Workspace


Tags:  No Tags on this question yet!

15. What will be the output of the below C program.

#include
int main()
{
int k=1;
printf("%d==1 is %s",k,k==1?"TRUE":"FALSE");
return 0;
}

Answer: Option A

Explanation:

When two strings are placed together (or separated by white-space) they are concatenated (this is called as "stringization" operation). So the string is as if it is given as "%d==1 is %s". The conditional operator( ?: ) evaluates to "TRUE".

Workspace


Tags:  No Tags on this question yet!

16. What will be the output of the below C program.

#include
int main(){
int a= 0;
int b = 20;
char x =1;
char y =10;
if(a,b,x,y)
printf("hello");
return 0;
}

Answer: Option A

Explanation:

The comma operator has associativity from left to right. Only the rightmost value is returned and the other values are evaluated and ignored.
Thus the value of last variable y is returned to check in if. Since it is a non zero value if becomes true so, "hello" will be printed.

Workspace


Tags:  No Tags on this question yet!

17. What will be output of the following "c" code?

#include
int main(){
printf("%d","abcde"-"abcde");
return 0;
}

Answer: Option A

Explanation:

Just count ASCII values and minus them, the value will be 0.

Workspace


Tags:  No Tags on this question yet!

18. What is the output of the following 'C' program ?

#include
#include
void main()
{
printf("%f",sqrt (36.0));
}

Answer: Option C

Explanation:

The sqrt() function returns the square root of a given argument.

Here, the argument is 36.0, so sqrt() function returns 6.000000, as the return type we want is in float.

Workspace


Tags:  No Tags on this question yet!

19. What is the output of the following C Program?

#include
void main()
{
printf("%d %d %d", sizeof(3.14f), sizeof(3.14), sizeof (3.14l));
}

Answer: Option C

Explanation:

Here, 3.14f denotes that it is a float-type value, so the size of a float-type value is 4 bytes.

Similarly, 3.14 denotes it is a double-type value, so it's size is 8 bytes.

And, 3.14l denotes it is a long double type of variable, so it's size is 12 bytes.

Hence, the output is 4 8 12.

Workspace


Tags:  No Tags on this question yet!

20. What is the output of the following 'C' program ?

#include
void main()
{
printf(5 + "Fascimile");
}

Answer: Option C

Explanation:

In line no. 4, '5' denotes that the characters should be displayed from the 5th index to the (n-1)th index i.e, 8th index in the given string "Fascimile".

Hence, the output is mile.

Workspace


Tags:  No Tags on this question yet!



Most Popular Qs.

Latest MCQ Qs.