C program 2021 Makeup

Uncategorized

Q.no 1 . Explain the different types of data types with examples.

In C programming, data types are declarations for variables. This determines the type and size of data associated with variables.
Type of data types:

  1. Primary data types:These are fundamental data types in C namely integer(int), floating point(float), character(char) and void.
  2. Derived data types:Derived data types are nothing but primary datatypes but a little twisted or grouped together like array, stucture, union and pointers. These are discussed in details later.

For more details follow notes section of site.

Q.no 2

Q.no 3

Dynamic memory allocation in c language enables the C programmer to allocate memory at runtime. Dynamic memory allocation in c language is possible by 4 functions of stdlib.h header file.

  1. malloc()
  2. calloc()
  3. realloc()
  4. free()

Q.4

The strcmp() compares two strings character by character. If the strings are equal, the function returns 0.
C strcmp() Prototype
The function prototype of strcmp() is:
int strcmp (const char* str1, const char* str2);

 strcpy()

The strcpy() function in C programming to copy strings (with the help of an example).

The function prototype of strcpy() is:
char* strcpy(char* destination, const char* source);
Example

Write a program to count a number of vowels in a given string.

Q.5 Describe the types of  control statement.

Control statements enable us to specify the flow of program control; ie, the order in which the instructions in a program must be executed. They make it possible to make decisions, to perform tasks repeatedly or to jump from one section of code to another.
There are four types of control statements in C:

  1. Decision making statements
  2. Selection statements
  3. Iteration statements
  4. Jump statements

For more details follow notes section of site.
 

Q.7

S.No Array Structure
1 Array is collection of homogeneous data. Structure is the collection of heterogeneous data.
2 Array data are access using index. Structure elements are access using . operator.
3 Array allocates static memory. Structures allocate dynamic memory.
4 Array element access takes less time than structures. Structure elements takes more time than Array.

 
 





Q.8

Write a c program for a  menu driven program which has following option:

a. Factorial of a number

b. Odd or Even

c. Exit

 

Leave a Reply

Your email address will not be published. Required fields are marked *