Strings programs unit III TO UPLOAD
Strings programs unit III TO UPLOAD
h>
void main()
{
char str[]="aa\0bb";
printf("%s",str);
}
#include <stdio.h>
void main()
{
char string[50];
int i, length = 0;
printf("Enter a string \n");
gets(string);
/* keep going through each character of the string till its end */
for (i = 0; string[i] != '\0'; i++)
{
length++;
}
printf("The length of a string is the number of characters in it \n");
printf("So, the length of %s = %d\n", string, length);
}
//Program(String reverse without library functions)
#include<stdio.h>
#include<string.h>
int main()
{
char str[100], temp;
int i, j = 0;
printf("\nEnter the string :");
gets(str);
i = 0;
j = strlen(str) - 1;
while (i < j)
{
temp = str[i];
str[i] = str[j];
str[j] = temp;
i++;
j--;
}
printf("\nReverse string is :%s", str);
return (0);
}
/* C program to Reverse a String without using strrev() */
#include <stdio.h>
#include <string.h>
int main()
{
char Str[100], RevStr[100];
int i, j, len;
j = 0;
len = strlen(Str);
}
RevStr[j] = '\0';
return 0;
}
/* C program to Copy String without using strcpy() */
#include <stdio.h>
#include <string.h>
int main()
{
char Str[100], CopyStr[100];
int i;
return 0;
}
To Concatenate Two Strings without using strcat() */
#include <stdio.h>
#include <string.h>
int main()
{
char Str1[100], Str2[100];
int i, j;
i = 0;
while( Str1[i]!='\0')
{
i++;
}
j = 0;
while( Str2[j]!='\0')
{
Str1[i] = Str2[j];
i++;
j++;
}
Str1[i] = '\0';
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
char Str1[100], Str2[100];
int result, i;
i = 0;
return 0;
}
SORTING OF NAMES
#include <stdio.h>
#include <string.h>
void main()
{
printf("\n----------------------------------------\n");
printf("Input NamestSorted names\n");
printf("------------------------------------------\n");
printf("------------------------------------------\n");
}
//SUM OF DIAGONAL ELEMENTS
#include <stdio.h>
void main ()
{
if (m == n )
{
else
printf("The given order is not square matrix\n");