0% found this document useful (0 votes)
63 views3 pages

SR - No. Types & Description: Void Indicates That No Value Is Available

The document discusses different data types in C including basic types like integers and floating-point numbers. It also discusses enumerated types, the void type, and derived types like pointers, arrays, structures, unions, and functions. The document then provides an example of a recursive function to calculate the factorial of a number and defines constants in C, describing integer, real, octal, hexadecimal, and character constants. Finally, it differentiates between keywords and identifiers in C with examples.

Uploaded by

sudharsonkumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views3 pages

SR - No. Types & Description: Void Indicates That No Value Is Available

The document discusses different data types in C including basic types like integers and floating-point numbers. It also discusses enumerated types, the void type, and derived types like pointers, arrays, structures, unions, and functions. The document then provides an example of a recursive function to calculate the factorial of a number and defines constants in C, describing integer, real, octal, hexadecimal, and character constants. Finally, it differentiates between keywords and identifiers in C with examples.

Uploaded by

sudharsonkumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

4) Explain the different data types in C.

Data types in c refer to an extensive system used for declaring variables or functions of different
types. The type of a variable determines how much space it occupies in storage and how the bit
pattern stored is interpreted.

Sr.No. Types & Description

1 Basic Types
They are arithmetic types: (a) integer types and (b) floating-point types.

2 Enumerated types
They are again arithmetic types and they are used to define variables that can only assign certain
discrete integer values throughout the program.

3 The type void


void indicates that no value is available.

4 Derived types
(a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types.

7) What is recursion? Write a program to find the factorial of a given number using recursion.

The C programming language supports recursion, i.e., a function to call itself. Recursive
functions are very useful to solve many mathematical problems, such as calculating the factorial
of a number, generating Fibonacci series, etc.

Example Program:
Live Demo
#include <stdio.h>
int factorial(int i) {
if(i <= 1) {
return 1;
}
return i * factorial(i - 1);
}
void main() {
int i = 12;
printf(factorial(i));
}
8) Define constant. Describe the various types of constant in C.
C Constants are also like normal variables. But, only difference is, their values cannot be
modified by the program once they are defined. Constants refer to fixed values.
Syntax:
const data_type variable_name; (or) const data_type *variable_name;
TYPES OF C CONSTANT:

Constant type data type (Example)

int (53, 762, -478 etc )


unsigned int (5000u, 1000U etc)
long int, long long int
Integer constants (483,647 2,147,483,680)

float (10.456789)
Real or Floating point constants doule (600.123456789)

Octal constant int (Example: 013 /*starts with 0 */)

Hexadecimal constant int (Example: 0x90 /*starts with 0x*/)

character constants char (Example: „A‟, „B‟, „C‟)

string constants char (Example: “ABCD”, “Hai”)

9) Differentiate between identifier and keywords with Examples

BASIS FOR
KEYWORD IDENTIFIER
COMPARISON

Basic Keywords are the reserved Identifiers are the user defined names of
word. variable, function and labels.

Use Specify the type/kind of Identify the name of a particular entity.


entity.

Format Consider only letters. Consider letters, underscore, digits.

Case Use only lowercase. Lower and upper cases, both are allowed.

Symbol No special symbol, No punctuation or special symbol except


punctuation is used. 'underscore' is used.

Classification Keywords are not further Identifier are classified into 'external name'
classified. and 'internal name'.
BASIS FOR
KEYWORD IDENTIFIER
COMPARISON

Starting letter It always starts with a First character can be a uppercase, lowercase
lowercase letter. letter or underscore.

Example int, char, if, while, do, class Test, count1, high_speed, etc.
etc.

6mark
Explain any five string manipulation library functions with examples
Function Work of Function
strlen() computes string's length
strcpy() copies a string to another
strcat() concatenates(joins) two strings
strlwr() converts string to lowercase
strupr() converts string to uppercase

#include <stdio.h>
#include <string.h>
void main () {
char str1[12] = "Hello";
char str2[12] = "World";
char str3[12];
int len ;
strcpy(str3, str1);
printf("strcpy( str3, str1) : %s\n", str3 );
strcat( str1, str2);
printf("strcat( str1, str2): %s\n", str1 );
len = strlen(str1);
printf("strlen(str1) : %d\n", len );
printf(strlwr(str1));
printf(strupr(str2));
}

Output:
strcpy( str3, str1) : Hello
strcat( str1, str2): HelloWorld
strlen(str1) : 10
hello
WORLD

You might also like