Ex No 6 FUNDAMENTALS OF C PROGRAMMING
Ex No 6 FUNDAMENTALS OF C PROGRAMMING
Aim:
. To write a C program to find the length of the entered string using string handling function.
Algorithm:
Description:
● A sequence of one or more characters enclosed in double quotes.
● Stored using character arrays
● Automatically terminated with a null character (\0)
Declaration of String
data_type string_name[size];
Example: char s[5];
Initialization of String
Method 1:
1
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
Method 2:
char c[50] = "abcd";
Method 3:
char c[] = {'a', 'b', 'c', 'd', '\0'};
Method 4:
char c[5] = {'a', 'b', 'c', 'd', '\0'};
Program:
Read String from the user:
#include <stdio.h>
int main()
{
char name[20];
printf("Enter name: ");
scanf("%s", name);
printf("Your name is %s.", name);
return 0;
}
String Functions:
2
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
3
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
List of experiments:
OUTPUT :
4
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
5
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
OUTPUT :
6
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
OUTPUT :
5. Write a program to find the whether the given two strings are equal or not.
7
20CS1003L – Fundamentals of programming for URK21C
Problem Solving Lab S
OUTPUT :
Result:
THE PROGRAMS ARE EXECUTED AND VERIFIED.