include include main(){char s1[20], s2[20];printf(“\nEnter first string: “);gets(s1);printf(“\nEnter second string: “);gets(s2);strcat(s1, s2);printf(“\nThe concatenated string is: %s”, s1);getch();}OUTPUT: Enter first string: Programming Enter second string: .com
Start reading C Program to CONCATENATE Two Strings using strcat()Blog
include include int main(){char s1[20], s2[20];int result;printf(“\nEnter first string: “);gets(s1);printf(“\nEnter second string: “);gets(s2);result = strcmp(s1, s2);if (result == 0)printf(“\nBoth strings are equal”);elseprintf(“\nBoth strings are not equal”);return 0;}OUTPUT:Enter first string: Programming9.com Enter second string: Programming9.com Both strings are equal
Start reading C Program to Compare Two Strings using strcmp()include swap (int, int);main(){int a, b;printf(“\nEnter value of a & b: “);scanf(“%d %d”, &a, &b);printf(“\nBefore Swapping:\n”);printf(“\na = %d\n\nb = %d\n”, a, b);swap(a, b);printf(“\nAfter Swapping:\n”);printf(“\na = %d\n\nb = %d”, a, b);getch();}swap (int a, int b){int temp;temp = a;a = b;b = temp;}OUTPUT:Enter value of a & b: 10 20 Before Swapping: a = 10 b = …
Start reading C Program to Implement Call By Value using Functionsinclude include main(){char s1[20];int len;printf(“\nEnter any string: “);gets(s1);len = strlen(s1);printf(“\nLength of string: %d”, len);getch();}OUTPUT:Enter any string: programming9.com Length of string: 16
Start reading C Program to Find Length of a String Using STRLEN()include include int main(){char str[50];int i=0, word=0, chr=0;printf(“\nEnter Your String: “);gets(str);while (str[i] != ‘\0’){if (str[i] == ‘ ‘){word++;chr++;}elsechr++;i++;}printf(“\nNumber of characters: %d”, chr);printf(“\nNumber of words: %d”, word+1);return 0;}OUTPUT:Enter Your String: Welcome to Programming9 .com Number of characters: 28Number of words: 4
Start reading C Program to Find Number of Characters and Words in a Stringinclude int main(){int i, n, a, sq;printf(“\n\tProgram finds square of positive numbers only\n”);printf(“\nHow many numbers you want to enter: “);scanf(“%d”, &n);for (i=1; i<=n; i++){printf(“\nEnter Number: “);scanf(“%d”, &a);if (a < 0)continue;sq = a * a;printf(“\nSquare of a Number : %d\n”, sq);}return 0;}OUTPUT:Program finds square of positive numbers only How many numbers you want to enter: 3 …
Start reading C Program to Implement CONTINUE statementBreak is a simple statement. It only makes sense if it occurs in the body of a switch, do, while or for statements. When it is executed, the control flow jumps out of the loop when the condition met. If you use break, it will go out of the loop and executes the statements out …
Start reading C program to Implement BREAK Statementinclude swap (int *, int *);int main(){int a, b;printf(“\nEnter value of a & b: “);scanf(“%d %d”, &a, &b);printf(“\nBefore Swapping:\n”);printf(“\na = %d\n\nb = %d\n”, a, b);swap(&a, &b);printf(“\nAfter Swapping:\n”);printf(“\na = %d\n\nb = %d”, a, b);return 0;}swap (int *x, int *y){int temp;temp = *x;*x = *y;*y = temp;} OUTPUT:Enter value of a & b: 10 20 Before Swapping: …
Start reading Swapping of Two Numbers Using Call By Reference in CProgram to Search an Element using BInary Search */ include /* Function Prototype Declaration */void binary_search(); /* Global Declaration of Variables */int a[50], n, item, loc, beg, mid, end, i; /* We used main() because it’s a C-Compiler.Use void main() or int main() if necessary */ main(){printf(“\nEnter size of an array: “);scanf(“%d”, &n); // Reading …
Start reading C Program to Implement BINARY SEARCHinclude main(){int n,i,sum;i=1,sum=0;printf(“Enter Maximum Value(n):”);scanf(“%d”,&n);while(i<=n){sum=sum+i*i;++i;}printf(“Sum of squares of numbers from 1 to n is :%d “,sum);}OUTPUT: Enter Maximum Value(n):5Sum of squares of numbers from 1 to n is :55
Start reading C Program for Sum of Squares of Numbers from 1 to n