‘C’ supports several different types of data.
The basic data types are listed below.
1. Fundamantal Data types:
int float char
2. Derived Data types:
Functions arrays pointers Structures unions
3. User defined Data types:
enum typedef
Enum:
enum identifier{value1,value2,value3,…,value n } ;
We can declare variables as follows.
Enum identifier v1 , v2 , v3 , … , vn ;
E.g. : enum day { mon , tue , wed , … , sun } ;
enum day week_st , week_end ;
week_st = mon ;
week_end = fri ;
Typedef:
Type definition allows users to define an identifier that would represent an existing data type.
The user defined data type identifier can later be used to declare variables.
typedef existing_datatype identifier
E.g. : typedef int unit ;
typedef float marks;
unit batch1 , batch2 ;
Marks m1 , m2 ;
1) There is a new data-type which can take as values natural numbers between (and including) 0 and 25. How many minimum bits are required to store this data-type. [Amcat]
Op 1: 4
Op 2: 5
Op 3: 1
Op 4: 3
Correct Op : 2
2) A data type is stored as an 6 bit signed integer. Which of the following cannot be represented by this data type? [Amcat]
Op 1: -12
Op 2: 0
Op 3: 32
Op 4: 18
Correct Op : 3
3) A language has 28 different letters in total. Each word in the language is composed of maximum 7 letters. You want to create a data-type to store a word of this language. You decide to store the word as an array of letters. How many bits will you assign to the data-type to be able to store all kinds of words of the language. [Amcat]
Op 1: 7
Op 2: 35
Op 3: 28
Op 4: 196
Correct Op : 2
4) A 10-bit unsigned integer has the following range: [Amcat]
Op 1: 0 to 1000
Op 2: 0 to 1024
Op 3: 1 to 1025
Op 4: 0 to 1023
Correct Op : 4
5) Rajni wants to create a data-type for the number of books in her book case. Her shelf can accommodate a maximum of 75 books. She allocates 7 bits to the data-type. Later another shelf is added to her book-case. She realizes that she can still use the same data-type for storing the number of books in her book-case. What is the maximum possible capacity of her new added shelf? [Amcat]
Op 1: 52
Op 2: 127
Op 3: 53
Op 4: 75
Correct Op : 1
6) A new language has 15 possible letters, 8 different kinds of punctuation marks and a blank character. Rahul wants to create two data types, first one which could store the letters of the language and a second one which could store any character in the language. The number of bits required to store these two data-types will respectively be:[Amcat]
Op 1: 3 and 4
Op 2: 4 and 3
Op 3: 4 and 5
Op 4: 3 and 5
Correct Op : 3
7)Parul takes as input two numbers: a and b. a and b can take integer values between 0 and 255. She stores a, b and c as 1-byte data type. She writes the following code statement to process a and b and put the result in c. [Amcat]
c = a + 2*b
To her surprise her program gives the right output with some input values of a and b, while gives an erroneous answer for others. For which of the following inputs will it give a wrong answer?
Op 1: a = 10 b = 200
Op 2: a = 200 b = 10
Op 3: a = 50 b = 100
Op 4: a = 100 b = 50
Correct Op : 1
8)Prashant takes as input 2 integer numbers, a and b, whose value can be between 0 and 127. He stores them as 7 bit numbers. He writes the following code to process these numbers to produce a third number c.
c = a - b
In how many minimum bits should Prashant store c? [Amcat]
Op 1: 6 bits
Op 2: 7 bits
Op 3: 8 bits
Op 4: 9 bits
Correct Op : 3
9) Ankita takes as input 2 integer numbers, a and b, whose value can be between 0 and 31. He stores them as 5 bit numbers. He writes the following code to process these numbers to produce a third number c.
c = 2*(a - b)
In how many minimum bits should Ankita store c? [Amcat]
Op 1: 6 bits
Op 2: 7 bits
Op 3: 8 bits
Op 4: 9 bits
Correct Op : 2
10) A character in new programming language is stored in 2 bytes. A string is represented as an array of characters. A word is stored as a string. Each byte in the memory has an address. The word "Mahatma Gandhi" is stored in the memory with starting address 456. The letter 'd' will be at which memory address? [Amcat]
Op 1: 468
Op 2: 480
Op 3: 478
Op 4: 467
Correct Op : 3
11) Stuti is making a questionnaire of True-false questions. She wants to define a data-type which stores the response of the candidate for the question. What is the most-suited data type for this purpose? [Amcat]
Op 1: integer
Op 2: boolean
Op 3: float
Op 4: character
Correct Op : 2
12) By default a real number is treated as a
Op 1. float
Op 2. double
Op 3. long double
Op 4. far double
Correct: Op 2
13) Which of the following is not a valid variable name declaration?
Op 1. int _a3;
Op 2. int a_3;
Op 3. int 3_a;
Op 4. int _3a
Correct: Op 3
14) Which of the following special symbol allowed in a variable name?
Op 1. * (asterisk)
Op 2. | (pipeline)
Op 3. - (hyphen)
Op 4. _ (underscore)
Correct: Op :4
15) In the following program where is the variable a getting defined and where it is getting declared?
#include<stdio.h>
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;
Op 1. extern int a is declaration, int a = 20 is the definition
Op 2. int a = 20 is declaration, extern int a is the definition
Op 3. int a = 20 is definition, a is not defined
Op 4. a is declared, a is not defined
Correct: Op 1
16) Which of the following is a User-defined data type?
Op 1. typedef int Boolean;
Op 2. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
Op 3. struct {char name[10], int age};
Op 4. all of the mentioned
Correct: Op 4
17) What will be output of the following program?
#include<stdio.h>
int main()
{
int x;
x=10,20,30;
printf("%d",x);
return 0;
}
Op 1. 10
Op 2. 20
Op 3. 30
Op 4. 0
Op 5. Compilation error
Correct : Op 1
18) What will be output of the following c program?
#include<stdio.h>
int main()
{
int _=5;
int __=10;
int ___; ___=_+__;
printf("%i",___);
return 0;
}
Op1. 5
Op2. 10
Op3. 15
Op4. Compilation error
Op5. None of these
Correct: Op 3
Explanation: Variable name can have only underscore.
19) What will be output of the following program?
#include<stdio.h>
int main()
{
float a=0.7;
if(a<0.7)
{
printf("C");
}
Else
{
printf("C++");
}
return 0; }
Op1. C
Op2. C++
Op3. NULL
Op4. Compilation error
Op5.None of these
Correct: Op1