Wednesday, April 11, 2018

C Interview questions

There are lot's of programmer in the world. Most of the programmer practice common things in programming .It's a matter of fact lot of programmer doesn't know  some tricky things.That's why i'm sharing some tricky question on c language. It's helps you to learn new things and makes your logic clear. It's also helps various interview of software engineering field , company interview and others

Let's learn 

What will be the output of this code ?

#include<stdio.h>
int main()
{
int x[3] = {0,2,3};
printf("%d",sizeof(x));
return 0;
}

Answer: 12


What will be the output of this code ?

#include <stdio.h>
    int main()
    {
        char str[] = "world, world";
        str[4] = '.';
        printf("%s\n", str);
        return 0;
    }

Answer: world. world

Print your name 3 times without using for loop ?

#include <stdio.h>
#include <conio.h>
void print(char* name,int coun)
{
    printf("%d : %s\n",coun+1,name);
    coun+=1;
    if(coun<3)
        print(name,coun);
}
int main()
{
    char name[10];
    printf("Name :");
    scanf("%s",name);
    print(name,0);
    return 0;
}

When code execute what will be the result?

#include <stdio.h>
int main() {

  int a,b,d;
  a = 5;
  b = a-2;
  if (a > b)
   d  = b;
  else
    d = 8;
 printf("%d",d );
  return 0;
}

Answer: 3

What will be the output of this program ?

#include<stdio.h>
int main(){
int x = 103;
int *z;
z = &x;
z++;
printf("%d ",*z);
return 0;
}

Answer: Garbage value


No comments:

Post a Comment