Professional Documents
Culture Documents
THEORY
Strings are sequence of characters used in programming language for storing and manipulating
texts such as words, sentence, names etc. In C, there is no built-in data type for strings. String can be
represented as a one-dimensional array of characters. A character string is stored in an array of
character type. In C, just like variables strings can be passed to a function. The strings can be passed to
other function to carry out different operations.
DEMONSTRATION
#include <stdio.h>
void studentData(int rollno , char *name , float marks)
{
printf("\nName is : %s",name);
printf("\nRoll No. is : %d",rollno);
printf("\nMarks are : %f ",marks);
}
int main()
{
int rollno;
float marks;
char name[20];
printf("Enter Name::");
scanf("%s",&name);
printf("Enter roll no::");
scanf("%d",&rollno);
printf("Enter marks::");
scanf("%f",&marks);
Discussion:
In above program, the string is passed to a function to carry out the operation.
CONCLUSION
Hence, passing string to function was demonstrated.