21 Temmuz 2013 Pazar

Objective questions of c



Objective type questions on c with answers for interview 
C programming language objective questions and answers

(1)
#define max value 10
int main(){
    int a=60;
    if(a/max value==6)
         printf("equal");
    else
         printf("not equal");
return 0;
}

What will be output if you compile and execute the above code?
(a)equal
(b)not equal
(c)Run time error
(d)Compiler error

(2)
#define num int long
int main(){
    num a=0;
    printf("%d,%d,%d",a++,sizeof a++,sizeof(a++));
    return 0;
}

What will be output if you compile and execute the above code?
(a)3 2 4
(b)0 0 4
(c)0 4 4
(d)Compiler error

(3)
#define short int long
int main(){
    printf("%d",sizeof(short));
    return 0;

   
}

What will be output if you compile and execute the above code?
(a)2
(b)4
(c)8
(d)Compiler error

(4)
#define float char
int main(){       
float f=255;
    printf("%d",sizeof(f++));
return 0;
}

What will be output if you compile and execute the above code?
(a)1
(b)2
(c)8
(d)Compiler error

(5)
int main(){      
char f=255.0;
    printf("%d",sizeof(f++));
return 0;
}

What will be output if you compile and execute the above code?
(a)1
(b)8
(c)10
(d)Compiler error

(6)
int main(){       
char f=255;
    f++;
    printf("%d",sizeof(f));
return 0;
}

What will be output if you compile and execute the above code?
(a)1
(b)2
(c)4
(d)Compiler error

(7)
#define value 10\2
int main(){
printf("%d",value);
return 0;
}

What will be output if you compile and execute the above code?
(a)5
(b)20
(c)102
(d)Compiler error

(8)
#define xxx 11\
3
int main(){
    printf("%ld",xxx);
    return 0;
}

What will be output if you compile and execute the above code?
(a)11
(b)3
(c)113
(d)Compiler error

(9)
#define option1 a++; printf("%d",a);
#define option2 print("%d",a);
int main(){
    int a=10;
    if(a++)
         option1
    else
         option2; 
}

What will be output if you compile and execute the above code?
(a)10
(b)11
(c)12
(d)Compiler error

(10)
//test.c
int main(){
    printf("%s",__FILE__);
}

What will be output if you compile and execute the above code?
(a)null
(b)test.c
(c)url of current working directory
(d)Compiler error

(11)
#include"stdio.h"
int main(){
    #ifdef __stdio_h
         prinrf("defined");
    #else
         printf("not defined");
    #endif
return 0;
}

What will be output if you compile and execute the above code?
(a) defined
(b) not defined
(c)Run time error
(d)Compiler error

(12)
#include"stdio.h"
int main(){
    const int a=1;
   
    #if 5+~5+1
         printf("%d",a+1);
    #elif 7
         printf("%d",a+2);
    #else
         printf("%d",a+3);
    #endif
return 0;   
}

What will be output if you compile and execute the above code?
(a)2
(b)3
(c)4
(d)Compiler error

(13)
#define conio.h
#include "stdio.h"
#define max 0\5
int main(){
    #ifndef __conio_h
    #define conio.h
    printf("%s",__TIME__);
    #else
    #undef __conio_h
    printf("%s",__DATE__);
    #endif
return 0;   
}

What will be output if you compile and execute the above code?
(a)Output will be date of compilation
(b)Output will be time of compilation
(c)Output will be both time of compilation and date of compilation
(d)Compiler error

(14)
#define max 5
#define a max*max
#define value a\a
int main(){
    const int aa=5;
    printf("%d",value+aa);
return 0;
}

What will be output if you compile and execute the above code?
(a)5
(b)6
(c)10
(d)Compiler error

(15)
#define function(a,b) a##b
int main(){
    printf("%d",function(5,2));
    return 0;
}

What will be output if you compile and execute the above code?
(a)10
(b)2
(c)52
(d)Compiler error

(16)
#define find(a,b,c) #a#b#c
int main(){
    int a=10;
    int b=20;
    int c=30;
    printf("%s",find(a,b,c)+1);
return 0;
}

What will be output if you compile and execute the above code?
(a)102030
(b)02030
(c)bc
(d)Compiler error

(17)
#define swap(x,y) x^=y^=x^=y
int main(){
    int a=10,b=20;
    swap(a,b);
    printf("%d %d" ,a,b);
    return 0;
}

What will be output if you compile and execute the above code?
(a)10 20
(b)20 10
(c)0 10
(d)Compiler error

(18)
#define int long
#define cal(x,y,z) x*y*z
int main(){
    int a=2;
    int b=cal(a++,a++,a++);
    printf("%d,%d" ,a,b);
    return 0;
}

What will be output if you compile and execute the above code?
(a)5,0
(b)5,125
(c)5,60
(d)Compiler error

(19)
#define final(a,b,c) ++a+ ++b+ ++c
int main(){
    printf("%d" ,final(1,2,3));
    return 0;
}

What will be output if you compile and execute the above code?
(a)6
(b)9
(c)10
(d)Compiler error

(20)
void one();
void two();
#pragma startup one 2
#pragma startup two 1
int main(){
    printf("main ");
return 0;
}
void one()
{
    printf("one ");
}
void two()
{
    printf("two ");
}

What will be output if you compile and execute the above code?
(a)main one two
(b)one main two
(c)main
(d)two main one

Answer of c programming objective types questions and answers

1.     (d)
2.     (c)
3.     (b)
4.     (a)
5.     (a)
6.     (a)
7.     (c)
8.     (c)
9.     (d)
10.    (b)
11.    (b)
12.    (b)
13.    (b)
14.    (c)
15.    (c)
16.    (c)
17.    (b)
18.    (a)
19.    (d)
20.    (d)

C dili video dersleri

Bu bölümde baştan sonra C dilini anlatan videolara ulaşabilirsiniz.

Bu videoları baştan sonra izlediğinizde hiç birşey bilmediğinizi düşündüğünüz C dili hakkında temeli atmış hatta biraz üzerine koymuş olacaksınız.

Cproggramming olarak bizlere destek olmak için facebook sayfamızı beğenebilir , Aklınızdaki sorular için marmara.sinancanbayrak@gmail.com adresi ile iletişime geçebilirsiniz. Bol C li günler :)

1- C programlama diline giriş                 13- C programlama dili Fonksiyon1               

2- C programlama dili Scanf ve Printf    14- C programlama dil Fonksiyon2

3- C programlama dili 4 işlem                15- C programlama dili Mat Fonksiyon1

4-C programlama dili değişkenler          16- C programlama dil Mat Fonksiyon2

5-C programlama dili İf- else if              17- C programlama dil Random Fonksiyonu

6-C programlama dili Switch - Case      18- C programlama dil Karakter Fonksiyonları

7-Cprogramlama dili Switch - Case (devam  19- C programlama dili Dizi Kullanımı

8-C programlama dili go-to deyimi          20- C programlama dili Dizi Matrisi

9-C programlama dili  while döngüsü       21- C programlama dil Göstericiler1

10-C programlama dili do while               22- C programlama dil Göstericiler 2

11-C programlama dili for döngüsü1        23- C programlama dil Göstericiler 3

12-C programlama dili for döngüsü2

C programlama dili hakkında diğer videolu konu anlatım videomuz için: C dili video konu anlatımları 



C Dersleri-Ders 11 - Pointer Kavramı

C Dersleri-Ders 12.1 -String ve bazı standart fonksiyonlar

C Dersleri-Ders 12.2 -String ve bazı standart fonksiyonlar II