Test on C Programming Fundamentals Part 2

1. What is the output of following code ?

#include<stdio.h>

void main()

{

int i=0;

do

{

printf(“inside the loop\n”);

}

while(i==1);

printf(“outside the loop\n”);

}

 
 
 
 

2. Will loop execute?

#include<stdio.h>

void main()

{

Int i;

for( ; i ; )

printf(“%d”,i);

printf(“outside the loop\n”);

}

 

 
 
 
 

3. Generate the output?

#include<stdio.h>

void main()

{

int i;

for(i=0;i<10;i++)

{

printf(“%d,”,i);

if(i==5)

continue;

if(i==7)

break;

}

}

 

 
 
 
 

4. What is the output

#include<stdio.h>

void main()

{

int a[10];

printf(“%d”,sizeof(a));

}

 

 
 
 
 

5. #include<stdio.h>

void main()

{

int i;

while(1)

{

printf(“there is no loop”);

}

}

 
 
 
 

6. Give an example exit controlled loop?

 
 
 
 

7. Give an example of entry control loop?

 
 
 
 

8. What will be the output?

main()

{

int i;

for(i=1;i<=5;printf(“\n%d”,i));

i++;

}

 
 
 
 

9. main()

{

Int p;

for(p=1;p<=10,–p;p=p+2)

printf(“hello\n”);

printf(“hai”);

}

 

 
 
 
 

10. Name the function that calls itself?

 
 
 
 

11. Single line swapping can be done using which of the below expression:

 
 
 
 

12. What are the methods to declare an array as an argument?

    1. return_type function(type array name[] )
    2. return_type function(type array name[SIZE])
    3. return_type function(type*array.name)
    4. return_type function(type array name
 
 
 
 

13. What is the right way to initialize

    1. int num[6]={1,2,4,6,7,8};
    2. int n{} = {2,3,4,5,3]
    3. int f={4,5,6,7,8}
    4. int a(2)={3,4,7,8}

 

 
 
 
 

14. Find the output of the following program :

#include<stdio.h>

void main()

{

int f = 2;

while(f!=31.0)

{

printf(“%f\n”,f);

f +=0.1;

}

}

 
 
 
 

15. Syntax for the 2D Array

 

 

 
 
 
 

16. #include<stdio.h>

int main()

{

int x,y;

for(x=5;x>=1;x – -)

{

for(y=1;y>=x;y++)

printf(“%d\n”,y);

}

}

 

 
 
 
 

17. What is the output

main()

{

char a[]=”a b c”;

char b[]= “a b c”;

int i;

printf(“%d\n”,strcmp(a,b));

}

 
 
 
 

18. Find the true statement given below:

#inlcude<stdio.h>

void main()

{

char c;

printf(“enter a character”);

scanf(“%c”,&c);

printf(“%c = %d”,c,c);

}

 
 
 
 

19. What will happen?

#include<stdio.h>

main()

{

char a[]=”kutty mama njan njetty mama”;

printf(“%d\n”,strlen(a));

}

 
 
 
 

20. What will happen

main()

{

char a[]=”racecar”;

printf(“%s\n”,strrev(a));

}

 
 
 
 

21. What will print on the output screen?

#include<stdio.h>

void main()

{

int i,j,a[2][2]={{1,2},{2,1}},x;

for(i=0;i<2;i++)

for(j=0:j<2:j++)

{

if(x=i==j)

printf(“%d\t”,a[i][j]);

}

}

 
 
 
 

22. What is the output ?

#include<stdio.h>

int f(int);

void main()

{

int b;

b=f(20);

printf(“%d”,b);

}

int f(int a);

{

return a = a>20 ? 10 : 20;

}

 
 
 
 

23. What will be the output ?

#include<stdio.h>

main()

{

int a[3][4]={{1,2,3},{4,5,6},{7,8,9}};

printf(“%d”),a[2][3];

}

 
 
 
 

24. what will be the output

main()

{

char str1[]=”abcd”;

char str2[]=”efgh”;

printf(“%d %d”,sizeof(str1),sizeof(str2));

}

 
 
 
 

25. what will be the output ?

main()

{

char s[20]=”hello world”;

s[5]=’\0’;

printf(“%d”,strlen(s));

}

 

 
 
 
 

26. what are the true statements?

main()

{

printf(“oh my god”);

main();

}

 
 
 
 

27. find the true statements for the below program

main()

{

char s[]=”’\0’super ball”

printf(“%s”,s);

}

 
 
 
 

28. how to declare character array in c ?

 
 
 
 

29. how to declare 2-D integer  array in c ?

 
 
 
 

30. How we can call a subroutine?

 
 
 
 

Question 1 of 30

Leave a Reply

Your email address will not be published. Required fields are marked *