union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}
a. 4, 4, 0
b. 0, 0, 0
c. 100, 4, 0
d. 40, 4, 0
main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }
What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }
#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }
#ifdef something int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }
There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }
Write a program that reads a dynamic array of 40 integers and displays only even integers
main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }
Write a C program to print ‘Campus Force training’ without using even a single semicolon in the program.
void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }
main() { unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally, print out how many zeros and ones in the diagonal.
Write a program to receive an integer and find its octal equivalent?