Questions for: Declarations And Initializations
#include<stdio.h>
struct emp
{
char name[20];
int age;
};
int main()
{
emp int xx;
int a;
printf("%d\n", &a);
return 0;
}
There is an error in the line emp int xx;
To overcome this error, remove the int and add the struct at the begining of emp int xx;
#include<stdio.h>
struct emp
{
char name[20];
int age;
};
int main()
{
struct emp xx;
int a;
printf("%d\n", &a);
return 0;
}
#include<stdio.h>
int main()
{
void v = 0;
printf("%d", v);
return 0;
}
Discuss About this Question.
#include<stdio.h>
int main()
{
display();
return 0;
}
void display()
{
printf("ExamAdept.com");
}
In this program the compiler will not know that the function display() exists. So, the compiler will generate "Type mismatch in redeclaration of function display()".
To over come this error, we have to add function prototype of function display().
Another way to overcome this error is to define the function display() before the int main(); function.
#include<stdio.h>
void display(); /* function prototype */
int main()
{
display();
return 0;
}
void display()
{
printf("ExamAdept.com");
}
Output: ExamAdept.com
Note: This problem will not occur in modern compilers (this problem occurs in TurboC but not in GCC).
Discuss About this Question.
#include<stdio.h>
int main()
{
int X=40;
{
int X=20;
printf("%d ", X);
}
printf("%d\n", X);
return 0;
}
Discuss About this Question.
#include<stdio.h>
int main()
{
int i=5;
for(;scanf("%s", &i); printf("%d\n", i));
return 0;
}
During the for loop execution scanf() ask input and then printf() prints that given input. This process will be continued repeatedly because, scanf() returns the number of input given, the condition is always true(user gives a input means it reurns '1').
Hence this for loop would get executed infinite times.
Discuss About this Question.
Discuss About this Question.