SlideShare a Scribd company logo
C Programs
TYPEDEF

1. What can be said of the following program ?
main()
{
enum Months {JAN =1,FEB,MAR,APR};
Months X = JAN;
if(X==1)
{
printf("Jan is the first month");
}
}
a) Does not print anything
b) Prints : Jan is the first month
c) Generates compilation error
d) Results in runtime error
Answer : b

2.main()
    {
           extern int i;
           i=20;
           printf("%d",i);
     }

           Answer:
                   Linker Error : Undefined symbol '_i'
          Explanation:
extern storage class in the following declaration,
                              extern int i;
specifies to the compiler that the memory for iis allocated in some other program and that address
will be given to the current program at the time of linking. But linker finds that no other variable of
name iis available in any other program with memory space allocated for it. Hence a linker error has
occurred .

3. enum colors {BLACK,BLUE,GREEN}
         main()
         {

           printf("%d..%d..%d",BLACK,BLUE,GREEN);

           return(1);
           }
           Answer:
                     0..1..2
           Explanation:
                     enum assigns numbers starting from 0, if not explicitly defined.




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
4. Given the following statement enum day = { jan = 1 ,feb=4, april, may} What is the value
of may?
(a) 4
(b) 5
(c) 6
(d) 11
(e) None of the above
Answer c) 6

SWITCH:

5. What is the output of the following program?
main()
{
int l=6;
switch(l)
{ default : l+=2;
case 4: l=4;
case 5: l++;
break;
}
printf("%d",l);
}
a)8 b)6 c)5 d)4 e)none

Answer : c) 5

    6. main()
    {
         int i=3;
         switch(i)
         {
         default:printf("zero");
         case 1: printf("one");
                   break;
         case 2:printf("two");
                   break;
         case 3: printf("three");
                   break;
         }
    }
         Answer :
                   three
         Explanation :
                   The default case can be placed anywhere inside the loop. It is executed only when all
other cases doesn't match.

7.        #include<stdio.h>
          main()
          {
          int i=1,j=2;
          switch(i)
          {




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
case 1: printf("GOOD");
                     break;
            case j: printf("BAD");
            break;
            }
            }
            Answer:
                     Compi ler Error: Constant expression required in function main.
            Explanation:
                     The case statement can have only constant expressions (this implies that we cannot
                     use variable names directly so an error).
            Note:
                     Enumerated types can be used in case statements.

8. main()
            {
                      float i=1.5;
                      switch(i)
                      {
                                case 1: printf("1");
                                case 2: printf("2");
                                default : printf("0");
                      }
            }
            Answer:
                    Compi ler Error: switch expression not integral
            Explanation:
                    Switch statements can be applied only to integral types.

10. Output of the following program is
main()
{
        int i=0;
        for(i=0;i<20;i++)
        {
        switch(i)
        case 0:i+=5;
        case 1:i+=2;
        case 5:i+=5;
        default i+=4;
        break;
        }
        printf("%d,",i);
        }
}

a) 0,5,9,13,17
b) 5,9,13,17
c) 12,17,22
d) 16,21
e) Syntax error

Ans. (d)




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
11. main()
{
int i;
for(i=0;i<3;i++)
switch(i)
{
case 1: printf("%d",i);
case 2 : printf("%d",i);
default: printf("%d"i);
}
}
 Answer: 011122

FUNCTIONS:

12. What is the output of the following program?
main()
{
int x=20;
int y=10;
swap(x,y);
printf("%d %d",y,x+2);
}
swap(int x,int y)
{
int temp;
temp =x;
x=y;
y=temp;
}

    a) 10,20 b) 20,12 c) 22,10 d)10,22 e)none


Answer : d)10,22

13. Which of the following about the following two declaration is true
i ) int *F()
ii) int (*F)()
 Choice :
a) Both are identical
b) The first is a correct declaration and the second is wrong
c) The first declaraion is a function returning a pointer to an integer and the second is a
pointer to              function returning int
d) Both are different ways of declarin pointer to a function

          Answer : c).

     14. main()
     {
         printf("%p",main);
     }




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
Answer:
                   Some address will be printed.
         Explanation:
         Function names are just addresses (just like array names are addresses).
main() is also a function. So the address of function main will be printed. %p in printf specifies that
the argument is an address. They are printed as hexadecimal numbers.

15. main()
         {
         clrscr();
         }
         clrscr();

          Answer:
                  No output/error
          Explanation:
                  The first clrscr() occurs inside a function. So it becomes a function call. In the second
                  clrscr(); is a function declaration (because it is not inside any function).

16.      main()
         {
         int i;
         printf("%d",scanf("%d",&i)); // value 10 is given as input here
         }
         Answer:
                  1
         Explanation:
Scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should
have been scanned successfully. So number of items read is 1.

17. main()
         {
         show();
         }
         void show()
         {
         printf("I'm the greatest");
         }
         Answer:
                   Compi er error: Type mismatch in redeclaration of show.
         Explanation:
                   When the compiler sees the function show it doesn't know anything about it. So the
                   default return type (ie, int) is assumed. But when compiler sees the actual definition
                   of show mismatch occurs since it is declared as void. Hence the error.
                   The solutions are as follows:
                            1. declare void show() in main() .
                            2. define show() before main().
                            3. declare extern void show() before the use of show().

18. main()
         {
         main();
         }




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
Answer:
                  Runtime error : Stack overflow.
          Explanation:
                   main function calls itself again and again. Each time the function is called its return
                   address is stored in the call stack. Since there is no condition to terminate the
                   function call, the call stack overflows at runtime. So it terminates the program and
                   results in an error.

19. What are the following notations of defining functions known as?
         i.       int abc(int a,float b)
{
/* some code */
                    }
         ii.    int abc(a,b)
         int a; float b;
{
/* some code*/
}
         Answer:
                    i. ANSI C notati on
                    ii. Kernighan & Ritche notation



     20. What is printed when this program is executed
     main()
     {
     printf ("%dn",f(7));
     }
     f(X)
     {

                                       if ( x<= 4)
     return x;

     return f(--x);
     }
     a) 4
     b)5
     c) 6
     d) 7

     Answer : a)


     21. what is printed when the following program is compiled and executed?
     int    func (int x)
     {
     if (x<=0)
     return(1);
     return func(x -1) +x;

     }
     main()




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
{
     printf("%dn",func(5));
     }
     a) 12
     b) 16
     c) 15
     d) 11

          Answer : .b) 16.

     22. Find the out put:
                   main()
                   {
                   int a==4
sqrt(a);
printf("%d",a);
                   }
1).2.0         2). 2       3). 4.0              4). 4
                  Answer : 2

23. Find the output
main()
{
int a[]={ 2,4,6,8,10 };
int i;
                     change(a,5);
                     for( i = 0; i <= 4; i++)
                     printf("n %d",a[i]);
          }
          change( int *b, int n)
          {
          int i;
          for( i = 0; i < n; i++)
          *(b+i) = *(b+i) + 5;
          }
Answer:



24. #include<studio.h>
main()
{
func(1);
}
func(int i){
static char *str[] ={ "One","Two","Three","Four"};
printf("%sn",str[i++]);
return;
}
Answer:- it will give warning because str is pointer to the char but
it is initialized with more values
if it is not considered then the answer is Two */




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
25. Find the out put:

#include<stdio.h>
/* This problem was asked in PCS Bombay in a walk-in-interview
Write a recursive function that calculates
n * (n-1) * (n-2) * ....... 2 * 1 */

main() {
int factorial(int n);
int i,ans;
printf("n Enter a Number:");
scanf("%d",&i);
ans = factorial(i);
printf("nFactorial by recursion = %dn", ans);
}
int factorial(int n)
{
if (n <= 1) return (1);
else
return ( n * factorial(n-1));
}

Answer :

26.Find the output

#include <stdio.h>
main()
{
int j,ans;
j = 4;
ans = count(4);
printf("%dn",ans);
}

int count(int i)
{
if ( i < 0) return(i);
else
return( count(i-2) + count(i-1));
}
Answer :

/* It is showing -18 as an answer */

     27. Find the out put

      int x;
      main()
      {
      int x=0;
      {




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
int x=10;
      x++;
      change_value(x);
      x++;
      Modify_value();
      printf("First output : %dn",x);
      }
      x++;

      change_value(x);
      printf("Second Output : %dn",x);
      Modify_value();
      printf("Third Output : %dn",x);
      }

     Modify_val ue()
     {
     return (x+=10);
     }
     change_value()
     {
     return(x+=1);
     }
     Answer :




28. Consider the following program
main()
{
int i=20,*j=&i;
f1(j);
*j+=10;
f2(j);
printf("%d and %d",i,*j);
}
f1(k)
int *k;
{
*k +=15;
}

f2(x)
int *x;
{
int m=*x,*n=&m;
*n += 10;
}

The values printed by the program will be
a) 20 and 55
b) 20 and 45
c) 45 and 45




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
d) 45 and 55
e) 35 and 35
Answer : c

29. what is printed when the following program is
compiled and executed?

int func (int x)
{
if (x<=0)
return(1);
return func(x -1) +x;
}
main()
{
printf("%dn",func(5));
}

a) 12
b) 16
c) 15
d) 11
Answer : b


STRUCTURE AND UNION:

30. What is the size of the following union. Assume that the size of int =2, size of float =4 and size of
char =1.

Union Tag
{
int a;
float b;
char c;
};

a)2       b)4c)1 d) 7

Answer : b



DATA TYPES
     31. What is th output of the fol lowing program?
int x= 0x65;
main()
{
char x;
printf("%dn",x)
}
a) compilation error    b) 'A'     c) 65       d) unidentified




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com
Answer : c




PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450   / 96000 66689
                 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli
                Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses.
                                            www.pantechprojects.com

More Related Content

What's hot

Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
karmuhtam
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmer
Miguel Vilaca
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
Leandro Schenone
 
C programming-apurbo datta
C programming-apurbo dattaC programming-apurbo datta
C programming-apurbo datta
Apurbo Datta
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
Mohammed Saleh
 
C programming session3
C programming  session3C programming  session3
C programming session3
Keroles karam khalil
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
Saket Pathak
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
Anil Bishnoi
 
PHP Reviewer
PHP ReviewerPHP Reviewer
PHP Reviewer
Cecilia Pamfilo
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
Vikram Nandini
 
C programming
C programmingC programming
Kuliah komputer pemrograman
Kuliah  komputer pemrogramanKuliah  komputer pemrograman
Kuliah komputer pemrogramanhardryu
 
Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5
Ismar Silveira
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paperfntsofttech
 
VTU 1ST SEM PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
VTU 1ST SEM  PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...VTU 1ST SEM  PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
VTU 1ST SEM PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
vtunotesbysree
 
02. functions & introduction to class
02. functions & introduction to class02. functions & introduction to class
02. functions & introduction to class
Haresh Jaiswal
 
Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02
CIMAP
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 

What's hot (20)

Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmer
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
C programming slide-6
C programming slide-6C programming slide-6
C programming slide-6
 
C programming-apurbo datta
C programming-apurbo dattaC programming-apurbo datta
C programming-apurbo datta
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
C programming session3
C programming  session3C programming  session3
C programming session3
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 
PHP Reviewer
PHP ReviewerPHP Reviewer
PHP Reviewer
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
C programming
C programmingC programming
C programming
 
Kuliah komputer pemrograman
Kuliah  komputer pemrogramanKuliah  komputer pemrograman
Kuliah komputer pemrograman
 
Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5Paradigmas de Linguagens de Programacao - Aula #5
Paradigmas de Linguagens de Programacao - Aula #5
 
Fnt software solutions placement paper
Fnt software solutions placement paperFnt software solutions placement paper
Fnt software solutions placement paper
 
VTU 1ST SEM PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
VTU 1ST SEM  PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...VTU 1ST SEM  PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
VTU 1ST SEM PROGRAMMING IN C & DATA STRUCTURES SOLVED PAPERS OF JUNE-2015 & ...
 
02. functions & introduction to class
02. functions & introduction to class02. functions & introduction to class
02. functions & introduction to class
 
Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 

Viewers also liked

Gender research final project
Gender research final projectGender research final project
Gender research final projectbahslerd
 
Gender Education
Gender EducationGender Education
Gender Educationwritemind
 
SOC 463/663 (Social Psych of Education) - Gender & Education
SOC 463/663 (Social Psych of Education) - Gender & EducationSOC 463/663 (Social Psych of Education) - Gender & Education
SOC 463/663 (Social Psych of Education) - Gender & Education
Melanie Tannenbaum
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
In a Rocket
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
Kirsty Hulse
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
ux singapore
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Stanford GSB Corporate Governance Research Initiative
 

Viewers also liked (7)

Gender research final project
Gender research final projectGender research final project
Gender research final project
 
Gender Education
Gender EducationGender Education
Gender Education
 
SOC 463/663 (Social Psych of Education) - Gender & Education
SOC 463/663 (Social Psych of Education) - Gender & EducationSOC 463/663 (Social Psych of Education) - Gender & Education
SOC 463/663 (Social Psych of Education) - Gender & Education
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Similar to Aptitute question papers in c

Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
Sujata Regoti
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2docSrikanth
 
Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01
ManjeeraBhargavi Varanasi
 
C language questions_answers_explanation
C language questions_answers_explanationC language questions_answers_explanation
C language questions_answers_explanation
srinath v
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2Amit Kapoor
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
Java Quiz
Java QuizJava Quiz
Java Quiz
Dharmraj Sharma
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
SAKSHIGAWADE2
 
Functional Programming in C#
Functional Programming in C#Functional Programming in C#
Functional Programming in C#
Giorgio Zoppi
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
Dipta Saha
 
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
rafbolet0
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
YashwanthCse
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
choconyeuquy
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
vrickens
 
Switch statement mcq
Switch statement  mcqSwitch statement  mcq
Switch statement mcq
Parthipan Parthi
 
Programming in C
Programming in CProgramming in C
Programming in C
Nishant Munjal
 
Functions
FunctionsFunctions
Functions
Jesmin Akhter
 

Similar to Aptitute question papers in c (20)

Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2doc
 
Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01
 
Ppl home assignment_unit2
Ppl home assignment_unit2Ppl home assignment_unit2
Ppl home assignment_unit2
 
C language questions_answers_explanation
C language questions_answers_explanationC language questions_answers_explanation
C language questions_answers_explanation
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
Java Quiz
Java QuizJava Quiz
Java Quiz
 
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branchComputer experiments   1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
Computer experiments 1^j2^j3^j4^j8^j9. d24 ^j sakshi gawade cs branch
 
Functional Programming in C#
Functional Programming in C#Functional Programming in C#
Functional Programming in C#
 
C Tutorials
C TutorialsC Tutorials
C Tutorials
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
Switch statement mcq
Switch statement  mcqSwitch statement  mcq
Switch statement mcq
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Functions
FunctionsFunctions
Functions
 

More from Pantech ProEd Pvt Ltd

2013 14-ns2-project-titles-me-mtech
2013 14-ns2-project-titles-me-mtech2013 14-ns2-project-titles-me-mtech
2013 14-ns2-project-titles-me-mtech
Pantech ProEd Pvt Ltd
 
2013 14-embedded-project-titles-pantech-me-m tech-project-titles
2013 14-embedded-project-titles-pantech-me-m tech-project-titles2013 14-embedded-project-titles-pantech-me-m tech-project-titles
2013 14-embedded-project-titles-pantech-me-m tech-project-titles
Pantech ProEd Pvt Ltd
 
2013 14-dotnet-titles-pantech-proed-for-me-mtech
2013 14-dotnet-titles-pantech-proed-for-me-mtech2013 14-dotnet-titles-pantech-proed-for-me-mtech
2013 14-dotnet-titles-pantech-proed-for-me-mtech
Pantech ProEd Pvt Ltd
 
2013 14-java-project-titles-me-tech-pantech
2013 14-java-project-titles-me-tech-pantech2013 14-java-project-titles-me-tech-pantech
2013 14-java-project-titles-me-tech-pantech
Pantech ProEd Pvt Ltd
 
2013 14-power-electronics-project-titles-me-mtech
2013 14-power-electronics-project-titles-me-mtech2013 14-power-electronics-project-titles-me-mtech
2013 14-power-electronics-project-titles-me-mtech
Pantech ProEd Pvt Ltd
 
2013 14-power-systems-project-titles-for-me-m-tech-pantech
2013 14-power-systems-project-titles-for-me-m-tech-pantech2013 14-power-systems-project-titles-for-me-m-tech-pantech
2013 14-power-systems-project-titles-for-me-m-tech-pantechPantech ProEd Pvt Ltd
 
2013 14-vlsi-project-titles-for-me-mtech-pantech-pro ed
2013 14-vlsi-project-titles-for-me-mtech-pantech-pro ed2013 14-vlsi-project-titles-for-me-mtech-pantech-pro ed
2013 14-vlsi-project-titles-for-me-mtech-pantech-pro edPantech ProEd Pvt Ltd
 
plc_2012-13_titles
plc_2012-13_titlesplc_2012-13_titles
plc_2012-13_titles
Pantech ProEd Pvt Ltd
 
2. _embedded_project_titles_2012-13-final
2.  _embedded_project_titles_2012-13-final2.  _embedded_project_titles_2012-13-final
2. _embedded_project_titles_2012-13-finalPantech ProEd Pvt Ltd
 
7. _power_electronics_2012-13_titles
7.  _power_electronics_2012-13_titles7.  _power_electronics_2012-13_titles
7. _power_electronics_2012-13_titlesPantech ProEd Pvt Ltd
 
Hexaware mock test1
Hexaware mock test1Hexaware mock test1
Hexaware mock test1
Pantech ProEd Pvt Ltd
 
Cts aptitude questio papers
Cts aptitude questio papersCts aptitude questio papers
Cts aptitude questio papers
Pantech ProEd Pvt Ltd
 
Syntel model placement paper 2
Syntel model placement paper 2Syntel model placement paper 2
Syntel model placement paper 2
Pantech ProEd Pvt Ltd
 

More from Pantech ProEd Pvt Ltd (20)

2013 14-ns2-project-titles-me-mtech
2013 14-ns2-project-titles-me-mtech2013 14-ns2-project-titles-me-mtech
2013 14-ns2-project-titles-me-mtech
 
2013 14-embedded-project-titles-pantech-me-m tech-project-titles
2013 14-embedded-project-titles-pantech-me-m tech-project-titles2013 14-embedded-project-titles-pantech-me-m tech-project-titles
2013 14-embedded-project-titles-pantech-me-m tech-project-titles
 
2013 14-dotnet-titles-pantech-proed-for-me-mtech
2013 14-dotnet-titles-pantech-proed-for-me-mtech2013 14-dotnet-titles-pantech-proed-for-me-mtech
2013 14-dotnet-titles-pantech-proed-for-me-mtech
 
2013 14-java-project-titles-me-tech-pantech
2013 14-java-project-titles-me-tech-pantech2013 14-java-project-titles-me-tech-pantech
2013 14-java-project-titles-me-tech-pantech
 
2013 14-power-electronics-project-titles-me-mtech
2013 14-power-electronics-project-titles-me-mtech2013 14-power-electronics-project-titles-me-mtech
2013 14-power-electronics-project-titles-me-mtech
 
2013 14-power-systems-project-titles-for-me-m-tech-pantech
2013 14-power-systems-project-titles-for-me-m-tech-pantech2013 14-power-systems-project-titles-for-me-m-tech-pantech
2013 14-power-systems-project-titles-for-me-m-tech-pantech
 
2013 14-vlsi-project-titles-for-me-mtech-pantech-pro ed
2013 14-vlsi-project-titles-for-me-mtech-pantech-pro ed2013 14-vlsi-project-titles-for-me-mtech-pantech-pro ed
2013 14-vlsi-project-titles-for-me-mtech-pantech-pro ed
 
plc_2012-13_titles
plc_2012-13_titlesplc_2012-13_titles
plc_2012-13_titles
 
8. _power_system_2012-13
8.  _power_system_2012-138.  _power_system_2012-13
8. _power_system_2012-13
 
6. _dotnet_2012-13.doc
6.  _dotnet_2012-13.doc6.  _dotnet_2012-13.doc
6. _dotnet_2012-13.doc
 
5. _java_2012-13_titles
5.  _java_2012-13_titles5.  _java_2012-13_titles
5. _java_2012-13_titles
 
4. _vlsi_2012-13_titles
4.  _vlsi_2012-13_titles4.  _vlsi_2012-13_titles
4. _vlsi_2012-13_titles
 
3. _dsp_2012-13_titles
3.  _dsp_2012-13_titles3.  _dsp_2012-13_titles
3. _dsp_2012-13_titles
 
2. _embedded_project_titles_2012-13-final
2.  _embedded_project_titles_2012-13-final2.  _embedded_project_titles_2012-13-final
2. _embedded_project_titles_2012-13-final
 
1. _ns2_2012-13_titles.doc
1.  _ns2_2012-13_titles.doc1.  _ns2_2012-13_titles.doc
1. _ns2_2012-13_titles.doc
 
7. _power_electronics_2012-13_titles
7.  _power_electronics_2012-13_titles7.  _power_electronics_2012-13_titles
7. _power_electronics_2012-13_titles
 
Mahindra satyam-2010-banglore.docx
Mahindra satyam-2010-banglore.docxMahindra satyam-2010-banglore.docx
Mahindra satyam-2010-banglore.docx
 
Hexaware mock test1
Hexaware mock test1Hexaware mock test1
Hexaware mock test1
 
Cts aptitude questio papers
Cts aptitude questio papersCts aptitude questio papers
Cts aptitude questio papers
 
Syntel model placement paper 2
Syntel model placement paper 2Syntel model placement paper 2
Syntel model placement paper 2
 

Recently uploaded

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 

Recently uploaded (20)

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 

Aptitute question papers in c

  • 1. C Programs TYPEDEF 1. What can be said of the following program ? main() { enum Months {JAN =1,FEB,MAR,APR}; Months X = JAN; if(X==1) { printf("Jan is the first month"); } } a) Does not print anything b) Prints : Jan is the first month c) Generates compilation error d) Results in runtime error Answer : b 2.main() { extern int i; i=20; printf("%d",i); } Answer: Linker Error : Undefined symbol '_i' Explanation: extern storage class in the following declaration, extern int i; specifies to the compiler that the memory for iis allocated in some other program and that address will be given to the current program at the time of linking. But linker finds that no other variable of name iis available in any other program with memory space allocated for it. Hence a linker error has occurred . 3. enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); } Answer: 0..1..2 Explanation: enum assigns numbers starting from 0, if not explicitly defined. PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 2. 4. Given the following statement enum day = { jan = 1 ,feb=4, april, may} What is the value of may? (a) 4 (b) 5 (c) 6 (d) 11 (e) None of the above Answer c) 6 SWITCH: 5. What is the output of the following program? main() { int l=6; switch(l) { default : l+=2; case 4: l=4; case 5: l++; break; } printf("%d",l); } a)8 b)6 c)5 d)4 e)none Answer : c) 5 6. main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } } Answer : three Explanation : The default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match. 7. #include<stdio.h> main() { int i=1,j=2; switch(i) { PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 3. case 1: printf("GOOD"); break; case j: printf("BAD"); break; } } Answer: Compi ler Error: Constant expression required in function main. Explanation: The case statement can have only constant expressions (this implies that we cannot use variable names directly so an error). Note: Enumerated types can be used in case statements. 8. main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } } Answer: Compi ler Error: switch expression not integral Explanation: Switch statements can be applied only to integral types. 10. Output of the following program is main() { int i=0; for(i=0;i<20;i++) { switch(i) case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break; } printf("%d,",i); } } a) 0,5,9,13,17 b) 5,9,13,17 c) 12,17,22 d) 16,21 e) Syntax error Ans. (d) PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 4. 11. main() { int i; for(i=0;i<3;i++) switch(i) { case 1: printf("%d",i); case 2 : printf("%d",i); default: printf("%d"i); } } Answer: 011122 FUNCTIONS: 12. What is the output of the following program? main() { int x=20; int y=10; swap(x,y); printf("%d %d",y,x+2); } swap(int x,int y) { int temp; temp =x; x=y; y=temp; } a) 10,20 b) 20,12 c) 22,10 d)10,22 e)none Answer : d)10,22 13. Which of the following about the following two declaration is true i ) int *F() ii) int (*F)() Choice : a) Both are identical b) The first is a correct declaration and the second is wrong c) The first declaraion is a function returning a pointer to an integer and the second is a pointer to function returning int d) Both are different ways of declarin pointer to a function Answer : c). 14. main() { printf("%p",main); } PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 5. Answer: Some address will be printed. Explanation: Function names are just addresses (just like array names are addresses). main() is also a function. So the address of function main will be printed. %p in printf specifies that the argument is an address. They are printed as hexadecimal numbers. 15. main() { clrscr(); } clrscr(); Answer: No output/error Explanation: The first clrscr() occurs inside a function. So it becomes a function call. In the second clrscr(); is a function declaration (because it is not inside any function). 16. main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here } Answer: 1 Explanation: Scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should have been scanned successfully. So number of items read is 1. 17. main() { show(); } void show() { printf("I'm the greatest"); } Answer: Compi er error: Type mismatch in redeclaration of show. Explanation: When the compiler sees the function show it doesn't know anything about it. So the default return type (ie, int) is assumed. But when compiler sees the actual definition of show mismatch occurs since it is declared as void. Hence the error. The solutions are as follows: 1. declare void show() in main() . 2. define show() before main(). 3. declare extern void show() before the use of show(). 18. main() { main(); } PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 6. Answer: Runtime error : Stack overflow. Explanation: main function calls itself again and again. Each time the function is called its return address is stored in the call stack. Since there is no condition to terminate the function call, the call stack overflows at runtime. So it terminates the program and results in an error. 19. What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ } Answer: i. ANSI C notati on ii. Kernighan & Ritche notation 20. What is printed when this program is executed main() { printf ("%dn",f(7)); } f(X) { if ( x<= 4) return x; return f(--x); } a) 4 b)5 c) 6 d) 7 Answer : a) 21. what is printed when the following program is compiled and executed? int func (int x) { if (x<=0) return(1); return func(x -1) +x; } main() PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 7. { printf("%dn",func(5)); } a) 12 b) 16 c) 15 d) 11 Answer : .b) 16. 22. Find the out put: main() { int a==4 sqrt(a); printf("%d",a); } 1).2.0 2). 2 3). 4.0 4). 4 Answer : 2 23. Find the output main() { int a[]={ 2,4,6,8,10 }; int i; change(a,5); for( i = 0; i <= 4; i++) printf("n %d",a[i]); } change( int *b, int n) { int i; for( i = 0; i < n; i++) *(b+i) = *(b+i) + 5; } Answer: 24. #include<studio.h> main() { func(1); } func(int i){ static char *str[] ={ "One","Two","Three","Four"}; printf("%sn",str[i++]); return; } Answer:- it will give warning because str is pointer to the char but it is initialized with more values if it is not considered then the answer is Two */ PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 8. 25. Find the out put: #include<stdio.h> /* This problem was asked in PCS Bombay in a walk-in-interview Write a recursive function that calculates n * (n-1) * (n-2) * ....... 2 * 1 */ main() { int factorial(int n); int i,ans; printf("n Enter a Number:"); scanf("%d",&i); ans = factorial(i); printf("nFactorial by recursion = %dn", ans); } int factorial(int n) { if (n <= 1) return (1); else return ( n * factorial(n-1)); } Answer : 26.Find the output #include <stdio.h> main() { int j,ans; j = 4; ans = count(4); printf("%dn",ans); } int count(int i) { if ( i < 0) return(i); else return( count(i-2) + count(i-1)); } Answer : /* It is showing -18 as an answer */ 27. Find the out put int x; main() { int x=0; { PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 9. int x=10; x++; change_value(x); x++; Modify_value(); printf("First output : %dn",x); } x++; change_value(x); printf("Second Output : %dn",x); Modify_value(); printf("Third Output : %dn",x); } Modify_val ue() { return (x+=10); } change_value() { return(x+=1); } Answer : 28. Consider the following program main() { int i=20,*j=&i; f1(j); *j+=10; f2(j); printf("%d and %d",i,*j); } f1(k) int *k; { *k +=15; } f2(x) int *x; { int m=*x,*n=&m; *n += 10; } The values printed by the program will be a) 20 and 55 b) 20 and 45 c) 45 and 45 PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 10. d) 45 and 55 e) 35 and 35 Answer : c 29. what is printed when the following program is compiled and executed? int func (int x) { if (x<=0) return(1); return func(x -1) +x; } main() { printf("%dn",func(5)); } a) 12 b) 16 c) 15 d) 11 Answer : b STRUCTURE AND UNION: 30. What is the size of the following union. Assume that the size of int =2, size of float =4 and size of char =1. Union Tag { int a; float b; char c; }; a)2 b)4c)1 d) 7 Answer : b DATA TYPES 31. What is th output of the fol lowing program? int x= 0x65; main() { char x; printf("%dn",x) } a) compilation error b) 'A' c) 65 d) unidentified PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com
  • 11. Answer : c PANTECH SOLUTIONS PVT LTD , 151 / 34 , Sri Renga Building , T Nagar , Chennai – 17 Tel : 044 42606450 / 96000 66689 Branches @ Madurai , Coimbatore, Cochin , Pune, Hyderabad and Tirunelveli Pantech Potency : Final Year IEEE / Non IEEE Projects and Professional Courses. www.pantechprojects.com