Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

c interview progs.pdf

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
C exam
C exam
Cargando en…3
×

Eche un vistazo a continuación

1 de 6 Anuncio

Más Contenido Relacionado

Similares a c interview progs.pdf (20)

Anuncio

Más reciente (20)

c interview progs.pdf

  1. 1. 1. #include <stdio.h> int main() { Int a = 5, *b, c; b = &a; printf("%d", a * *b * a + *b); return (0); } Output: 130 2. #include <stdio.h> int main() { int i, j = 3; float k = 7; i = k % j; // trying to modulus float value with int printf("%d", i); return (0); } Output: compile time error 3. #include <stdio.h> 4. int main() 5. {
  2. 2. 6. int a; 7. int b = 5; 8. a = 0 && --b; 9. printf("%d %d", a, b); 10. } Explanation:In the logical AND operator, if any of the condition is false then the whole result is false. Here 0 acts as a false value in c therefore the whole result is false and –b is not executed. Therefore the result is 0 5. #include <stdio.h> int main() { int a = 0; while (a < 5) { printf("%dn", a++); } } Explanation:Here, the while loop is going to execute 5 times. We know that a++ is post increment and in post-increment we first assign then increment.when first time while loop execute, while(0<5) the printf function contains n which acts as a backslash escape character. Therefore it prints 0n in the first loop, 1n in the 2nd loop, 3n in the 3rd loop and so on. #include <stdio.h> int main() { int x = 5; if (x >= 10) printf("Hello"); printf("GFG"); else printf("hi"); } Explanation:It will give compilation error because when there is only one statement in the if clause, then curly braces are not required but if there are more than one statement then we must enclose with curly braces and here we are not giving curly braces. Therefore we will get compile time error with a message else without a previous if. It is a problem of handing if statement which is not allowed in C. 1. Find the output
  3. 3. void main() { printf(”%d”); } Answer : a. garbage b. -1 c. 0 d.1 2. What is output ? main() { printf(5+”seventh sense india); } Answer : th sense india 3. Find out put void main() { int success(); int (*sun)(); sun = success; (*sun)(); printf(“%d”,(*sun)()); } int success() { printf(“Hello”); return (3.33); } Answer : a. Hello3 Hello3 b.Hello3 c.Hello Hello3 d.compilation error 4. Find output Aaa() { printf(“Hi”); } Bbb() {
  4. 4. printf(“Hello”); } Ccc() { printf(“Bye”); } void main() { int (*ptr[3])(); ptr[0] = Aaa; ptr[1] = Bbb; ptr[2] = Ccc; ptr[2](); } Answer : a. Hello b. Hi c. Bye d.compilation error 5. struct temp { int a; struct temp no_roll; double c; }obj; Answers: a. Underscore cannot be used in variable declaration b. it will be compiled successfully c. obj must be a pointer to struct d. error: struct variables cannot be included in its own structure 6. int takefirst(int a,int b,int c) { return (++a,b+2,c); } void main( ) { static int m,n; m = takefirst(n,m,n); printf(“%d”,m); }
  5. 5. Answer : a. 2 b.1 c.0 d. syntax error in return statement 7. Find output of fallowing program void main() { printf("Today r is a7b great tday");} Answers : 8. What is output ? void main( ) { int i=107,x=5; printf((x>7)?”%d”:”%c”,i); } Answers: a. compilation error b. k c. z d. 107 9. If a= -11 and b= -3 what is the value of a%b? Answers : a. 2 b.-2 c.3 d.-3 10. Find output int show(int v) { if(v==1||v==0) return 1; if(v % 2==0) return show(v/2) +2;
  6. 6. else return show(v-2) +3; } void main( ) { int z; z = show(7); printf("%d",z); } Answers: a. 11 b.5 c. 10 d.infinite loop

×