Showing posts from April, 2016
write a program to read a series of words from a terminal using scanf functionprogram:
main( ) { char word1[40], word2[40], word3[40], word4[40]; printf("Enter text : \n"); scanf("%s %s", word1, word2); scanf("%s", word3); scanf("%s", word4); printf("\n"); printf("word1 = %s\nword2 = %s\n", word1, word2); printf("word3 = %s\nword4 = %s\n", word3, word4); } Output Enter text : Gill Road, Gill Park word1 = Gil…
c program to copy one string to another and count the number of characters copiedprogram: main( ) { char string1[80], string2[80]; int i; printf("Enter a string \n"); printf("?"); scanf("%s", string2); for( i=0 ; string2[i] != '\0'; i++) string1[i] = string2[i]; string1[i] = '\0'; …
Source Code to Calculate Factorial Using RecursionProgram:- #include<stdio.h>int factorial(int n);int main(){int n; printf("Enter an positive integer: "); scanf("%d",&n); printf("Factorial of %d = %ld", n, factorial(n));return0;}int factorial(int n){if(n!=1)return n*factorial(n-1);}Output Enter an positive integer: 8
Factorial of 8  = 40320