BCA

C LAB :PART A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

C LAB : PART B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

Write a C Program to find the length of a string without using built in function

 

   /*Write a C Program to find the length of a string without using built in function */

#include < stdio.h >
#include< conio.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);
getch();
}