#include<stdio.h>
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}
Answers were Sorted based on User's Feedback
Answer / susie
Answer :
Compiler Error
Explanation:
You should not initialize variables in declaration
| Is This Answer Correct ? | 10 Yes | 3 No |
Answer / anand
Compilation error
you should not iniialize the structure variable inside the
declaration.
| Is This Answer Correct ? | 4 Yes | 2 No |
There is no syntax error.
Pointer s is declared but never initialized.
Using uninitialized pointer , trying to access members(x and name) of structure results in invalid access of memory.
Hence segmentation fault.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
why is printf("%d %d %d",i++,--i,i--);
main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); } int i;
How we print the table of 2 using for loop in c programing?
Is it possible to print a name without using commas, double quotes,semi-colons?
what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);
typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }
main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }
how to print 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 using any loop(for or while) only once(only 1 loop) and maximum 2 variables using C.
19 Answers Cap Gemini, Infosys,
Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)
main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }