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.

C Programming :: Variables & Data Types

Home > C Programming > Variables & Data Types > General Questions

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

#include
int main()
{
float i, j;
scanf(%f %f, &i, &j);
printf(%.2f %.3f, i, j);
return 0;
}

What will be the output for the give input 12.342 and 123.4568

Answer: 12.34 123.456

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

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

#include
void main()

{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}

Answer: I hate U

Explanation:

For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.

Important Note:
Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .

Workspace

Tags:

No Tags on this question yet!

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

#include
int main(){
int a=5;
static int b=a;
printf("%d %d",a,b);
return 0;
}

Answer: Compilation error

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

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

#include
void main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}

Answer: 5 4 3 2 1

Explanation:

When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.

Workspace

Tags:

No Tags on this question yet!

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

#include
int main(){
float x;
x=(int)5.6f*3.2f/sizeof((int)6.6);
printf("%f",x);
return 0;
}

Answer: 8

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

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

#include
int main(){
float **(*ptr)[4]=(float **(*)[4])0;
ptr+=5;
printf("%d %d",ptr,sizeof ptr);
return 0;
}

Answer: 40 2

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

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

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

Answer: 100

Explanation:

This is the correct way of writing the previous program.

Workspace

Tags:

No Tags on this question yet!

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

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

Answer: Linker Error : Undefined symbol "I"

Explanation:

extern storage class specifies to the compiler that the memory for "i" is allocated in some other program and that address will be given to the current program at the time of linking.

But linker finds that no other variable of name "i" is available in any other program with memory space allocated for it.

Hence a linker error has occurred .

Workspace

Tags:

No Tags on this question yet!

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

#include
int main(){
float **(*ptr)[4]=(float **(*)[4])0;
ptr+=5;
printf("%d %d",ptr,sizeof ptr);
return 0;
}

Answer: 40 2

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

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

#include
int main(){
float x;
x=(int)5.6 * 3.2/sizeof((int)6.6);
printf("%f",x);
return 0;
}

Answer: 4

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!