Which of the following is not a valid variable name declaration?
a) int int;
b) int 3a;
c) int goto;
d) None of the mentioned
Answer:d
Variable names beginning with underscore is not encouraged. Why?
a) It is not standardized
b) To avoid conflicts since assemblers and loaders use such names
c) To avoid conflicts since library routines use such names
d) To avoid conflicts with environment variables of an operating system
Answer:c
All keywords in C are in
a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None
Answer:a
Click on to read more on Keywords
Which of the following is not a valid C variable name?
a) int number;
b) float rate;
c) int variable_count;
d) int $main;
Answer:d
Explanation: Since only underscore and no other special character is allowed in a variable name, it results in an error.
Which of the following is true for variable names in C?
a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length
Answer:c
Explanation: According to the syntax for C variable name, it cannot start with a digit.
Which is valid C expression?
a) int n = 100,000;
b) int n = 100000;
c) int my num = 1000;
d) int $n = 10000;
Answer:b
Explanation: space, comma and $ cannot be used in a variable name.
What is the output of this C code?
#include <stdio.h>
void main()
{
printf("Rajendra %d \n", x);
}
a) Rajendra x;
b) Rajendra followed by a Garbage value
c) Compile time error
d) Rajendra
Answer:c
Which of the following is not a valid variable name declaration?
a) float PI = 3.14;
b) double PI = 3.14;
c) int PI = 3.14;
d) #define PI 3.14
Answer:d
Explanation: since it is a Macro definition ( Macros )
What will happen if the below program is executed?
#include <stdio.h>
void main()
{
int main = 3;
printf("%d", main);
}
a) It will cause a compile-time error
b) It will cause a run-time error
c) It will run without any error and prints 3
d) It will experience infinite looping
Answer:c
Explanation: A C program can have same function name and same variable name.
10. What is the problem in following variable declaration?
float 7Apssdc-TCS-Training?;
a) The variable name begins with an integer
b) The special character ‘-‘
c) The special character ‘?’
d) All of the mentioned
Answer: d
What is the Output of this C code?
#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
Answer:b
A Variable is a....?
A. indicated datatype
B. stores the data
C. Collection of elements
D. None
Answer: Option B
The format identifier ‘%i’ is also used for _____ data type?
a) char
b) int
c) float
d) double
Answer:b
Explanation: Both %d and %i can be used as a format identifier for int data type.
Which of the following is a User-defined data type?
a) int;
b) strings
c) enum
d) all of the mentioned
Answer:c
What is short int in C programming?
a) Basic datatype of C
b) Qualifier
c) short is the qualifier and int is the basic datatype
d) All of the mentioned
Answer:c
Which is correct with respect to size of the datatypes?
a) char > int > float
b) int > char > float
c) char < int < double
d) double > char > int
Answer:c
Explanation:char has lesser bytes than int and int has lesser bytes than double in any system
What is the output of this C code?
#include <stdio.h>
int main()
{
float x = 'a';
printf("%f", x);
return 0;
}
a) a
b) run time error
c) a.0000000
d) 97.000000
Answer:d
Explanation:Since the ASCII value of a is 97, the same is assigned to the float variable and printed.
What is the output of this C code?
#include<stdio.h>
main()
{
int x = 5;
if(x=5)
{
if(x=5) printf("Ram");
}
printf("Sitha");
}
a) RamSitha
b) Ram
c) Sitha
d) Error
Answer:A
Explanation:RamSitha, both the if statement’s expression evaluates to be true.
What is the output of this C code?
#include <stdio.h>
int main()
{
int var = 010;
printf("%d", var);
}
a) 2
b) 8
c) 9
d) 10
Answer:b
Explanation:010 is octal representation of 8.
Can I use “int” data type to store the value 32768? Why?
No. “int” data type is capable of storing values from -32768 to 32767. To store 32768, you can use “long int” instead. You can also use “unsigned int”, assuming you don’t intend to store negative values.
Back
You may like the following posts:
Identifiers
C Tokens
Data type
Variables
Constants
a) int int;
b) int 3a;
c) int goto;
d) None of the mentioned
Answer:d
Variable names beginning with underscore is not encouraged. Why?
a) It is not standardized
b) To avoid conflicts since assemblers and loaders use such names
c) To avoid conflicts since library routines use such names
d) To avoid conflicts with environment variables of an operating system
Answer:c
All keywords in C are in
a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None
Answer:a
Click on to read more on Keywords
Which of the following is not a valid C variable name?
a) int number;
b) float rate;
c) int variable_count;
d) int $main;
Answer:d
Explanation: Since only underscore and no other special character is allowed in a variable name, it results in an error.
Which of the following is true for variable names in C?
a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length
Answer:c
Explanation: According to the syntax for C variable name, it cannot start with a digit.
Which is valid C expression?
a) int n = 100,000;
b) int n = 100000;
c) int my num = 1000;
d) int $n = 10000;
Answer:b
Explanation: space, comma and $ cannot be used in a variable name.
What is the output of this C code?
#include <stdio.h>
void main()
{
printf("Rajendra %d \n", x);
}
a) Rajendra x;
b) Rajendra followed by a Garbage value
c) Compile time error
d) Rajendra
Answer:c
Which of the following is not a valid variable name declaration?
a) float PI = 3.14;
b) double PI = 3.14;
c) int PI = 3.14;
d) #define PI 3.14
Answer:d
Explanation: since it is a Macro definition ( Macros )
What will happen if the below program is executed?
#include <stdio.h>
void main()
{
int main = 3;
printf("%d", main);
}
a) It will cause a compile-time error
b) It will cause a run-time error
c) It will run without any error and prints 3
d) It will experience infinite looping
Answer:c
Explanation: A C program can have same function name and same variable name.
10. What is the problem in following variable declaration?
float 7Apssdc-TCS-Training?;
a) The variable name begins with an integer
b) The special character ‘-‘
c) The special character ‘?’
d) All of the mentioned
Answer: d
What is the Output of this C code?
#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
Answer:b
A Variable is a....?
A. indicated datatype
B. stores the data
C. Collection of elements
D. None
Answer: Option B
The format identifier ‘%i’ is also used for _____ data type?
a) char
b) int
c) float
d) double
Answer:b
Explanation: Both %d and %i can be used as a format identifier for int data type.
Which of the following is a User-defined data type?
a) int;
b) strings
c) enum
d) all of the mentioned
Answer:c
What is short int in C programming?
a) Basic datatype of C
b) Qualifier
c) short is the qualifier and int is the basic datatype
d) All of the mentioned
Answer:c
Which is correct with respect to size of the datatypes?
a) char > int > float
b) int > char > float
c) char < int < double
d) double > char > int
Answer:c
Explanation:char has lesser bytes than int and int has lesser bytes than double in any system
What is the output of this C code?
#include <stdio.h>
int main()
{
float x = 'a';
printf("%f", x);
return 0;
}
a) a
b) run time error
c) a.0000000
d) 97.000000
Answer:d
Explanation:Since the ASCII value of a is 97, the same is assigned to the float variable and printed.
What is the output of this C code?
#include<stdio.h>
main()
{
int x = 5;
if(x=5)
{
if(x=5) printf("Ram");
}
printf("Sitha");
}
a) RamSitha
b) Ram
c) Sitha
d) Error
Answer:A
Explanation:RamSitha, both the if statement’s expression evaluates to be true.
What is the output of this C code?
#include <stdio.h>
int main()
{
int var = 010;
printf("%d", var);
}
a) 2
b) 8
c) 9
d) 10
Answer:b
Explanation:010 is octal representation of 8.
Can I use “int” data type to store the value 32768? Why?
No. “int” data type is capable of storing values from -32768 to 32767. To store 32768, you can use “long int” instead. You can also use “unsigned int”, assuming you don’t intend to store negative values.
Back
You may like the following posts:
Identifiers
C Tokens
Data type
Variables
Constants
No comments:
Post a Comment