NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Quiz-1

1. What type of variable is accessible from any function in a C program?
a) Local variable
b) Temporary variable
c) Global variable
d) Static variable

2. What is output of following code?
#include <stdio.h>
int main() {
    int x = 5;
    int y = x << 2;
    printf(“%d”, y);
    return 0;
A)5
B)10
C)15
D)20

3. In C, which operator is used for logical AND?
A)&&
B)&
C)and
D)AND

4. What is the purpose of the `const` keyword in C?
A)It makes a variable constant and unchangeable.
B)It specifies a variable as an integer.
C)It is used to declare a constant value.
D)It creates a constant function.

5. What is the scope of a global variable in C?
A)It is limited to the function in which it is declared.
B)It is limited to the block in which it is declared.
C)It is limited to the file in which it is declared.
D)It is limited to the program in which it is declared.

6. Which operator finds the remainder in C?
A.* 
B. % 
C. / 
D. &

7. Which of the following is an important requirement of c programming?
1.Function
2.Input variables
3.Output variables
4.All of the above

8. What is output of following code?
#include <stdio.h>
void main()
{
int x,y;
x = (1, 2, 3);
y = 1,2,3;
printf("x = %d ", x);
printf("y = %d ", y);
}
A)x = 3 y = 1
B)x = 1 y = 3
C)x = 1 y = 1
D)x = 3 y = 3

9. Which of the following is a valid comment in C?
a) // This is a comment
b) # This is a comment
c) -- This is a comment
d) %% This is a comment

10. What is the result of 10 / 3 in C (integer division)?
A.Error 
B. 3 
C. 3.33 
D. 4

11. #include<stdio.h>
void main()
{
int a=5,b=10,c=20;
printf("%d %d %d %d",a,b,c);
}
A)Error
B)5 10 20 30
C)5 10 20 0
D)5 10 20 void

12. #include<stdio.h>
void main()
{
int a=5,b=10,c=20;
printf("%d %d ",a,b,c);
}
A)Error
B)5 10 20
C)5 10 NULL
D)5 10

13. #include<stdio.h>
void main()
{
printf("%d",printf("Hello"));
}
A)Hello5
B)Hello
C)Error
D)H

14. #include<stdio.h>
int main()
{
int x;
printf("%d",scanf("%d",&x));
/* Suppose that input value given
for above scanf is 20 */
return 1;
}
A)1
B)0
C)Will ask user to enter value
D)Error

15. What is the purpose of comments in code?
a) To declare variables
b) To improve readability
c) To execute logic
d) To store data


16. What data type would you use to store a character in C?
A int
B float
C char
D double

17. What is the purpose of the printf function in C?
A To read input
B To print output
C To perform calculations
D To control program flow

18. What is the main function of a compiler in programming?
A To write code
B To interpret code
C To convert code into machine language
D To debug code

19. #include <stdio.h>
int main()
{
int ThisIsVariableName = 12;
int ThisIsVariablename = 14;
printf("%d", ThisIsVariablename);
return 0;
}
a) The program will print 12
b) The program will print 14
c) The program will have a runtime error
d) The program will cause a compile-time error due to redeclaration

20.#include <stdio.h>
int main()
{
int n = 1;
printf("%d, %d", 3*n, n++);
}
a)6 1
b)3 1
c)3 2
d)Error

21.#include <stdio.h>
int main()
{
int d, a = 1, b = 2;
d = a++ + ++b;
printf("%d %d %d", d, a, b);
}
a)4 2 3
b)3 1 2
c)4 2 2
d)Error

22.What will be the final value of x in the following C code?
#include <stdio.h>
void main()
{
int x = 5 * 9 / 3 + 9;
}
a) 3.75
b) Depends on compiler
c) 24
d) 3

23. #include <stdio.h>
void main()
{
int main = 3;
printf("%d", main);
}
a)Compile Error
b)3
c)Runtime Error
d)None of the above
e)
24.scanf() is a predefined function in______header file.
a) stdlib. h
b) ctype. h
c) stdio. h
d) stdarg. H

25. Which of the following best describes a local variable?
a) Declared outside all functions
b) Accessible throughout the program
c) Declared inside a function
d) Used for global configuration


26.The C-preprocessors are specified with _________ symbol.
a) #
b) $
c) ” ”
d) &

27.Which keyword is used to prevent any changes in the variable within a C program?
a) immutable
b) mutable
c) const
d) volatile

28.Which is valid C expression?
a) int my_num = 100,000;
b) int my_num = 100000;
c) int my num = 1000;
d) int $my_num = 10000;

29.What is the role of a semicolon in C-like languages?
a) To start a comment
b) To terminate a statement
c) To declare a variable
d) To separate functions

30. All keywords in C are in ____________
a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None of the mentioned

31. What does whitespace refer to in programming?
a) Empty variables
b) Spaces, tabs, and newlines
c) Unused memory
d) Blank comments

32.Which of the following is not a valid C variable name?
a) int number;
b) float rate;
c) int variable_count;
d) int $main;

33. An algorithm must be:
A.Infinite
B.Ambiguous 
C.Step-by-step 
D. Random

34.Who is the father of C language?
a) Steve Jobs
b) James Gosling
c) Dennis Ritchie
d) Rasmus Lerdorf

35. What is a token in programming?
a) A comment
b) A whitespace
c) A meaningful element like keyword or operator
d) A semicolon only

36. What is the goal of debugging?
A.To compile code 
B. To optimize performance 
C. To fix errors 
D. To write documentation

37. Which is NOT an arithmetic operator?
A.+ 
B. && 
C. * 
D. %

38.When is the 'else' block executed in an if-else statement?
a)When the condition is true
b)When the condition is false
c)Always
d)Never

39.What will happen if a 'break' statement is omitted in a switch case?
a)The program will throw an error
b)Only the first case will execute
c)All subsequent cases will execute until a break is encountered
d)It will stop the switch completely

40.Which of the following cannot be checked in a switch-case statement?
a)Character
b)Integer
c)Float
d)Enum

41.#include<stdio.h>
void main()
{
int a=3;

switch(a)
{

}

printf("MySwitch");
}
a)MySwitch
b)No Output
c)Compiler Error
d)None of the above

42.#include<stdio.h>
void main()
{
int n = 0;
if (n)
printf("True");
else
printf("False");
}
a)True
b)False
c)0
d)Error

43.What is output of:
int score = 85;
if(score >= 90)
printf("A");
else if(score >= 80)
printf("B");
else if(score >= 70)
printf("C");
else printf("F");

a)A
b)B
c)C
d)F

44.Output of the following code:
int a = 7, b = 5;
if(a < b)
printf("a is smaller");
else if(a == b)
printf("Equal");
else
printf("a is greater");
a)a is smaller
b)Equal
c)a is greater
d)Error
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.