Saturday, 5 March 2022

7. Write a program to enter text with gets() and display it using printf() statement also find the length of the text.( find lenth without using function)

/* 7.write a program to enter text with gets() and display
    it using printf() statement also find the lenth */

#include<stdio.h>
#include<conio.h>

void main()
{
    int i,a=0,k=0;
    char str[97];
    clrscr();

    printf("enter a text:");
    gets(str);

    printf("\n\nyour entered text is: %s",str);

    for(i=0; str[i] !='\0'; i++)
    {
        if(str[i] !=' ')
        {
            a++;
        }
    }
    printf("\n\nyour entered text lenth is: %d",a);
    getch();
}

/*      output:

enter a text:vrushal pandav


your entered text is: vrushal pandav

your entered text lenth is: 13

*/ 

No comments:

Post a Comment

python programs

1. sum of two number