0% found this document useful (0 votes)
7 views

c Questions for 24 Aug

Uploaded by

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

c Questions for 24 Aug

Uploaded by

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

1. What will be the output of the following code snippet?

#include <stdio.h>
void solve() {
int a[] = {1, 2, 3, 4, 5};
int sum = 0;
for(int i = 0; i < 5; i++) {
if(i % 2 == 0) {
sum += *(a + i);
}
else {
sum -= *(a + i);
}
}
printf("%d", sum);
}
int main() {
solve();
return 0;
}

a-2
b.15
c.syntax error
d.3
Ans d

2. What will be the output of the following code snippet?

#include <stdio.h>
void solve() {
int x = 2;
printf("%d", (x << 1) + (x >> 1));
}
int main() {
solve();
return 0;
}
a-2
b.15
c.syntax error
d.3
Ans a

3. What will be the output of the following code snippet?


main()
{
char x [10], *ptr = x;
scanf ("%s", x);
change(&x[4]);
}
change(char a[])
{
puts(a);
}
If abcdefg is the input, the output will be-
a) abcd
b) abc
c) efg
d) Garbage
Answer: (c) efg

4. What will be the output of the following code snippet?


main()
{
int a = 1, b = 2, c = 3:
printf("%d", a + = (a + = 3, 5, a))
}
0. 6
a. 9
b. 12
c. 8
Answer: (d) 8

5. What does this declaration mean?


int x : 4;
a) X is a four-digit integer.
b) X cannot be greater than a four-digit integer.
c) X is a four-bit integer.
d) None of the these
Answer: (c) X is a four-bit integer.

6. Which of the following statement is correct about the ftell() function?

a. It returns the current position.


b. It sets the file pointer to the given position.
c. It sets the file pointer at the beginning of the file.
d. It reads a character from the file.

Answer: (a) It returns the current position.

7. What will be the output of this program?


#include <stdio.h>
int main() {
int i = 5;
printf("%d", i = ++i == 6);
return 0;
}

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

Answer: (d)
8. What type of data type does the atoi() function return?
a) String
b) char
c) Integer
d) Float

Answer: (c)

9. The enum keyword is used to assign names to the ________ constants.


a) Integer
b) String
c) Character
d) All of the these

Answer: (a)

10. What will be the output of this program?

main ()
{
if(5 < '5')
printf("5")
else
printf("Not equal to 5.")
}
a) ENQ
b) 5
c) I
d) Not equal to 5
Answer: (b)

You might also like