[go: up one dir, main page]

0% found this document useful (0 votes)
176 views9 pages

C Language Quiz

The document discusses various C programming concepts and code snippets: 1) An example code with post-increment and pre-increment operators that has an unpredictable output. 2) A code snippet that prints the character pointed to by a pointer variable. 3) A code with a runtime error due to infinite recursion from calling main() recursively. The document then provides explanations and outputs for various C programming questions.

Uploaded by

Deepankar Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views9 pages

C Language Quiz

The document discusses various C programming concepts and code snippets: 1) An example code with post-increment and pre-increment operators that has an unpredictable output. 2) A code snippet that prints the character pointed to by a pointer variable. 3) A code with a runtime error due to infinite recursion from calling main() recursively. The document then provides explanations and outputs for various C programming questions.

Uploaded by

Deepankar Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1)  void main()

{
            int i=5;
            printf("%d",i++ + ++i);
}

Output Cannot be predicted  exactly.

2) main()
{
 char *p;
 p="Hello";
 printf("%c\n",*&*p);
}
H

3) main()
            {
            main();
            }

Answer:
 Runtime error : Stack overflow.

What are the files which are automatically opened when a C file is
executed?
Answer:
stdin, stdout, stderr (standard input, standard output, standard error).
Q4) What will be the output of following program ?
1 #include < stdio.h >
2 int main()
3{
4 int tally=0;
5 for(;;)
6 {
7 if(tally==10)
8 break;
9 printf("%d ",++tally);
10 }
11 return 0;
12 }
1. 0 1 2 3 4 5 6 7 8 9 10
2. 0 1 2 3 ... infinite times
3. 1 2 3 4 5 6 7 8 9 10
4. 123456789

Q5) How many times this loop will execute?

int main()
{
inti;
for(i=0;i<10;i++)
{
printf(“%d\n",i++);
i=++i;
}
return 0;
}
1. 10
2. 5
3. 4
4. None of these
6) How many times this loop will execute?

const MAX=10;
int main()
{
inti=1;
for(;i<MAX;i=i/i)
{
printf("%d\n",i);
}
return 0;
}
1. 10
2. 5
3. 4
4. Infinite

7) #include<stdio.h>
int main()
{
printf("%d",printf("College"));
return 0;
}

8) #include<stdio.h>
int main()
{
void num=10;
printf("%v", num);
return 0;
}
9) #include<stdio.h>
int main()
{
printf("%d\t",sizeof(2.5));
printf("%d\t",sizeof(2));
printf("%d",sizeof('A'));
return 0;
}

10) int main()


{
int n=0;
while(n<printf("MENU\n"))
{
n++;
}
return 0;
}
1. MENU

MENU

MENU

MENU

MENU

MENU
2. MENU

MENU

MENU

MENU

MENU
3. compile_time error
4. None of these

11)  main()
{
              int i=5,j=6,z;
              printf("%d",i+++j);
             }

11

12) #include <stdio.h>

void main()
{
double k = 0;
for (k = 0.0; k < 3.0; k++);
printf("%lf", k);
}

3.000000

Q13) #include<stdio.h>
int main(){
while(printf("%d", 5) < 4)
printf("Loop ");
return 0;
}
A. Prints Nothing
B. 5Loop 5Loop 5Loop 5Loop 5Loop
C. 5Loop
D. Infinite iterations or Infinite Loop
Q14)
#include<stdio.h>

int main()
{
int arr[i]={10};
printf(“%d\n”,0[arr]);
return 0;
}
A.1
B.10
C.0
D.6

Q15)Point out the error in the program



f(int a, int b)
{
int a;
a=20;
return a;
}

A.Missing parenthesis in the return statement


B.The function should be defined as int f(int a, int b)
C. Redeclaration of a
D.None of the above

Q16)The agency that sits between the user and the UNIX system is called
the
A.logic

B.profile

C.shell

D.erxc

Q17Which command is used to display a file contents in octal form?

A.cd
B.od
C.of
D.oct

Q18)The cp command uses:



A.standard input file

B.standard output file

C.both input and output file

D.neither standard input nor standard output file

Q19)The field separator in cut command is specified with


A.-a option

B.-d option

C. -r option
D.-x option

Q20)Which option will be used with touch command to change the access
time?
A.-a

B.-b

C.-t

D.-h

Q21)The default shell in UNIX OS is



[A] ksh

[B] sh

[C] csh

[D] bsh
Q22)The user’s general prompt sign of Borne shell is

A.%

B. $

C. >

D. #

Q23)A file is removed from the disk if

[A] owner of the file deletes it

[B] count in the open file description table becomes zero

[C] reference count in its inode becomes zero

[D] none of the above

Q24)Which command is used with vi editor to move the cursor one row
up?

A. i

B.j

C.h

D.k
Q25)Files that store data in same format as used in program are called

a.Binary files

b.Source file

c.Text file

d.Core

You might also like