Skip to main content

Posts

Showing posts from February 23, 2014

program to find the largest element in an array

C program to find the largest element in an array #include <stdio.h> int main(){   int a[50],size,i,big;   printf( "\nEnter the size of the array: " );   scanf( "%d" ,&size);   printf( "\nEnter %d elements in to the array: ”, size);   for (i=0;i<size;i++)       scanf( "%d" ,&a[i]);   big=a[0];   for (i=1;i<size;i++){       if (big<a[i])            big=a[i];   }   printf( "\nBiggest: %d" ,big);   return 0; }   C program to print Pascal triangle using for loop #include <stdio.h> long fact( int ); int main(){     int line,i,j;     printf( "Enter the no. of lines: " );     scanf( "%d" ,&line);     for (i=0;i<line;i++){          for (j=0;j...

C program to compare two strings without using string functions

#include <stdio.h> int stringCompare( char [], char []); int main(){     char str1[100],str2[100];     int compare;     printf( "Enter first string: " );     scanf( "%s" ,str1);     printf( "Enter second string: " );     scanf( "%s" ,str2);     compare = stringCompare(str1,str2);     if (compare == 1)          printf( "Both strings are equal." );     else          printf( "Both strings are not equal" );       return 0; } int stringCompare( char str1[], char str2[]){     int i=0,flag=0;         while (str1[i]!= '\0' && str2[i]!= '\0' ){          if (str1[i]!=str2[i]){   ...