SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Data structure week 1
Data structure week 1Data structure week 1
Data structure week 1karmuhtam
 
Simulado java se 7 programmer
Simulado java se 7 programmerSimulado java se 7 programmer
Simulado java se 7 programmerMiguel Vilaca
 
C programming-apurbo datta
C programming-apurbo dattaC programming-apurbo datta
C programming-apurbo dattaApurbo Datta
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignmentSaket Pathak
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manualAnil Bishnoi
 
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 #5Ismar 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 classHaresh Jaiswal
 
Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02CIMAP
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 solIIUM
 

Was ist angesagt? (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
 

Andere mochten auch

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 & EducationMelanie Tannenbaum
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty 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 Aldabaux singapore
 

Andere mochten auch (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?
 

Ähnlich wie Aptitute question papers in c

Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSESujata Regoti
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2docSrikanth
 
C language questions_answers_explanation
C language questions_answers_explanationC language questions_answers_explanation
C language questions_answers_explanationsrinath 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
 
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 branchSAKSHIGAWADE2
 
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 FILEDipta 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.docxrafbolet0
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfYashwanthCse
 
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 pdfchoconyeuquy
 
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.docxvrickens
 

Ähnlich wie 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
 

Mehr von 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-titlesPantech 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-mtechPantech 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-pantechPantech 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-mtechPantech 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
 
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
 

Mehr von 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
 

Kürzlich hochgeladen

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Kürzlich hochgeladen (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

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