Dca1102 C Language

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 57

Model Question Paper (C Programming Language)

PROGRAMME BACHELOR OF COMPUTER APPLICATIONS (BCA)


SEMESTER 1
COURSE CODE & NAME DCA1102 – PROGRAMING IN C

1.  Which of the following language is the predecessor to C Programming Language?


a) A
b) B
c) BCPL
d) C++
Ans: c

2. BPCL stands for

a) Basic Combined Programming Language

b) Basic Combo Programming Language

c) Basic Combo Program Language

d) None of these.

Ans: a

3. C programming language was developed by


a) Dennis Ritchie
b) Ken Thompson
c) Bill Gates
d) Peter Norton

Ans: a

4. C was developed in the year ___


a) 1970
b) 1972
c) 1976
d) 1980

Ans: b

5. C is a ___ language
a) High Level
b) Low Level

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


c) Middle Level
d) Machine Level

Ans: c

6. C language is available for which of the following Operating Systems?


a) DOS
b) Windows
c) Unix
d) All of these

Ans: d

7. Which of the following symbol is used to denote a pre-processor statement?


a) !
b) #
c) ~
d) ;

Ans: b

8. Which of the following are tokens in C?


a) Keywords
b) Variables
c) Constants
d) All of the above

Ans: d

9. Which symbol is used as a statement terminator in C?


a) !
b) #
c) ~
d) ;

Ans: d

 10. Which escape character can be used to begin a new line in C?


a) \a
b) \b
c) \m
d) \n

Ans: d

11. Which escape character can be used to horizontal tab in C?

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


a) \t
b) \b
c) \m
d) \n

Ans: a
12. Character constants should be enclosed between ___
a) Single quotes
b) Double quotes
c) Both a and b
d) None of these

Ans: a

13. String constants should be enclosed between ___


a) Single quotes
b) Double quotes
c) Both a and b
d) None of these

Ans: b

14.The __________ consists of an equal sign and an expression, which is usually a single
constant.
a) Initializer
b)Variable
c) Constant
d) None of these
Ans: a

15. A single declaration statement can contain variables of different types. (True/False)
Ans: False

16. In C, variable names are case sensitive. (True/False)


Ans: True

17. A variable name in C consists of letters, numbers and _________.

Ans: Underscore

 18. What will be the maximum size of a double variable?


a) 1 byte
b) 4 bytes
c) 8 bytes
d) 16 bytes
Ans: c

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


 19. What will be the maximum size of a float variable?
a) 1 byte
b) 2 bytes
c) 4 bytes
d) 8 bytes
Ans: c

20. The size of a String variable is


a) 1 byte
b) 8 bytes
c) 16 bytes
d) None of these
Ans: d

21.Using C language programmers can write their own library functions. (True/False)
Ans: True

22. C is a ________ level programming language.


Ans: Middle

23. The documentation section contains a set of __________ lines.


Ans: Comment

24. Every C program must have one main() function. (True/False)

Ans:True

25.The information that needs to be passed in when a function is called is______.


Ans: Argument

26. The main() function doesn’t return any value. (True/False)

Ans: False

27. The operator && is an example for ___ operator.


a) Assignment
b) Increment
c) Logical
d) Rational
Ans: c

28. The operator & is used for


a) Bitwise AND
b) Bitwise OR
c) Logical AND
d) Logical OR
Ans: a

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


29. The equality operator is represented by
a) :=
b) .EQ.
c) =
d) ==
Ans: d

30. The bitwise AND operator is used for


a) Masking
b) Comparison
c) Division
d) Shifting bits
Ans: a

31. An octal integer constant consists of any combination of digits from the set _________
through _________.
Ans: (0,7)

32. A sequence of digits preceded by 0x or 0X is considered as _____________ integer.


Ans: Hexa Decimal

33. A string constant is a sequence of __________ enclosed within double quotes.


Ans: Character

34. The size of the Integers in C language is same in all the machines. (True/False)
Ans: True

35. A ________ is a place where we can store values.


Ans: Variable

36. Size of int is _________ bits.


a) 8
b) 16
c) 32
d) 64
Ans: b

37. Which of the following tells the compiler the name and type of a variable you'll be using in
your program?
(a) declaration
(b) variables
(c) integers
(d) assignments

Ans: a

38. Which operator has the lowest priority?


a) ++
b) %

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


c) +
d) ||
Ans: d

39. Which operator has the highest priority?


a) ++
b) %
c) +
d) ||
Ans: a

40. Which of the following is a ternary operator?


a) ?:
b) *
c) sizeof
d) ^
Ans: a

41. What will be the output of the expression 11 ^ 5?


a) 5
b) 6
c) 11
d) None of these
Ans: d

42. The type cast operator is


a) (type)
b) cast()
c) (;;)
d) // ” ”
Ans: a

43. Explicit type conversion is known as


a) Casting
b) Conversion
c) Disjunction
d) Separation
Ans: a

44. The operator + in a+=4 means


a) a=a+4
b) a+4=a
c) a=4
d) a=4+4
Ans: a

45.What is the value of the arithmetic expression: 14 % 3 + 7 % 2


(a) 1

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


(b) 2
(c) 3
(d) 4
Ans: c
46. __________ operator can be only applied to integers.

a) Additional

b) Subtraction

c) Multiplication

d) Modulus

Ans: d

47. The logical operators ___________ and __________ are used when we want to test more
than one condition and make decisions.
Ans: &&, ||

48. State whether the following statement is correct or not. (Correct/Incorrect)


if(a<4<c)
b=c;

Ans: Incorrect

49. ____________________ are built-in functions that carry out various commonly used
operations or calculations
Ans: Library Function

50. Fill in the blanks as indicated by alphabets. The value of (a) floor(5.8),
(b) floor(-5.8), (c) ceil(5.8) and (d) ceil(-5.8) are ______ (a) _____,
____ (b) ______, ____ (c) _______ and _____ (d) ______ respectively.

Ans: (a) 5, (b) -6 ,(c) 6, (d) -5

51. Header files in C contain


a) Compiler commands
b) Library functions
c) Header information of C programs
d) Operators for files
Ans: b

52. Which pair of functions below are used for single character I/O.
a) Getchar() and putchar()
b) Scanf() and printf()
c) Input() and output()
d) None of these
Ans: a

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


53. The printf() function retunes which value when an error occurs?
a) Positive value
b) Zero
c) Negative value
d) None of these
Ans: c

54. Identify the wrong statement


a) putchar(65)
b) putchar(‘x’)
c) putchar(“x”)
d) putchar(‘\n’)
Ans: c

55. The output of the following program segment is ____________.


int a=97;
printf(“%c”, a);

a) C
b) A
c) a
d) none of these
Ans: c
56. gets() is a formatted input statement. (True/False)
Ans: False

57. The argument for a gets() and puts() functions are ____________variables.
a) char
b) String
c) Integer
d) Float
Ans: b

58. Using gets() function, you cannot include whitespace characters in the input string.
(True/False).
Ans: False

59. Which of the following is charecter oriented console I/O function?


a) getchar() and putchar()
b) gets() and puts()
c) scanf() and printf()
d) fgets() and fputs()
Ans: a

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


60. An Ampersand before the name of a variable denotes
a) Actual Value
b) Variable Name
c) Address
d) Data Type
Ans: c

61. Symbolic constants can be defined using


a) # define
b) const
c) symbols
d) None of these
Ans: b

62. Null character is represented by


a) \n
b) \0
c) \o
d) \e
Ans: b

63. When the accuracy provided by a float number is not sufficient, the type long float can be
used to define the number. (True/False)
Ans: False

64. A double data type uses __________ bits.


a) 8
b) 16
c) 32
d) 64
Ans: d

65. If the operands are of different data types, the ‘lower’ type is automatically converted to the
‘higher’ type before the operation proceeds. (True/False)
Ans: True

66. During the final assignment ________ to int causes dropping of the excess higher order
bits.
a) int
b) short int
c) long int
d) all of these
Ans: c

67. The value of the expression 22.0/10 is ________.

Ans: 2.2

68. Casting can be used to round-off a given value. (True/False)

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Ans: True

69. The value of A in the expression A=(int)11.35/(int)14.5 is ___________.


a) 0
b) 1
c) 2
d) 4
Ans: a

70. If the value of X is 35.2, then the value of A in the expression: A = (int)(X+0.5); is
____________.
a) 35
b) 35.7
c) 36
d) None of these
Ans: a

71. What is the format character to display the value of a char variable?
a) %d
b) %f
c) %c
d) %s
Ans: c

72. The output of the following C statement: printf(“%c”, 70); is ___________.


Ans: False

73. All keywords must be written in ____________.


a) Uppercase
b) Lowercase
c) both (a) and (b)
d) none of these
Ans: b

74. default is not a valid keyword in C. (True/False)

Ans: False

75. getchar() function is an output function.(True/False)


Ans: False

76. In order to stop reading the input character, you can use a value called___________.
Ans: EOF

77. The __________ string consists of control characters, whitespace characters, and non-
whitespace characters.
Ans: Control

78. The control string used to read a hexadecimal character is _______________.

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


a) %u
b) %i
c) %x
d) %h
Ans: c
79. scanf() functions needs address of the data item to be read as the argument. (True/False)
Ans: True

80. The output of the following statement is ________________.


printf("%d %o %x\n", 64, 10, 75);
Ans: 64, 12, 4B

81. To print an int argument in octal, you can use ____________ format string.
a) %u
b) %i
c) %x
d) %o
Ans: d

82. Which header file is essential for using strcmp() function?


a) string.h
b) strings.h
c) text.h
d) strcmp.h
Ans: a

83. malloc() function used in dynamic allocation is available in which header file?
a) stdio.h
b) stdlib.h
c) conio.h
d) mem.h
Ans: b

84. Which among the following is an unconditional control structure


a) do-while
b) if-else
c) goto
d) for
Ans: c

85. The function main() is optional in a C program. (True/False)


Ans: False

86. If the function is defined elsewhere (not in the same program where it is called), the function
prototype must be preceded by the keyword
Ans: Extern
_____________.

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


87. The arguments that appear in function definition are called_____________ arguments
whereas the arguments that appear when the function is called are the ___________
arguments.
Ans: Formal,actual

88. A stopping condition must be there in a recursive definition. (True/False)


Ans: True

89. Continue statement is used


a) to go to the next iteration in a loop
b) come out of a loop
c) exit and return to the main function
d) restarts iterations from the beginning of the loop
Ans: a

90. Which operator in C is called a ternary operator


a) if..then
b) ++
c) ?:
d) ()
Ans: c

91. Which of the following header file is required for strcpy() function?
a) string.h
b) strings.h
c) files.h
d) strcsspy()
Ans: a

92. In the C language ‘a’ represents


a) a digit
b) an integer
c) a character
d) a word
Ans: c

93. Closing a file simply involves calling fclose with the ___________ as its argument.
Ans: File pointer

94. If you forget to close a file, it will be closed automatically when the program exits.
(True/False)
Ans: True

95. The companion function to putchar is putc, and the file pointer argument comes first.
(True/False)
Ans: false

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


96. Besides the file pointers which we explicitly open by calling fopen, there are also
____________ predefined streams.
Ans: Three

97. getchar() is the same as getc(stdin).(True/False)


Ans: True
98. __________ clears the error and EOF indicators for the stream.
Ans: clearerr

99. The number of relational operators in the C language is


a) Four
b) Six
c) Three
d) One
Ans: b

100. The library function used to copy one string to another is_________________.
Ans: strcpy

101. The library function atoi can be used for any string. (True/False)
Ans: False

102. Dereference operator is also known as ___________________.


Ans: indirection operator.

103. Pointer is a variable containing address of another variable. (True/False)


Ans: True

104. State whether the following statements are correct: (Correct/Incorrect)


int a, b;
b=&a;
Ans: Incorrect

105. In C, a Union is
a) memory location
b) memory store
c) memory screen
d) None of these
Ans: b

106. When the main function is called, it is called with the arguments
a) argc
b) argv
c) None of these
d) both a & b
Ans: d

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


107. Pointers are of
a) integer data type
b) character data type
c) unsigned integer data types
d) None of these
Ans: d

108. Maximum number of elements in the array declaration int a[5][8] is


a) 28
b) 32
c) 35
d) 40
Ans: d

109. The return data type, function name and the list of formal parameters enclosed in brackets
are separated by _______________.
Ans: Comma

110. Function prototype is also called ________.


Ans: Function Declaration

111. The function prototypes are optional. (True/False)


Ans: False

112. The function prototypes of the library functions is in the corresponding__________ files.
Ans: Header

113. The function prototype for the function fun() called in main() below is________________ .
Ans: double fun(double, double);

114. ______________ is a process by which a function calls itself repeatedly, until some
specified condition is satisfied
Ans: Recursion

115. Array subscripts in C always start at


a) -1
b) 1
c) 0
d) Value provided by the user
Ans: c

116. A Structure
a) can be read as a single entity
b) cannot be read as a single entity
c) can be displayed as a single entity
d) has member variables that cannot be read individually
Ans: b

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


117. Which is the correct way to declare a pointer?
a) int_ptr;
b) int *ptr;
c) *int ptr;
d) None of these.
Ans: b

118. The process of translating a source program into machine language is a function
of:
a) Compiler
b) Translator
c) Assembler
d) None of these.
Ans: a

119. _________________ let you work with the individual bits of a variable; one common use is
to treat an integer as a set of single-bit flags.
a) Bitwise operator
b) Logical Operator
c) Relational operator
d) None of these
Ans: a

120. Fill in the blanks as indicated by alphabets. If flag1=5, flag2=8, then


(a) flag1&flag2, (b) flag1|flag2, (c) ~flag1 and (d) flag1^flag2 is
computed to be ______ (a) _____, ____ (b) _______, ____ (c)_______
and _____ (d) ______ respectively.

Ans: (a) 0, (b) 13, (c) 10, (d) 13

121. Increment and Decrement operators are binary operators. (True/False)


Ans: False

122. The prefix form to increment i is _______ whereas the postfix form to increments i is
________.
Ans: ++i, i++

123. What is used as a terminator in C?


a) ?
b) ;
c) :
d) _
Ans: b

124. What is the answer of: 7%3


a) 2.5
b) 1

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


c) 2
d) 3
Ans: b

125. The _______ chars have values from -128 to 127.


a) signed
b) unsigned
c) long
d) none
Ans: a

126. What is the control character for “a single character”.


a) %c
b) %d
c) %i
d) %p
Ans: a

127. The goto requires a _________ in order to identify the place where the
branch is to be made.
Ans: Label

128. goto is an unconditional branching statement. (True/False)


Ans: True

129. The series of statements enclosed by braces after the expression in simple if statement is
itself a simple expression statement. (True/False)
Ans: False

130. In the cascaded if/else/if/else/... chain, each else clause is another _______ statement.
Ans: If

131. The conditional operator does not produce a lvalue. (True/False)


Ans: True

132. The condition of a switch statement is a _______.


Ans: Value

133. Switch statement is an unconditional branching statement. (True/False)


Ans: False

134. A ______________ loop starts out like an if statement .


Ans While:

135. while is an entry-controlled loop. (True/False)


Ans: True

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


136. What is the control character for “a decimal integer”.
a) %c
b) %d
c) %i
d) %p
Ans: b

137. What is the control character for “a floating point number”.


a) %c
b) %d
c) %i
d) %f
Ans: d

138. C supports the ______ statement to branch unconditionally from one point to another in
the program.
a) continue
b) goto
c) break
d) for
Ans: b

139. The _______ is used to break out of the case statements.


a) continue
b) break
c) default
d) case
Ans: b

140. On using the ________, the body of the loop is always executed at least once irrespective
of the expression.

Ans: Do….while

141. do…while is an entry-controlled loop. (True/False)


Ans: False

142. for loop is an exit-controlled loop. (True/False)


Ans:False

143. The “control variable'' of a for loop does not have to be an integer. (True/False)
Ans: True

145. The output of the following program is _______________.

#include<stdio.h>

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


main()
{
int n=5;
int fun(int n);
printf(“%d\n”, fun(n));
}
int fun(int n)
{
if(n==0)
return 0;
else
return (n+fun(n-1));
}

Ans: 15

146. Which one of the following is a loop construct that will always be executed once?

a. for
b. while
c. switch
d. do while

Ans d

147. In the C language, the constant is defined _______.

a. Before main
b. After main
c. Anywhere, but starting on a new line.
d. None of the these.

Ans c

148. What is the result after execution of the following code if a is 10, b is 5, and c is 10?

If ((a > b) && (a <= c))  
        a = a + 1;  
else  
    c = c+1;  

a. a = 10, c = 10
b. a = 11, c = 10

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


c. a = 10, c = 11
d. a = 11, c = 11

Ans: b

149. How many characters can a string hold when declared as follows?

char name[20]:  
a. 18
b. 19
c. 20
d. None of the these

Ans: c

150. What is the maximum number of characters that can be held in the string variable char
address line [40]?

a. 38
b. 39
c. 40
d. 41

Ans: b

151. The scope of an automatic variable is in ____________ in which it is declared.


Ans: The function in which it is declared.

152. Does an automatic variable retain its value once control is transferred out of its defining
function? (Yes/No)
Ans: No

153. The key word auto is must in the declaration of automatic variables. (True/False)
Ans: False

154. The variables declared in the main() function are the global variables.(True/False)
Ans: False

155. The global variables are more secured than the automatic variables in a program.
(True/False)
Ans: False

156. The scope of static variables and automatic variables is the same. (True/False)
Ans: True

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


157. ____________ variables retain their values throughout the life of the program. As a result,
if a function is exited and then reentered later, the static variables defined within that function
will retain their previous values.
Ans: Static

158. By default, a static variable is initialized to _______.


Ans: Zero

159. What will the result of len variable after execution of the following statements?

int len;  
char str1[] = {"39 march road"};  
len = strlen(str1);  
a. 11
b. 12
c. 13
d. 14

Ans c

160. Which is valid expression in c language?

a. int my_num = 100,000;


b. int my_num = 100000;
c. int my num = 1000;
d. int my num == 10000;

Ans b

161. What does this statement mean?

1. x - = y + 1;  

a. x = x - y + 1
b. x = -x - y - 1
c. x = x + y - 1
d. x = x - y - 1

Ans d

162. Study the following statement

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


main()  
{     
   char *s = "Hello,"  
   "World!";  
   printf("%s", s);  
}  

What will be the output?

a. Hello, World!
b. Hello,
World!
c. Hello
d. Compile error

Ans B

163. By modularizing the problem into different sub problems. Each sub problem can be
implemented as a __________.
Ans: Function

164. The main purpose of function is to save typing time. (True/False)

Ans: False

165. The visibility of a variable determines how much of the rest of the program can access that
variable. (True/False)
Ans:True

166. __________ class refers to the persistence of a variable and its scope within the program,
that is, the portion of the program over which the variable is recognized.
Ans: Storage

167. Visibility provides security for your data used in a program. (True/False)

Ans:True

168. The main purpose of using external variables is to access the same variable in different
______________ files.
Ans: Source

169. Compiler doesn’t allocate memory for an external variable where it is accessed.
(True/False)
Ans:True

170. Global variables and external variables have the same scope. (True/False)

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Ans: False

171. In C, an array subscript starts from __________


Ans: 0
172. An array name is a pointer. (True/False)
Ans: True

173. Will there be a compilation error for the following program


segment?(Yes/No)
int a[5] = {1, 2, 3, 4, 5};
int b[5] = {5, 4, 3, 2, 1};
int c[5][5];

c=a+b;

Ans:Yes

174. Suppose that cPtr is a character pointer, and its current content is 300. What will be the
new value in cPtr after the following assignment?

cPtr = cPtr + 5;  

a. 305
b. 310
c. 320
d. 340

Ans a

175. Array is a _________ data structure.

a. Non-linear
b. Primary
c. Linear
d. Data type

Ans c

176. Which of the following statement is correct about the array?

a. In the array, users can only allocate the memory at the run time.

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


b. In the array, users can only allocate the memory at the compile time.
c. The array is a primitive and non-linear data structure that only stores a similar data type.
d. All of the these

Ans: b

177. In a two-dimensional matrix, the first subscript in the declaration specifies number of
__________.
Ans: Rows

188. A two-dimensional array is considered as an array of one-dimensional arrays. (True/False)


Ans:True

199. Will there be a compilation error for the following program? (Yes/No).
char str1[10];
str1=”Hello, world”;
printf(“%s”, str1);

Ans: Compilation Error

200. The contents-of operator * does not merely fetch values through pointers; it can also set
values through pointers. (True/False)
Ans: True

201. You can perform any type of arithmetic operation on pointers. (True or False)
Ans: False

202. For an int array a[10], If you declare a pointer variable ip then you can set it to point to the
beginning of an array by assigning: int *ip =____________ .
Ans: &a[0];

203. One common use of pointer comparisons is when copying arrays using pointers.
(True/False)
Ans: True

204. To increment what p points to, you can use the expression __________.
Ans: (*p)++.)

205. Which of the following statement is correct about the C language?

a. The C language is a binary language with some extra features.


b. The C language is a high-level language with some low features.
c. The C language is a mid-level language with some high features.
d. The C language is a low-level language.

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Ans: c

206. Study the following statement : printf ("%d", 9/5);  

What will be the output of this statement?

a. 1.8
b. 1.0
c. 2.0
d. None of the these

Ans: d

207. A global variable is declared __________.

a. Outside of the function


b. Inside of the function
c. With the function
d. Anywhere in the program

Ans: a

208. Who defines the user-defined function?

a. Compiler
b. Computer
c. Compiler library
d. Users

Ans: d

209. Which of the following operations cannot be performed in file handling?

a. Open the file


b. Read the file
c. To write a file
d. None of the these

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Ans: d

210. Which of the following function is used to write the integer in a file?

a. getw()
b. putw()
c. int value
d. f_int()

Ans: b

211. A ______ is a special pointer value that is known not to point anywhere.
Ans: Null pointer

212. A function that returns ____________ values can return a null pointer when it is unable to
perform its task.
Ans: Pointer

213. In general, C does not initialize pointers to null for you, and it never tests pointers to see if
they are null before using them. (True/False)
Ans: True

214. An array of characters is called as _________.


Ans: String

215. You can represent an array of strings using pointers by using an array of __________ to
character.
Ans: Pointers

216. A string must always be terminated with a __________ character.

Ans: Null

217. 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.

Ans: a

218. In which of the following modes, the user can read and write the file?

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


a. r
b. w
c. r+
d. b+

Ans: c

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

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

Ans: a

220. Which of the following operator's precedence order is correct (from highest to lowest)?

a. %, *, /, +, -
b. %, +, /, *, -
c. +, -, %, *, /
d. %, +, -, *, /

Ans: a

221. We can define a two dimensional array as a pointer to a group of contiguous _________
dimensional arrays.
Ans: One

222. A two-dimensional array can also be expressed in terms of an_________ of pointers rather
than as a pointer to a group of contiguous arrays.
Ans: Array

223. A ___________ is a convenient tool for handling a group of logically related data items.
Ans: structure

224. We can declare structure variables using the tag name anywhere in the program.
(True/False)
Ans: True

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


225. ____________ is a method for packing data of different types.
Ans: Array

226. If person1 and person2 are variables of the same type structure then the expression
person1>person2 is valid. (True/False)
Ans: False

227. _______________ is a method for packing data of different types.


Ans: Structure

228. The link between a member and a variable is established using the member operator
_________.
Ans: Dot(.)

229. Which of the following is not an arithmetic operation?

a. x * = 65;
b. x / = 42;
c. x % = 2;
d. x ! = 56;

Ans: d

230. Which of the following operator is represented a relational operation?

a. ==
b. ++
c. ||
d. &&

Ans: a

231. Which of the following keyword is used for union in c language?

a. un
b. unt
c. ion
d. union

Ans: d

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


232. Which of the following variable name is correct in c language?

a. For
b. for
c. Basic salary
d. hello.

Ans: a

233. We cannot write a function that returns the structure. (True/False)


Ans: True

234. We can modify a member of the structure by passing the structure as a_____________.
Ans: argument

235. We can use structures to describe the format of a number of related variables.
(True/False)
Ans: True

236. You can declare an array of structures where each element is defined to be of the type
_______.
Ans: struct

237. The parentheses around the de referenced pointer is necessary to enforce the correct
_______.
Ans: precedence

238. An alternative notation other than dot, permits simpler pointer access to structure members
is ____________.
Ans: ->

239. A __________ holds the value of one-variable at a time.


Ans: Union

240. The compiler allocates storage for the smallest member of the union. (True/False)
Ans: false

241. Which of the following header files is used for character type function in C language?

a. <assert.h>
b. <ctype.h>
c. <iostream.h>
d. <locale.h>

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Ans: b

242. Which symbol is used to declare a pointer?

a. *
b. #
c. &
d. &&

Ans: a

243. Which function is used to reverse the string?


a) strcmp
b) strrev
c) strlen
d) strupr
Ans: b

244. Which header file is used for string functions?


a) math.h
b) stdio.h
c) string.h
d) conio.h
Ans: c

245. # include is called ________.


Ans: Preprocessor directive

246. Nesting of included files is not allowed. (True/False)


Ans: False

247. Defining instances of global variables is not recommended in the header files. (True/False)
Ans: True

248. The role of preprocessor in macro substitution is ______substitution according to the


macro definition.
Ans: Text

249. Macros and functions are synonyms. (True/False)


Ans: False

250. Nesting of macros is not allowed. (True/False)


Ans: False

251. In ANSI C, the function to delete a file is __________ .


Ans: remove

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


252. On older Unix systems, the function was called ______________.
Ans: unlink

253. You can use _______________ directive which compiles code depending on whether a
compile-time expression is true or false.
Ans: #if

254. Loops in C Language are implemented using.?


A) While Block
B) For Block
C) Do While Block
D) All the above

Ans: d

255. Choose correct statement about Functions in C Language.


A) A Function is a group of c statements which can be reused any number of times.
B) Every Function has a return type.
C) Every Function may no may not return a value.
D) All the above.
Ans: d

256. Choose a correct statement about C Language Functions.


A) A function name can not be same as a predefined C Keyword.
B) A function name can start with an Underscore( _ ) or A to Z or a to z.
C) Default return type of any function is an Integer.
D) All the above.
Ans: d

257. A function which calls itself is called a ___ function.


A) Self Function
B) Auto Function
C) Recursive Function
D) Static Function
Ans: c

258. What is the output of C Program with functions.?


void show();
int main()
{
show();
printf("ARGENTINA ");
return 0;

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


}

void show()
{
printf("AFRICA ");
}
A) ARGENTINA AFRICA
B) AFRICA ARGENTINA
C) ARGENTINA
D) Compiler error
Ans: b

259. The process of allocating memory at run time is known as _________________.


Ans: Dynamic Memory Allocation

260. malloc() function returns a pointer to integer. (True/False)


Ans: False

261. For deallocating memory, you can use _________ function.


Ans: free()

262. The function that is used to alter the size of a block previously allocated is
______________.
Ans: realloc()

263. A linked list is a data structure that is used to model a dynamic list of data items and is a
collection of ___________.
Ans: nodes.

264. Linked list make use of ____________ memory allocation technique.


Ans: dynamic

265. What is the limit for number of functions in a C Program.?


A) 16
B) 31
C) 32
D) None of the above
Ans: D

266. What is the minimum number of functions to be present in a C Program.?


A) 1
B) 2
C) 3
D) 4
Ans: a

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


267. What is the output of C Program with functions and pointers.?
int main()
{
int b=25;
//b memory location=1234;
int *p = b;
printf("%d %d", b, p);

return 0;
}
A) 25 1234
B) 25 0
C) 25 25
D) Compiler error
Ans: c

268. The type FILE is predefined in the header file ___________.


Ans: stdio.h

269. We may add a “+’’ character to the mode string in the fopen function to indicate that we
want to both read and write. (True/False)
Ans: True

270. __________ returns non-zero if the stream's error indicator is set, zero otherwise.
Ans: ferror

271. ____________ function returns the current value (measured in characters) of the file
position indicator if stream refers to a binary file.
Ans: ftell

272. fseek allows the file position indicator for stream to be set to an arbitrary value.
(True/False)
Ans: True

273. __________ stores the current file position indicator for stream in the object pointed to by
pos.
Ans: fgetpos

274. Command line argument is a parameter supplied to a program when the program is
invoked. (True/False)
Ans: true
275. In the command line arguments of main(), argv is an array-of-pointers to-___________.
Ans: char

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


276. The ____________ is a parameter supplied to a program when the program is invoked.
Ans: Command line argument

277. What is the dimension of the C array int ary[10][5].?


A) 1
B) 2
C) 5
D) 10
Ans: b

278. What is the dimension of the below C Array.?


int ary[]={1,3,5,7};
A) 1
B) 2
C) 3
D) 5
Ans: a

279. Choose facts about continue; statement is C Language.


A) continue; is used to take the execution control to next iteration or sequence
B) continue; statement causes the statements below it to skip for execution
C) continue; is usually accompanied by IF statement.
D) All the above.
Ans: d

280. Choose a correct statement about C break; statement.?


A) break; statement can be used inside switch block
B) break; statement can be used with loops like for, while and do while.
C) break; statement causes only the same or inner loop where break; is present to quit
suddenly.
D) All the above.
Ans: d

281. Choose a correct C Statement regarding for loop.


for(; ;);
A) for loop works exactly first time
B) for loop works infinite number of times
C) Compiler error
D) None of the above
Ans: b

282. A ___________ image is one in which each pixel on the screen is set individually.
Ans: Bitmapped

283. The best solution to allocate memory locations for the objects when the actual number of
locations is not known in advance is by using__________________ memory allocations.

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Ans: Dynamic

284. Stack is also called _______ data structure.


Ans: LIFO

285. The drawback of implementing a stack using an array is:


(a) Stack cannot grow
(b) Stack can grow
(c) Array cannot grow even if stack is empty
(d) Array can grow infinitely
Ans: a

286. Postfix expression is used for Evaluation of Expressions. (True/False)


Ans:True

287. Queue is also called a __________ data structure.


Ans: FIFO

288. In a linked implementation of a queue, the newly added element is the front element.
(True/False)
Ans: False

289. An application of a ______________ queue is in the implementation of priority queues


required to be maintained by the scheduler of an operating system.
Ans: priority

290. Long Double data type size of (bit).

a) 8

b) 16

c) 64

d) 80

Ans: d

291. unsigned chars have values between 0 and 255. (True/False)

Ans: True

292. signed chars have values from

a) -128 to 127

b) 128 to 127

c) 1 to 127

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


d) none of these

Ans: a

293. putchar() function is an input function.(True/False)

Ans: false

294. puts() is a formatted input statement. (True/False)

Ans: false

295. getchar(),putchar(), scanf(), printf(), gets() and puts(). These functions can be

accessed within a program by including the header file.

a) stdio.h

b) math.h

c) conio.h

d) ctype.h

Ans: a

296. ADT Stands for__________________

Ans: Abstract Data Type (ADT)

297. FIFO Stands for _______________

Ans: first in first out

298: LIFO stands for_______________

Ans: Last in first out

299. A method where the youngest entry or ‘top of the stack is processed first is termed as

a) first in first out logic

b) last in last out logic

c) first in last out logic

d) last in first out logic

Ans: d

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


300. A queue ia a data structure in which all insertions and deletions are made respectively at:

a) rear and front

b) front and rear

c) front and front

d) rear and rear

Ans: a

Q1 Write a program to accept a number and check the number is even or odd?

Ans: #include<stdio.h>

int main()

int number;

printf("Enter a number:");

scanf("%d",&number);

if(number%2==0)

printf("%d is even number",number);

else

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


{

printf("%d is odd number",number);

return 0;

Q2. Write a program to accept three number and find out the largest of three number.

Ans: #include <stdio.h>

int main()

int a, b, c;

printf("Enter three numbers?");

scanf("%d %d %d",&a,&b,&c);

if(a>b && a>c)

printf("%d is largest",a);

else if(b>a && b > c)

printf("%d is largest",b);

else if(c>a && c>b)

printf("%d is largest",c);

else if(a == b && a == c)

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


printf("All are equal");

Q3. Write a program to accept the marks and check the grade depends of a condition
(marks >85 display grade A,marks >60 display grade B+, marks>40 display grade B,
marks>30 display grade C, other wise display fail).

Ans: #include <stdio.h>

int main()

int marks;

printf("Enter your marks?");

scanf("%d",&marks);

if(marks > 85 && marks <= 100)

printf("Congrats ! you scored grade A ...");

else if (marks > 60 && marks <= 85)

printf("You scored grade B + ...");

else if (marks > 40 && marks <= 60)

printf("You scored grade B ...");

else if (marks > 30 && marks <= 40)

printf("You scored grade C ...");

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


}

else

printf("Sorry you are fail ...");

Q4. What is constraint? Explain the types of constraint?

Ans: Constants in C refer to fixed values that do not change during the execution of a program. C
supports several types of constants:
1. Integer constants
An integer constant refers to a sequence of digits. There are three types of integers, namely decimal,
octal and hexadecimal.
Decimal integers consist of a set of digits, 0 through 9, preceded by an optional – or +.
Examples: 12, -546, 0, 354647, +56

2. Real constants
The numbers containing fractional parts like 67.45 are called real (or floating point) constants.
Examples: 0.0045, -8.5, +345.678

3. Character constants
A single character constant (or simple character constant) contains a single character enclosed within a
pair of single quote marks.
Examples: ‘6’, ‘X’, ‘;’

4. String constants
A string constant is a sequence of characters enclosed within double quotes.The characters may be
letters, numbers, special characters and blank space.
Examples: “Hello!”, “1947”, “5+3”

Q5. Write a program to accept a year and check the year is leap year or not a leap year.

Ans:

#include<stdio.h>
#include<conio.h>
int main()
{
int year;
printf("Enter Year: ");
scanf("%d", &year);
if((year%4==0) && (year%100!=0))
printf("\nIt's a Leap Year");
else if(year%400==0)
printf("\nIt's a Leap Year");
else

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


printf("\nIt's not a Leap Year");
getch();
return 0;
}

Q6. write a program in C that converts temperature given in degree Fahrenheit to


temperature in degree Celsius. 

Ans: #include<stdio.h>
#include<conio.h>
int main()
{
float fahrenheit, celsius;
printf("Enter Temperature Value (in Fahrenheit): ");
scanf("%f", &fahrenheit);
celsius = (fahrenheit-32)/1.8;
printf("\nEquivalent Temperature (in Celsius) = %0.2f", celsius);
getch();
return 0;
}

Q7. What is operator? Explain the five types of operator?

An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations.
Operators are used in programs to manipulate data and variables. There are very types of operator:

1. Arithmetic operators
2. Unary operator
3. Relational operators
4. Logical operators
5. Conditional operator

6. Bitwise operators
7. Increment and Decrement operators

1. Arithmetic Operators
The basic operators for performing arithmetic are the same in many computer languages:
+ addition
- subtraction
* multiplication
/ division
% modulus (remainder)

2. Unary Operator
A unary operator acts upon a single operand to produce a new value. Example (++,--)

3. Relational

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


The relational operators such as <, <=, >, and >= are in fact operators, just like +, -, *, and /. The
relational operators take two values, look at them, and “return'' a value of 1 or 0 depending on whether
the tested relation was true or false. The complete set of relational operators in C is:
< less than
<= less than or equal
> greater than
>= greater than or equal
== equal
!= not equal

4. Logical operators

You can also combine true/false values by using the Boolean operators(also called the logical
operators), which take true/false values as operands and compute new true/false values. The three
Logical operators are:
&& AND
|| OR
! NOT (takes one operand, “unary'')

Q8. Write a program to accept a number and find out a factorial number.

Ans:

#include<stdio.h>
#include<conio.h>
int main()
{
int num, i, fact=1;
printf("Enter any number: ");
scanf("%d", &num);
for(i=num; i>0; i--)
fact = fact*i;
printf("\nFactorial of %d = %d", num, fact);
getch();
return 0;
}

Q9. What is Library Function? write any five library function?


Ans:
The C language is accompanied by a number of library functions or built in functions that carry
out various commonly used operations or calculations. There are library functions that carry out
standard input/output operations, functions that perform operations on characters, functions that
perform
operations on strings and functions that carry out various mathematical calculations.
A library function is accessed simply by writing the function name, followed by a list of
arguments that represent information being passed to the function. A typical set of library
functions will include a large number of functions that are common to most C compilers.
pow(d1,d2) Return d1 raised to the power d2

putchar(c) Send a character to the standard output device

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


rand() Return a random positive integer

sin(d) Return sine of d

sqrt(d) Return the square root of d

tan(d) Return the tangent of d

toascii(c) Convert value of argument to ASCII

tolower(c) Convert letter to lowercase

toupper(c) Convert letter to uppercase

Q10. Write a program to accept a number and find out a factorial number using function.

Ans:
#include<stdio.h>
#include<conio.h>
int findFact(int);
int main()
{
int num, fact;
printf("Enter any number: ");
scanf("%d", &num);
fact = findFact(num);
printf("\nFactorial of %d = %d", num, fact);
getch();
return 0;
}
int findFact(int n)
{
int i=n, f=1;
while(i>0)
{
f = f*i;
i--;
}
return f;
}

Q11. write a  program that will calculate the factorial of any given number using recursive
function?

Ans: #include<stdio.h>
#include<conio.h>
int findFact(int);
int main()

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


{
int num, fact;
printf("Enter the number: ");
scanf("%d", &num);
fact = findFact(num);
printf("Factorial = %d", fact);
getch();
return 0;
}
int findFact(int val)
{
if(val==1)
return val;
else
return val*findFact(val-1);
}

Q12. Write a program to accept a character value and check the character value is vowel
or consonant. (using switch statement)

Ans:

#include <stdio.h>

int main()

char input;

printf( "Enter a character " );

scanf( "%c", &input );

switch ( input )

case 'a':

printf("vowel character is: %c",input);

break;

case 'e':

printf("vowel character is: %c",input);

break;

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


case 'i':

printf("vowel character is: %c",input);

break;

case 'o':

printf("vowel character is: %c",input);

break;

case 'u':

printf("vowel character is: %c",input);

break;

case 'A':

printf("vowel character is: %c",input);

break;

case 'E':

printf("vowel character is: %c",input);

break;

case 'I':

printf("vowel character is: %c",input);

break;

case 'O':

printf("vowel character is: %c",input);

break;

case 'U':

printf("vowel character is: %c",input);

break;

default:

printf( "Consonant" );

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


break;

return 0;

Q13. Write a program to accept a character value and check the character value is vowel
or consonant. (using if statement)

Ans:

#include <stdio.h>

int main()

char input;

printf( "Enter a character " );

scanf( "%c", &input );

if(input == ‘a’ || input == ‘A’ || input == ‘e’ || input == ‘E’ || input == ‘i’ || input == ‘I’ || input == ‘o’
|| input == ‘O’ || input == ‘u’ || input == ‘U’ )

printf( "Vowel character is: %c",input);

else

printf( "Consonant" );

return 0;

Q14. Write a Program to calculate the average of N numbers?

Ans:

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


#define N 10 /* SYMBOLIC CONSTANT */

Void main()

int count;

float sum, average, number;

sum = 0;

count = 0;

while (count<N)

Printf(“enter a number”);

scanf(“%f”, &number);

sum = sum + number;

count = count + 1;

average = sum / N;

printf(“N = % d Sum = %f “, N, sum);

printf(“Average = %f”, average);

Q15. write a program to accept any number and check number is prime or not.

Ans:

#include<stdio.h>

#include<conio.h>
int main()
{
int num, i, count=0;
printf("Enter a number: ");
scanf("%d", &num);
for(i=2; i<num; i++)
{
if(num%i == 0)

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


{
count++;
break;
}
}
if(count==0)
printf("\nIt's a prime number");
else
printf("\nIt's not a prime number");
getch();
return 0;
}

Q16. Write a Program to find largest of n numbers?

Ans:

#include<stdio.h>

#include<conio.h>

void main()

int num, large, n, i;

clrscr();

printf("enter number of numbers \n");

scanf(“%d”,&n);

large=0;

i=0;

while(i<n)

printf("\n enter number ");

scanf(“%d”, &num);

if(large<num)

large=num;

i++;

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


}

printf("\n large = %d”, large);

Q17. Program to add two matrices?

Ans:

#include <stdio.h>

Void main()

int a[5][5], b[5][5], c[5][5];

int i, j, m, n;

printf(“Enter the order of the matrices:”);

scanf(“%d%d”, &m, &n);

printf(“ Enter the elements of A matrix:\n”);

for(i=0;i<m;i++)

for(j=0;j<n;j++)

scanf(“%d”, &a[i][j]);

printf(“Enter the elements of B matrix:\n”);

for(i=0;i<m;i++)

for(j=0;j<n;j++)

scanf(“%d”, &b[i][j]);

/* Add the matrices */

for(i=0;i<m;i++)

for(j=0;j<n;j++)

c[i][j] = a[i][j]+b[i][j];

/* Print the sum */

printf(“The sum of matrices:\n”);

for(i=0;i<m;i++)

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


{

for(j=0;j<n;j++)

printf(“%d\t”, c[i][j]);

printf(“\n”);

Q18. Write a program to accept two number and swap the two number.

Ans: #include<stdio.h>
#include<conio.h>
int main()
{
int num1, num2, temp;
printf("Enter Two Numbers:-\n");
printf("First Number: ");
scanf("%d", &num1);
printf("Second Number: ");
scanf("%d", &num2);
printf("\nBefore Swap:\n");
printf("First Number = %d\tSecond Number = %d", num1, num2);
temp = num1;
num1 = num2;
num2 = temp;
printf("\n\nAfter Swap:\n");
printf("First Number = %d\tSecond Number = %d", num1, num2);
getch();
return 0;
}

Q19. write a program in C that reverse a number using for loop.


Ans:
#include<stdio.h>
#include<conio.h>
int main()
{
int num, rev, rem;
printf("Enter the Number: ");
scanf("%d", &num);
for(rev=0; num!=0; num=num/10)
{
rem = num%10;
rev = (rev*10)+rem;

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


}
printf("\nReverse = %d", rev);
getch();
return 0;
}

Q20. create a program that checks for a Palindrome number.


Ans:

#include<stdio.h>
#include<conio.h>
int main()
{
int num, rev=0, rem, temp;
printf("Enter a Number: ");
scanf("%d", &num);
temp = num;
while(temp>0)
{
rem = temp%10;
rev = (rev*10)+rem;
temp = temp/10;
}
if(rev==num)
printf("\nIt's a Palindrome Number");
else
printf("\nIt's not a Palindrome Number");
getch();
return 0;
}

Q21. Write a Program to swap two integers using pointers?

Ans:

#include<stdio.h>

main()

int a, b;

void swap(int *a, int *b);

printf(“ Read the integers:”);

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


scanf(“%d%d”, &a, &b);

swap(&a, &b); /* call by reference or call by address*/

printf(“ \nAfter swapping:a=%d b=%d”, a, b);

void swap(int *x, int *y)

int temp;

temp=*x;

*x=*y;

*y=temp;

return;

Q22. write a program prints half pyramid using star pattern.

Ans: #include<stdio.h>
#include<conio.h>
int main()
{
int i, j;
for(i=0; i<5; i++)
{
for(j=0; j<=i; j++)
printf("* ");
printf("\n");
}
getch();
return 0;
}

Output

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Q23.  write a program to accept the array and finding the largest number from given list
(or array) 

Ans:
#include<stdio.h>
#include<conio.h>
int main()
{
int arr[10], i, large;
printf("Enter 10 Array Elements: ");
for(i=0; i<10; i++)
scanf("%d", &arr[i]);
i=0;
large = arr[i];
while(i<10)
{
if(large<arr[i])
large = arr[i];
i++;
}
printf("\nLargest Number = %d", large);
getch();
return 0;
}

Q24. Write a program to accept name and find out of length of name.
Ans:

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str[20];
int len;
printf("Enter the string: ");
gets(str);
len = strlen(str);
printf("\nLength of the string = %d", len);
getch();
return 0;
}

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Q25. write a program to accept any two string and display full string using concatenate
function in string.

Ans:
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str1[50], str2[50];
printf("Enter first string: ");
gets(str1);
printf("Enter second string: ");
gets(str2);
strcat(str1, str2);
printf("\nString after concatenation is:\n%s", str1);
getch();
return 0;
}

Q26. print a Fibonacci series 0 1 1 2 3 5 8 13 21 34……….n .

Ans:

#include<stdio.h>

int main()

int n1=0,n2=1,n3,i,number;

printf("Enter the number of elements:");

scanf("%d",&number);

printf("\n%d %d",n1,n2);//printing 0 and 1

for(i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed

n3=n1+n2;

printf(" %d",n3);

n1=n2;

n2=n3;

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


}

return 0;

Q27. To print the Name, Salary and date of joining of a person.(using Structures)

Ans:

#include<conio.h>

#include<stdio.h>

struct personal

char name[30];

int day;

int month;

int year;

float salary;

};

void main()

struct personal p;

printf(“Enter the name:\n)";

gets(p.name);

printf(“Enter the day of joining:\n)";

scanf(“%d”,&p.day);

printf(“Enter the month of joining:\n");

scanf(“%d”,&p.month);

printf(“Enter the year of joining:\n)";

scanf(“%d”,&p.year);

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


printf(“Enter the salary:\n)";

scanf(“%f”, & p.salary);

printf(“\nName:",p.name);

printf("\nDate of joining:%d %d %d",p.day,p.month,p.year);

printf(“Salary:",p.salary);

getch();

Q28. print a pattern like

1
12
123
123 4

Ans:

#include <stdio.h>

int main() {

int i, j, rows;

printf("Enter the number of rows: ");

scanf("%d", &rows);

for (i = 1; i <= rows; ++i) {

for (j = 1; j <= i; ++j) {

printf("%d ", j);

printf("\n");

return 0;

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


Q29. print a pattern like

1
22
333
4444

Ans:

#include <stdio.h>

int main() {

int i, j, rows;

printf("Enter the number of rows: ");

scanf("%d", &rows);

for (i = 1; i <= rows; ++i) {

for (j = 1; j <= i; ++j) {

printf("%d ", i);

printf("\n");

return 0;

Q30. Difference between Structure and Union?

Ans:

Structure

A structure is a user-defined data type available in C that allows to combining data items of
different kinds. Structures are used to represent a record.
Defining a structure: To define a structure, you must use the struct statement. The struct
statement defines a new data type, with more than one member. The format of the struct
statement is as follows:
struct [structure name]
{
member definition;

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com


member definition;
...
member definition;
};

union
A union is a special data type available in C that allows storing different data types in the same
memory location. You can define a union with many members, but only one member can
contain a value at any given time. Unions provide an efficient way of using the same memory
location for multiple purposes.
Defining a Union: To define a union, you must use the union statement in the same way as
you did while defining a structure. The union statement defines a new data type with more than
one member for your program. The format of the union statement is as follows:

union [union name]


{
member definition;
member definition;
...
member definition;
};

Solve Assignment Mob No. 7290886986 Email Id -solveassignmentuniversity@gmail.com

You might also like