#include<stdio.h> #include<string.h> int main (){ char str[6] ={'h','e','l','l','o','\0'}; printf("%s",str); //using strlen // strlen = string length printf("\nlength of string is %lu", strlen(str)); //using strcpy /*strcpy (s1 ,s2)= copy secound string in frist string*/ char str2[6]; strcpy(str2,str); printf("\n string1 copied in str2 = %s",str2); /* using of strncpy strncpy(s1,s2,length of string to be copied) = copies characters of a string s2 to another string s1 up to a speciafied length n */ char str3 [ 10 ] ; strncpy ( str3 , str , 4 ) ; printf ( "\n after strncpy str3 is %s " , str...
#include<stdio.h> // sum is a function which takes a and b as input and returns an integer as an output int sum(int a, int b); // function prototype declaration int main(){ int c; c = sum(2, 15); // function call printf("The value of c is %d\n", c); return 0; } int sum (int a, int b){ int c; c = a + b; return c; }
Comments
Post a Comment