Program to read string in C language:
#include<stdio.h>
void main(){
char course[20];
printf("enter your course name
\n");
gets(course);
printf("your course name is
%s",course);
}
output 1:
enter your course name
C
your course name is C
output 2:
enter your course name
C language
your course name is C language
output 3:
enter your course name
C++
your course name is C++
we use gets() function to read a string in c language.
here we declared a character array by name course ( of size 20) to store the string.
No comments:
Post a Comment