RakeshMgs

All C Program

 

    //C hello world example
    #include <stdio.h>
     
    void main()
    {
      printf("Hello world\n");
      
    }

    #include <stdio.h>

    void main()

    {

    int number;

    printf("Enter an integer: ");

    // scanf() reads the formatted input and stores them

    scanf("%d", &number);

    // printf() displays the formatted output

    printf("You entered: %d", number);

    }

    #include<stdio.h>
     
    void main()
    {
       int a, b, c;
     
       printf("Enter two numbers to add\n");
       scanf("%d%d",&a,&b);
     
       c = a + b;
     
       printf("Sum of entered numbers = %d\n",c);
     
       
    }
    #include<stdio.h>
     
    void main()
    {
       int length=2, breadth=3 ,area;
     
      
     
       area = length * breadth;
     
       printf("area of rectangle = %d\n",area);
     
       
    }
    #include <stdio.h>
     
    void main()
    {
       int n;
     
       printf("Enter an integer\n");
       scanf("%d", &n);
     
       if (n%2 == 0)
          printf("Even\n");
       else
          printf("Odd\n");
     
       
    }
    #include <stdio.h>
     
    void main()
    {
       int first, second, add, subtract, multiply;
       float divide;
     
       printf("Enter two integers\n");
       scanf("%d%d", &first, &second);
     
       add = first + second;
       subtract = first - second;
       multiply = first * second;
       divide = first / (float)second;   //typecasting
     
       printf("Sum = %d\n",add);
       printf("Difference = %d\n",subtract);
       printf("Multiplication = %d\n",multiply);
       printf("Division = %.2f\n",divide);
     
       
    }
     
    #include <stdio.h>
     
    void main()
    {
       int n, sum = 0, c, value;
     
       printf("Enter the number of integers you want to add\n");
       scanf("%d", &n);
     
       printf("Enter %d integers\n",n);
     
       for (c = 1; c <= n; c++)
       {
          scanf("%d", &value);
          sum = sum + value;
       }
     
       printf("Sum of entered integers = %d\n",sum);
     
       
    }
    #include <stdio.h>
     
    void main()
    {
       int n1=2,n2=3,n3=4;
      
       if(n1>n2 && n2>n3)
       printf("n1 is greater"); 
       
       if(n2>n1 && n2>n3)
       printf("n2 is greater");
      
       if(n3>n1 && n3>n2)
       printf("n3 is greater");
     }  
    #include <stdio.h>
     
    int main()
    {
       int x, y, temp;
     
       printf("Enter the value of x and y\n");
       scanf("%d%d", &x, &y);
     
       printf("Before Swapping\nx = %d\ny = %d\n",x,y);
     
       temp = x;
       x    = y;
       y    = temp;
     
       printf("After Swapping\nx = %d\ny = %d\n",x,y);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int a, b;
     
       printf("Enter two integers to swap\n");
       scanf("%d%d", &a, &b);
     
       a = a + b;
       b = a - b;
       a = a - b;
     
       printf("a = %d\nb = %d\n",a,b);
       return 0;
    }
    #include<stdio.h>
     
    void main()
    {
       int n;
     
       printf("Enter a number from 1, 2 or 3.\n");
       scanf("%d", &n);
     
       switch(n)
       {
          case 1:
                  printf("You choose case 1 Thanks!\n");
                  break;
          case 2:
                 printf("You choose case 2 Thanks!\n");
                  break;
          case 3:
                  printf("You choose case 3 Thanks!\n");
                  break;
     
          default:
                  printf("You didn't did what i said.\n");
       }
     
       
    }   
    #include<stdio.h>
     
    void main()
    {
      int total_mark=100, score=70,percentage;
     
       percentage=score/total_mark *100;
       
                  printf("You percentage is %d",percentage);
                  
       
    }   
    #include <stdio.h>
     
    int main()
    {
        float basic, gross, da, hra;
     
        // Read basic salary of employee
        printf("Enter basic salary of an employee: ");
        scanf("%f", &basic);
     
     
        // Calculate D.A and H.R.A according to specified conditions
        if(basic <= 10000)
        {
            da  = basic * 0.8;
            hra = basic * 0.2;
        }
        else if(basic <= 20000)
        {
            da  = basic * 0.9;
            hra = basic * 0.25;
        }
        else
        {
            da  = basic * 0.95;
            hra = basic * 0.3;
        }
     
        // Calculate gross salary
        gross = basic + hra + da;
     
        printf("GROSS SALARY OF EMPLOYEE = %.2f", gross);
     
        return 0;
    }
    #include<stdio.h>
     
    void main()
    {
      int amount=2000,rate=20,time=2,si;
     
       si=(amount*rate*time)/100;
       
                  printf("You simple interest is %d",si);
                  
       
    }   
    #include<stdio.h>
     
    void main()
    {
      int i=0;
     
       for(i=0;i<10;i++)
       
                  printf("%d /n",i);
                  
       
    }   
    #include<stdio.h>
     
    void main()
    {
      int i=0;
     
      do
             {
                  printf("%d /n",i);
                   i++;
                }  
       while(i<11)
    }   
    #include<stdio.h>
     
    void main()
    {
      int i=0;
     
      while(i<10)
             {
                  printf("%d \n",i);
                   i++  ;
       }
    }   
    #include <stdio.h>
     
    void main()
    {
       goto patna;
       
       begusrai:
       printf("hey i am in begusrai \n");
       
     
       goto deoghar;
       
       patna:
       printf("now u r in patna \n");
       
       goto begusrai;
       deoghar:
         printf("now u r in deoghar \n");
    }
    #include <stdio.h>
     
    void main()
    {
       int i=0;
       
       loop:
       if(i<10)
       
       {
       printf("%d \n",i);
        i++;
      }
       goto loop;
    }
    #include<stdio.h>
     
    int main()
    {
       int n, i = 3, count, c;
     
       printf("Enter the number of prime numbers required\n");
       scanf("%d",&n);
     
       if ( n >= 1 )
       {
          printf("First %d prime numbers are :\n",n);
          printf("2\n");
       }
     
       for ( count = 2 ; count <= n ;  )
       {
          for ( c = 2 ; c <= i - 1 ; c++ )
          {
             if ( i%c == 0 )
                break;
          }
          if ( c == i )
          {
             printf("%d\n",i);
             count++;
          }
          i++;
       }
     
       return 0;
    }
    #include<stdio.h>
     
    int main()
    {
       int n, first = 0, second = 1, next, c;
     
       printf("Enter the number of terms\n");
       scanf("%d",&n);
     
       printf("First %d terms of Fibonacci series are :-\n",n);
     
       for ( c = 0 ; c < n ; c++ )
       {
          if ( c <= 1 )
             next = c;
          else
          {
             next = first + second;
             first = second;
             second = next;
          }
          printf("%d\n",next);
       }
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
      char ch;
     
      printf("Enter a character\n");
      scanf("%c", &ch);
     
      if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')
        printf("%c is a vowel.\n", ch);
      else
        printf("%c is not a vowel.\n", ch);
     
      return 0;
    }
    #include <stdio.h>
     
    int main()
    {
      int year;
     
      printf("Enter a year to check if it is a leap year\n");
      scanf("%d", &year);
     
      if ( year%400 == 0)
        printf("%d is a leap year.\n", year);
      else if ( year%100 == 0)
        printf("%d is not a leap year.\n", year);
      else if ( year%4 == 0 )
        printf("%d is a leap year.\n", year);
      else
        printf("%d is not a leap year.\n", year);  
     
      return 0;
    }
    #include <stdio.h>
     
    int main()
    {
      int c, n, fact = 1;
     
      printf("Enter a number to calculate it's factorial\n");
      scanf("%d", &n);
     
      for (c = 1; c <= n; c++)
        fact = fact * c;
     
      printf("Factorial of %d = %d\n", n, fact);
     
      return 0;
    }
    #include <stdio.h>
     
    int main() {
      int a, b, x, y, t, gcd, lcm;
     
      printf("Enter two integers\n");
      scanf("%d%d", &x, &y);
     
      a = x;
      b = y;
     
      while (b != 0) {
        t = b;
        b = a % b;
        a = t;
      }
     
      gcd = a;
      lcm = (x*y)/gcd;
     
      printf("Greatest common divisor of %d and %d = %d\n", x, y, gcd);
      printf("Least common multiple of %d and %d = %d\n", x, y, lcm);
     
      return 0;
    }
    #include <stdio.h>
     
    int main()
    {
      int n, c, k;
     
      printf("Enter an integer in decimal number system\n");
      scanf("%d", &n);
     
      printf("%d in binary number system is:\n", n);
     
      for (c = 31; c >= 0; c--)
      {
        k = n >> c;
     
        if (k & 1)
          printf("1");
        else
          printf("0");
      }
     
      printf("\n");
     
      return 0;
    }
    #include <stdio.h>
     
    long factorial(int);
    long find_ncr(int, int);
    long find_npr(int, int);
     
    int main()
    {
       int n, r;
       long ncr, npr;
     
       printf("Enter the value of n and r\n");
       scanf("%d%d",&n,&r);
     
       ncr = find_ncr(n, r);
       npr = find_npr(n, r);
     
       printf("%dC%d = %ld\n", n, r, ncr);
       printf("%dP%d = %ld\n", n, r, npr);
     
       return 0;
    }
     
    long find_ncr(int n, int r) {
       long result;
     
       result = factorial(n)/(factorial(r)*factorial(n-r));
     
       return result;
    }
     
    long find_npr(int n, int r) {
       long result;
     
       result = factorial(n)/factorial(n-r);
     
       return result;
    } 
     
    long factorial(int n) {
       int c;
       long result = 1;
     
       for (c = 1; c <= n; c++)
          result = result*c;
     
       return result;
    }
    #include <stdio.h>
     
    int main()
    {
       int n, reverse = 0;
     
       printf("Enter a number to reverse\n");
       scanf("%d", &n);
     
       while (n != 0)
       {
          reverse = reverse * 10;
          reverse = reverse + n%10;
          n       = n/10;
       }
     
       printf("Reverse of entered number is = %d\n", reverse);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int n, reverse = 0, temp;
     
       printf("Enter a number to check if it is a palindrome or not\n");
       scanf("%d",&n);
     
       temp = n;
     
       while( temp != 0 )
       {
          reverse = reverse * 10;
          reverse = reverse + temp%10;
          temp = temp/10;
       }
     
       if ( n == reverse )
          printf("%d is a palindrome number.\n", n);
       else
          printf("%d is not a palindrome number.\n", n);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int row, c, n, temp;
     
       printf("Enter the number of rows in pyramid of stars you wish to see ");
       scanf("%d",&n);
     
       temp = n;
     
       for ( row = 1 ; row <= n ; row++ )
       {
          for ( c = 1 ; c < temp ; c++ )
             printf(" ");
     
          temp--;
     
          for ( c = 1 ; c <= 2*row - 1 ; c++ )
             printf("*");
     
          printf("\n");
       }
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
      int n, c, k, space = 1;
     
      printf("Enter number of rows\n");
      scanf("%d", &n);
     
      space = n - 1;
     
      for (k = 1; k <= n; k++)
      {
        for (c = 1; c <= space; c++)
          printf(" ");
     
        space--;
     
        for (c = 1; c <= 2*k-1; c++)
          printf("*");
     
        printf("\n");
      }
     
      space = 1;
     
      for (k = 1; k <= n - 1; k++)
      {
        for (c = 1; c <= space; c++)
          printf(" ");
     
        space++;
     
        for (c = 1 ; c <= 2*(n-k)-1; c++)
          printf("*");
     
        printf("\n");
      }
     
      return 0;
    }
    #include <stdio.h>
     
    int power(int, int);
     
    int main()
    {
       int n, sum = 0, temp, remainder, digits = 0;
     
       printf("Input an integer\n");
       scanf("%d", &n);
     
       temp = n;
       // Count number of digits
       while (temp != 0) {
          digits++;
          temp = temp/10;
       }
     
       temp = n;
     
       while (temp != 0) {
          remainder = temp%10;
          sum = sum + power(remainder, digits);
          temp = temp/10;
       }
     
       if (n == sum)
          printf("%d is an Armstrong number.\n", n);
       else
          printf("%d is not an Armstrong number.\n", n);
     
       return 0;
    }
     
    int power(int n, int r) {
       int c, p = 1;
     
       for (c = 1; c <= r; c++) 
          p = p*n;
     
       return p;   
    }
    #include <stdio.h>
     
    int check_armstrong(int);
    int power(int, int);
     
    int main () {
       int c, a, b;
     
       printf("Input two integers\n");
       scanf("%d%d", &a, &b);
     
       for (c = a; c <= b; c++) {
          if (check_armstrong(c) == 1)
             printf("%d\n", c);
       }
     
       return 0;
    }
     
    int check_armstrong(int n) {
       long long sum = 0, temp;
       int remainder, digits = 0;
     
       temp = n;
     
       while (temp != 0) {
          digits++;
          temp = temp/10;
       }
     
       temp = n;
     
       while (temp != 0) {
          remainder = temp%10;
          sum = sum + power(remainder, digits);
          temp = temp/10;
       }
     
       if (n == sum)
          return 1;
       else
          return 0;
    }
     
    int  power(int n, int r) {
       int c, p = 1;
     
       for (c = 1; c <= r; c++) 
          p = p*n;
     
       return p;   
    }
    #include <stdio.h>
     
    int main()
    {
      int n, i,  c, a = 1;
     
      printf("Enter the number of rows of Floyd's triangle to print\n");
      scanf("%d", &n);
     
      for (i = 1; i <= n; i++)
      {
        for (c = 1; c <= i; c++)
        {
          printf("%d ",a);
          a++;
        }
        printf("\n");
      }
     
      return 0;
    }
    #include <stdio.h>
     
    long factorial(int);
     
    int main()
    {
       int i, n, c;
     
       printf("Enter the number of rows you wish to see in pascal triangle\n");
       scanf("%d",&n);
     
       for (i = 0; i < n; i++)
       {
          for (c = 0; c <= (n - i - 2); c++)
             printf(" ");
     
          for (c = 0 ; c <= i; c++)
             printf("%ld ",factorial(i)/(factorial(c)*factorial(i-c)));
     
          printf("\n");
       }
     
       return 0;
    }
     
    long factorial(int n)
    {
       int c;
       long result = 1;
     
       for (c = 1; c <= n; c++)
             result = result*c;
     
       return result;
    }
    #include <stdio.h>
    int addNumbers(int n);
    
    int main()
    {
        int num;
        printf("Enter a positive integer: ");
        scanf("%d", &num);
        printf("Sum = %d",addNumbers(num));
        return 0;
    }
    
    int addNumbers(int n)
    {
        if(n != 0)
            return n + addNumbers(n-1);
        else
            return n;
    }
    #include <stdio.h>
    long int multiplyNumbers(int n);
    
    int main()
    {
        int n;
        printf("Enter a positive integer: ");
        scanf("%d", &n);
        printf("Factorial of %d = %ld", n, multiplyNumbers(n));
        return 0;
    }
    long int multiplyNumbers(int n)
    {
        if (n >= 1)
            return n*multiplyNumbers(n-1);
        else
            return 1;
    }
    #include <stdio.h>
    int hcf(int n1, int n2);
    int main()
    {
       int n1, n2;
       printf("Enter two positive integers: ");
       scanf("%d %d", &n1, &n2);
    
       printf("G.C.D of %d and %d is %d.", n1, n2, hcf(n1,n2));
       return 0;
    }
    
    int hcf(int n1, int n2)
    {
        if (n2 != 0)
           return hcf(n2, n1%n2);
        else 
           return n1;
    }
    #include <stdio.h>
    
    int power(int n1, int n2);
    
    int main()
    {
        int base, powerRaised, result;
    
        printf("Enter base number: ");
        scanf("%d",&base);
    
        printf("Enter power number(positive integer): ");
        scanf("%d",&powerRaised);
    
        result = power(base, powerRaised);
    
        printf("%d^%d = %d", base, powerRaised, result);
        return 0;
    }
    
    int power(int base, int powerRaised)
    {
        if (powerRaised != 0)
            return (base*power(base, powerRaised-1));
        else
            return 1;
    }
    #include <stdio.h>
    #include <math.h>
    int convertBinaryToDecimal(long long n);
    
    int main()
    {
        long long n;
        printf("Enter a binary number: ");
        scanf("%lld", &n);
        printf("%lld in binary = %d in decimal", n, convertBinaryToDecimal(n));
        return 0;
    }
    
    int convertBinaryToDecimal(long long n)
    {
        int decimalNumber = 0, i = 0, remainder;
        while (n!=0)
        {
            remainder = n%10;
            n /= 10;
            decimalNumber += remainder*pow(2,i);
            ++i;
        }
        return decimalNumber;
    }
    #include <stdio.h>
    #include <math.h>
    
    int convertDecimalToOctal(int decimalNumber);
    int main()
    {
        int decimalNumber;
    
        printf("Enter a decimal number: ");
        scanf("%d", &decimalNumber);
    
        printf("%d in decimal = %d in octal", decimalNumber, convertDecimalToOctal(decimalNumber));
    
        return 0;
    }
    
    int convertDecimalToOctal(int decimalNumber)
    {
        int octalNumber = 0, i = 1;
    
        while (decimalNumber != 0)
        {
            octalNumber += (decimalNumber % 8) * i;
            decimalNumber /= 8;
            i *= 10;
        }
    
        return octalNumber;
    }
    #include <stdio.h>
    #include <math.h>
    
    int convertBinarytoOctal(long long binaryNumber);
    int main()
    {
        long long binaryNumber;
    
        printf("Enter a binary number: ");
        scanf("%lld", &binaryNumber);
    
        printf("%lld in binary = %d in octal", binaryNumber, convertBinarytoOctal(binaryNumber));
    
        return 0;
    }
    
    int convertBinarytoOctal(long long binaryNumber)
    {
        int octalNumber = 0, decimalNumber = 0, i = 0;
    
        while(binaryNumber != 0)
        {
            decimalNumber += (binaryNumber%10) * pow(2,i);
            ++i;
            binaryNumber/=10;
        }
    
        i = 1;
    
        while (decimalNumber != 0)
        {
            octalNumber += (decimalNumber % 8) * i;
            decimalNumber /= 8;
            i *= 10;
        }
    
        return octalNumber;
    }
    #include <stdio.h>
    int main(){
       int* pc;
       int c;
       c=22;
       printf("Address of c:%u\n",&c);
       printf("Value of c:%d\n\n",c);
       pc=&c;
       printf("Address of pointer pc:%u\n",pc);
       printf("Content of pointer pc:%d\n\n",*pc);
       c=11;
       printf("Address of pointer pc:%u\n",pc);
       printf("Content of pointer pc:%d\n\n",*pc);
       *pc=2;
       printf("Address of c:%u\n",&c);
       printf("Value of c:%d\n\n",c);
       return 0;
    }
    #include <stdio.h>
    int main(){
       int* pc;
       int c;
       c=22;
       printf("Address of c:%u\n",&c);
       printf("Value of c:%d\n\n",c);
       pc=&c;
       printf("Address of pointer pc:%u\n",pc);
       printf("Content of pointer pc:%d\n\n",*pc);
       c=11;
       printf("Address of pointer pc:%u\n",pc);
       printf("Content of pointer pc:%d\n\n",*pc);
       *pc=2;
       printf("Address of c:%u\n",&c);
       printf("Value of c:%d\n\n",c);
       return 0;
    }
    #include <stdio.h>
    int main(){
       int* pc;
       int c;
       c=22;
       printf("Address of c:%u\n",&c);
       printf("Value of c:%d\n\n",c);
       pc=&c;
       printf("Address of pointer pc:%u\n",pc);
       printf("Content of pointer pc:%d\n\n",*pc);
       c=11;
       printf("Address of pointer pc:%u\n",pc);
       printf("Content of pointer pc:%d\n\n",*pc);
       *pc=2;
       printf("Address of c:%u\n",&c);
       printf("Value of c:%d\n\n",c);
       return 0;
    }
    #include <stdio.h>
    struct student
    {
        char name[50];
        int roll;
        float marks;
    } s;
    
    int main()
    {
        printf("Enter information:\n");
    
        printf("Enter name: ");
        scanf("%s", s.name);
    
        printf("Enter roll number: ");
        scanf("%d", &s.roll);
    
        printf("Enter marks: ");
        scanf("%f", &s.marks);
    
    
        printf("Displaying Information:\n");
    
        printf("Name: ");
        puts(s.name);
    
        printf("Roll number: %d\n",s.roll);
    
        printf("Marks: %.1f\n", s.marks);
    
        return 0;
    }
    #include <stdio.h>
    struct student
    {
        char name[50];
        int roll;
        float marks;
    } s[10];
    
    int main()
    {
        int i;
    
        printf("Enter information of students:\n");
    
        // storing information
        for(i=0; i<10; ++i)
        {
            s[i].roll = i+1;
    
            printf("\nFor roll number%d,\n",s[i].roll);
    
            printf("Enter name: ");
            scanf("%s",s[i].name);
    
            printf("Enter marks: ");
            scanf("%f",&s[i].marks);
    
            printf("\n");
        }
    
        printf("Displaying Information:\n\n");
        // displaying information
        for(i=0; i<10; ++i)
        {
            printf("\nRoll number: %d\n",i+1);
            printf("Name: ");
            puts(s[i].name);
            printf("Marks: %.1f",s[i].marks);
            printf("\n");
        }
        return 0;
    }
    #include <stdio.h>
    #include<stdlib.h>
    
    struct course
    {
       int marks;
       char subject[30];
    };
    
    int main()
    {
       struct course *ptr;
       int i, noOfRecords;
       printf("Enter number of records: ");
       scanf("%d", &noOfRecords);
    
       // Allocates the memory for noOfRecords structures with pointer ptr pointing to the base address.
       ptr = (struct course*) malloc (noOfRecords * sizeof(struct course));
    
       for(i = 0; i < noOfRecords; ++i)
       {
           printf("Enter name of the subject and marks respectively:\n");
           scanf("%s %d", &(ptr+i)->subject, &(ptr+i)->marks);
       }
    
       printf("Displaying Information:\n");
    
       for(i = 0; i < noOfRecords ; ++i)
           printf("%s\t%d\n", (ptr+i)->subject, (ptr+i)->marks);
    
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int first, second, *p, *q, sum;
     
       printf("Enter two integers to add\n");
       scanf("%d%d", &first, &second);
     
       p = &first;
       q = &second;
     
       sum = *p + *q;
     
       printf("Sum of entered numbers = %d\n",sum);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
      int array[100], maximum, size, c, location = 1;
     
      printf("Enter the number of elements in array\n");
      scanf("%d", &size);
     
      printf("Enter %d integers\n", size);
     
      for (c = 0; c < size; c++)
        scanf("%d", &array[c]);
     
      maximum = array[0];
     
      for (c = 1; c < size; c++)
      {
        if (array[c] > maximum)
        {
           maximum  = array[c];
           location = c+1;
        }
      }
     
      printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
      return 0;
    }
    #include <stdio.h>
     
    int main() 
    {
        int array[100], minimum, size, c, location = 1;
     
        printf("Enter the number of elements in array\n");
        scanf("%d",&size);
     
        printf("Enter %d integers\n", size);
     
        for ( c = 0 ; c < size ; c++ )
            scanf("%d", &array[c]);
     
        minimum = array[0];
     
        for ( c = 1 ; c < size ; c++ ) 
        {
            if ( array[c] < minimum ) 
            {
               minimum = array[c];
               location = c+1;
            }
        } 
     
        printf("Minimum element is present at location %d and it's value is %d.\n", location, minimum);
        return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int array[100], search, c, n;
     
       printf("Enter the number of elements in array\n");
       scanf("%d",&n);
     
       printf("Enter %d integer(s)\n", n);
     
       for (c = 0; c < n; c++)
          scanf("%d", &array[c]);
     
       printf("Enter the number to search\n");
       scanf("%d", &search);
     
       for (c = 0; c < n; c++)
       {
          if (array[c] == search)     /* if required element found */
          {
             printf("%d is present at location %d.\n", search, c+1);
             break;
          }
       }
       if (c == n)
          printf("%d is not present in array.\n", search);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int c, first, last, middle, n, search, array[100];
     
       printf("Enter number of elements\n");
       scanf("%d",&n);
     
       printf("Enter %d integers\n", n);
     
       for (c = 0; c < n; c++)
          scanf("%d",&array[c]);
     
       printf("Enter value to find\n");
       scanf("%d", &search);
     
       first = 0;
       last = n - 1;
       middle = (first+last)/2;
     
       while (first <= last) {
          if (array[middle] < search)
             first = middle + 1;    
          else if (array[middle] == search) {
             printf("%d found at location %d.\n", search, middle+1);
             break;
          }
          else
             last = middle - 1;
     
          middle = (first + last)/2;
       }
       if (first > last)
          printf("Not found! %d is not present in the list.\n", search);
     
       return 0;   
    }
    #include <stdio.h>
     
    int main()
    {
       int n, c, d, a[100], b[100];
     
       printf("Enter the number of elements in array\n");
       scanf("%d", &n);
     
       printf("Enter the array elements\n");
     
       for (c = 0; c < n ; c++)
          scanf("%d", &a[c]);
     
       /*
        * Copying elements into array b starting from end of array a
        */
     
       for (c = n - 1, d = 0; c >= 0; c--, d++)
          b[d] = a[c];
     
       /*
        * Copying reversed array into original.
        * Here we are modifying original array, this is optional.
        */
     
       for (c = 0; c < n; c++)
          a[c] = b[c];
     
       printf("Reverse array is\n");
     
       for (c = 0; c < n; c++)
          printf("%d\n", a[c]);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int array[100], position, c, n, value;
     
       printf("Enter number of elements in array\n");
       scanf("%d", &n);
     
       printf("Enter %d elements\n", n);
     
       for (c = 0; c < n; c++)
          scanf("%d", &array[c]);
     
       printf("Enter the location where you wish to insert an element\n");
       scanf("%d", &position);
     
       printf("Enter the value to insert\n");
       scanf("%d", &value);
     
       for (c = n - 1; c >= position - 1; c--)
          array[c+1] = array[c];
     
       array[position-1] = value;
     
       printf("Resultant array is\n");
     
       for (c = 0; c <= n; c++)
          printf("%d\n", array[c]);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int array[100], position, c, n;
     
       printf("Enter number of elements in array\n");
       scanf("%d", &n);
     
       printf("Enter %d elements\n", n);
     
       for ( c = 0 ; c < n ; c++ )
          scanf("%d", &array[c]);
     
       printf("Enter the location where you wish to delete element\n");
       scanf("%d", &position);
     
       if ( position >= n+1 )
          printf("Deletion not possible.\n");
       else
       {
          for ( c = position - 1 ; c < n - 1 ; c++ )
             array[c] = array[c+1];
     
          printf("Resultant array is\n");
     
          for( c = 0 ; c < n - 1 ; c++ )
             printf("%d\n", array[c]);
       }
     
       return 0;
    }
    #include <stdio.h>
     
    void merge(int [], int, int [], int, int []);
     
    int main() {
      int a[100], b[100], m, n, c, sorted[200];
     
      printf("Input number of elements in first array\n");
      scanf("%d", &m);
     
      printf("Input %d integers\n", m);
      for (c = 0; c < m; c++) {
        scanf("%d", &a[c]);
      }
     
      printf("Input number of elements in second array\n");
      scanf("%d", &n);
     
      printf("Input %d integers\n", n);
      for (c = 0; c < n; c++) {
        scanf("%d", &b[c]);
      }
     
      merge(a, m, b, n, sorted);
     
      printf("Sorted array:\n");
     
      for (c = 0; c < m + n; c++) {
        printf("%d\n", sorted[c]);
      }
     
      return 0;
    }
     
    void merge(int a[], int m, int b[], int n, int sorted[]) {
      int i, j, k;
     
      j = k = 0;
     
      for (i = 0; i < m + n;) {
        if (j < m && k < n) {
          if (a[j] < b[k]) {
            sorted[i] = a[j];
            j++;
          }
          else {
            sorted[i] = b[k];
            k++;
          }
          i++;
        }
        else if (j == m) {
          for (; i < m + n;) {
            sorted[i] = b[k];
            k++;
            i++;
          }
        }
        else {
          for (; i < m + n;) {
            sorted[i] = a[j];
            j++;
            i++;
          }
        }
      }
    }
    #include <stdio.h>
     
    int main()
    {
      int array[100], n, c, d, swap;
     
      printf("Enter number of elements\n");
      scanf("%d", &n);
     
      printf("Enter %d integers\n", n);
     
      for (c = 0; c < n; c++)
        scanf("%d", &array[c]);
     
      for (c = 0 ; c < ( n - 1 ); c++)
      {
        for (d = 0 ; d < n - c - 1; d++)
        {
          if (array[d] > array[d+1]) /* For decreasing order use < */
          {
            swap       = array[d];
            array[d]   = array[d+1];
            array[d+1] = swap;
          }
        }
      }
     
      printf("Sorted list in ascending order:\n");
     
      for ( c = 0 ; c < n ; c++ )
         printf("%d\n", array[c]);
     
      return 0;
    }
     
    #include <stdio.h>
     
    int main()
    {
      int n, array[1000], c, d, t;
     
      printf("Enter number of elements\n");
      scanf("%d", &n);
     
      printf("Enter %d integers\n", n);
     
      for (c = 0; c < n; c++) {
        scanf("%d", &array[c]);
      }
     
      for (c = 1 ; c <= n - 1; c++) {
        d = c;
     
        while ( d > 0 && array[d] < array[d-1]) {
          t          = array[d];
          array[d]   = array[d-1];
          array[d-1] = t;
     
          d--;
        }
      }
     
      printf("Sorted list in ascending order:\n");
     
      for (c = 0; c <= n - 1; c++) {
        printf("%d\n", array[c]);
      }
     
      return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int array[100], n, c, d, position, swap;
     
       printf("Enter number of elements\n");
       scanf("%d", &n);
     
       printf("Enter %d integers\n", n);
     
       for ( c = 0 ; c < n ; c++ )
          scanf("%d", &array[c]);
     
       for ( c = 0 ; c < ( n - 1 ) ; c++ )
       {
          position = c;
     
          for ( d = c + 1 ; d < n ; d++ )
          {
             if ( array[position] > array[d] )
                position = d;
          }
          if ( position != c )
          {
             swap = array[c];
             array[c] = array[position];
             array[position] = swap;
          }
       }
     
       printf("Sorted list in ascending order:\n");
     
       for ( c = 0 ; c < n ; c++ )
          printf("%d\n", array[c]);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int array[100], n, c, d, position, swap;
     
       printf("Enter number of elements\n");
       scanf("%d", &n);
     
       printf("Enter %d integers\n", n);
     
       for ( c = 0 ; c < n ; c++ )
          scanf("%d", &array[c]);
     
       for ( c = 0 ; c < ( n - 1 ) ; c++ )
       {
          position = c;
     
          for ( d = c + 1 ; d < n ; d++ )
          {
             if ( array[position] > array[d] )
                position = d;
          }
          if ( position != c )
          {
             swap = array[c];
             array[c] = array[position];
             array[position] = swap;
          }
       }
     
       printf("Sorted list in ascending order:\n");
     
       for ( c = 0 ; c < n ; c++ )
          printf("%d\n", array[c]);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int m, n, c, d, first[10][10], second[10][10], sum[10][10];
     
       printf("Enter the number of rows and columns of matrix\n");
       scanf("%d%d", &m, &n);
       printf("Enter the elements of first matrix\n");
     
       for (c = 0; c < m; c++)
          for (d = 0; d < n; d++)
             scanf("%d", &first[c][d]);
     
       printf("Enter the elements of second matrix\n");
     
       for (c = 0; c < m; c++)
          for (d = 0 ; d < n; d++)
                scanf("%d", &second[c][d]);
     
       printf("Sum of entered matrices:-\n");
     
       for (c = 0; c < m; c++) {
          for (d = 0 ; d < n; d++) {
             sum[c][d] = first[c][d] + second[c][d];
             printf("%d\t", sum[c][d]);
          }
          printf("\n");
       }
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int m, n, c, d, first[10][10], second[10][10], difference[10][10];
     
       printf("Enter the number of rows and columns of matrix\n");
       scanf("%d%d", &m, &n);
       printf("Enter the elements of first matrix\n");
     
       for (c = 0; c < m; c++)
         for (d = 0 ; d < n; d++)
           scanf("%d", &first[c][d]);
     
       printf("Enter the elements of second matrix\n");
     
       for (c = 0; c < m; c++)
         for (d = 0; d < n; d++)
             scanf("%d", &second[c][d]);
     
       printf("Difference of entered matrices:-\n");
     
       for (c = 0; c < m; c++) {
         for (d = 0; d < n; d++) {
           difference[c][d] = first[c][d] - second[c][d];
           printf("%d\t",difference[c][d]);
         } 
         printf("\n");
       }
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       int m, n, c, d, matrix[10][10], transpose[10][10];
     
       printf("Enter the number of rows and columns of matrix\n");
       scanf("%d%d", &m, &n);
     
       printf("Enter the elements of matrix\n");
     
       for (c = 0; c < m; c++)
          for(d = 0; d < n; d++)
             scanf("%d",&matrix[c][d]);
     
       for (c = 0; c < m; c++)
          for( d = 0 ; d < n ; d++ )
             transpose[d][c] = matrix[c][d];
     
       printf("Transpose of entered matrix :-\n");
     
       for (c = 0; c < n; c++) {
          for (d = 0; d < m; d++)
             printf("%d\t",transpose[c][d]);
          printf("\n");
       }
     
       return 0;
    #include <stdio.h>
     
    int main()
    {
      int m, n, p, q, c, d, k, sum = 0;
      int first[10][10], second[10][10], multiply[10][10];
     
      printf("Enter the number of rows and columns of first matrix\n");
      scanf("%d%d", &m, &n);
      printf("Enter the elements of first matrix\n");
     
      for (c = 0; c < m; c++)
        for (d = 0; d < n; d++)
          scanf("%d", &first[c][d]);
     
      printf("Enter the number of rows and columns of second matrix\n");
      scanf("%d%d", &p, &q);
     
      if (n != p)
        printf("Matrices with entered orders can't be multiplied with each other.\n");
      else
      {
        printf("Enter the elements of second matrix\n");
     
        for (c = 0; c < p; c++)
          for (d = 0; d < q; d++)
            scanf("%d", &second[c][d]);
     
        for (c = 0; c < m; c++) {
          for (d = 0; d < q; d++) {
            for (k = 0; k < p; k++) {
              sum = sum + first[c][k]*second[k][d];
            }
     
            multiply[c][d] = sum;
            sum = 0;
          }
        }
     
        printf("Product of entered matrices:-\n");
     
        for (c = 0; c < m; c++) {
          for (d = 0; d < q; d++)
            printf("%d\t", multiply[c][d]);
     
          printf("\n");
        }
      }
     
      return 0;
    }
    #include <stdio.h>
     
    int main()
    {
        char array[100];
     
        printf("Enter a string\n");
        scanf("%s", array);
     
        printf("You entered the string %s\n",array);
        return 0;
    }
    #include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char a[100];
       int length;
     
       printf("Enter a string to calculate it's length\n");
       gets(a);
     
       length = strlen(a);
     
       printf("Length of entered string is = %d\n",length);
     
       return 0;
    }
    include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char a[100], b[100];
     
       printf("Enter the first string\n");
       gets(a);
     
       printf("Enter the second string\n");
       gets(b);
     
       if (strcmp(a,b) == 0)
          printf("Entered strings are equal.\n");
       else
          printf("Entered strings are not equal.\n");
     
       return 0;
    }
    #include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char source[1000], destination[1000];
     
       printf("Input a string\n");
       gets(source);
     
       strcpy(destination, source);
     
       printf("Source string:      \"%s\"\n", source);
       printf("Destination string: \"%s\"\n", destination);
     
       return 0;
    }
    #include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char a[1000], b[1000];
     
       printf("Enter the first string\n");
       gets(a);
     
       printf("Enter the second string\n");
       gets(b);
     
       strcat(a,b);
     
       printf("String obtained on concatenation is %s\n",a);
     
       return 0;
    }
    #include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char arr[100];
     
       printf("Enter a string to reverse\n");
       gets(arr);
     
       strrev(arr);
     
       printf("Reverse of entered string is \n%s\n",arr);
     
       return 0;
    }
    #include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char a[100], b[100];
     
       printf("Enter the string to check if it is a palindrome\n");
       gets(a);
     
       strcpy(b,a);
       strrev(b);
     
       if (strcmp(a,b) == 0)
          printf("Entered string is a palindrome.\n");
       else
          printf("Entered string is not a palindrome.\n");
     
       return 0;
    }
    #include <stdio.h>
     
    int toString(char []);
     
    int main()
    {
      char a[100];
      int n;
     
      printf("Input a valid string to convert to integer\n");
      scanf("%s", a);
     
      n = toString(a);
     
      printf("String  = %s\nInteger = %d\n", a, n);
     
      return 0;
    }
     
    int toString(char a[]) {
      int c, sign, offset, n;
     
      if (a[0] == '-') {  // Handle negative integers
        sign = -1;
      }
     
      if (sign == -1) {  // Set starting position to convert
        offset = 1;
      }
      else {
        offset = 0;
      }
     
      n = 0;
     
      for (c = offset; a[c] != '\0'; c++) {
        n = n * 10 + a[c] - '0';
      }
     
      if (sign == -1) {
        n = -n;
      }
     
      return n;
    }
    #include <stdio.h>
    #include <string.h>
     
    int check_vowel(char);
     
    int main()
    {
      char s[100], t[100];
      int i, j = 0;
     
      printf("Enter a string to delete vowels\n");
      gets(s);
     
      for(i = 0; s[i] != '\0'; i++) {
        if(check_vowel(s[i]) == 0) {       //not a vowel
          t[j] = s[i];
          j++;
        }
      }
     
      t[j] = '\0';
     
      strcpy(s, t);    //We are changing initial string
     
      printf("String after deleting vowels: %s\n", s);
     
      return 0;
    }
     
     
    int check_vowel(char c)
    {
      switch(c) {
        case 'a':
        case 'A':
        case 'e':
        case 'E':
        case 'i':
        case 'I':
        case 'o':
        case 'O':
        case 'u':
        case 'U':
          return 1;
        default:
          return 0;
      }
    }
    #include <stdio.h>
     
    int main() 
    {
       char string[1000], sub[1000];
       int position, length, c = 0;
     
       printf("Input a string\n");
       gets(string);
     
       printf("Enter the position and length of substring\n");
       scanf("%d%d", &position, &length);
     
       while (c < length) {
          sub[c] = string[position+c-1];
          c++;
       }
       sub[c] = '\0';
     
       printf("Required substring is \"%s\"\n", sub);
     
       return 0;
    }
    #include <stdio.h>
    #include <string.h>
     
    int check_subsequence (char [], char[]);
     
    int main () {
       int flag;
       char s1[1000], s2[1000];
     
       printf("Input first string\n");
       gets(s1);
     
       printf("Input second string\n");
       gets(s2);
     
       /** Passing smaller length string first */
     
       if (strlen(s1) < strlen(s2))
          flag = check_subsequence(s1, s2);
       else
          flag = check_subsequence(s2, s1);
     
       if (flag)
          printf("YES\n");
       else
          printf("NO\n");
     
       return 0;
    }
     
    int check_subsequence (char a[], char b[]) {
       int c, d;
     
       c = d = 0;
     
       while (a[c] != '\0') {
          while ((a[c] != b[d]) && b[d] != '\0') {
             d++;
          }
          if (b[d] == '\0')
             break;
          d++;
          c++;
       }
       if (a[c] == '\0')
          return 1;
       else
          return 0;
    }
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
     
    int main()
    {
       char ch, input[100], output[100];
       int no[26] = {0}, n, c, t, x;
     
       printf("Enter some text\n");
       scanf("%s", input);
     
       n = strlen(input);
     
       /** Store how many times characters (a to z) 
          appears in input string in array */
     
       for (c = 0; c < n; c++)
       {
          ch = input[c] - 'a';
          no[ch]++;
       }
     
       t = 0;
     
       /** Insert characters a to z in output string 
           that many number of times as they appear 
           in input string */
     
       for (ch = 'a'; ch <= 'z'; ch++)
       {
          x = ch - 'a';
     
          for (c = 0; c < no[x]; c++)
          {
             output[t] = ch;
             t++;
          }
       }
       output[t] = '\0';
     
       printf("%s\n", output);
     
       return 0;
    }
    #include <stdio.h>
     
    int main()
    {
       char text[1000], blank[1000];
       int c = 0, d = 0;
     
       printf("Enter some text\n");
       gets(text);
     
       while (text[c] != '\0') {
          if (text[c] == ' ') {
             int temp = c + 1;
             if (text[temp] != '\0') {
                while (text[temp] == ' ' && text[temp] != '\0') {
                   if (text[temp] == ' ') {
                      c++;
                   }  
                   temp++;
                }
             }
          }
          blank[d] = text[c];
          c++;
          d++;
       }
     
       blank[d] = '\0';
     
       printf("Text after removing blanks\n%s\n", blank);
     
       return 0;
    }
    #include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char string[1000];
     
       printf("Input a string to convert to lower case\n");
       gets(string);
     
       printf("Input string in lower case: \"%s\"\n",strlwr(string));
     
       return  0;
    }
    #include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char string[1000];
     
       printf("Input a string to convert to upper case\n");
       gets(string);
     
       printf("Input string in upper case: \"%s\"\n",strupr(string));
     
       return  0;
    }
    #include <stdio.h>
     
    void upper_string(char []);
     
    int main()
    {
       char string[100];
     
       printf("Enter a string to convert it into upper case\n");
       gets(string);
     
       upper_string(string);
     
       printf("Entered string in upper case is \"%s\"\n", string);
     
       return 0;
    }
     
    void upper_string(char s[]) {
       int c = 0;
     
       while (s[c] != '\0') {
          if (s[c] >= 'a' && s[c] <= 'z') {
             s[c] = s[c] - 32;
          }
          c++;
       }
    }
    #include <stdio.h>
     
    void lower_string(char []);
     
    int main()
    {
       char string[100];
     
       printf("Enter a string to convert it into lower case\n");
       gets(string);
     
       lower_string(string);
     
       printf("Entered string in lower case is \"%s\"\n", string);
     
       return 0;
    }
     
    void lower_string(char s[]) {
       int c = 0;
     
       while (s[c] != '\0') {
          if (s[c] >= 'A' && s[c] <= 'Z') {
             s[c] = s[c] + 32;
          }
          c++;
       }
    }
    #include <stdio.h>
    #include <string.h>
     
    int main()
    {
       char string[100];
       int c = 0, count[26] = {0};
     
       printf("Enter a string\n");
       gets(string);
     
       while (string[c] != '\0')
       {
          /** Considering characters from 'a' to 'z' only
              and ignoring others */
     
          if (string[c] >= 'a' && string[c] <= 'z') 
             count[string[c]-'a']++;
     
          c++;
       }
     
       for (c = 0; c < 26; c++)
       {
          /** Printing only those characters 
              whose count is at least 1 */
     
          if (count[c] != 0)
             printf("%c occurs %d times in the entered string.\n",c+'a',count[c]);
       }
     
       return 0;
    }
    #include <stdio.h>
     
    int check_anagram(char [], char []);
     
    int main()
    {
       char a[100], b[100];
       int flag;
     
       printf("Enter first string\n");
       gets(a);
     
       printf("Enter second string\n");
       gets(b);
     
       flag = check_anagram(a, b);
     
       if (flag == 1)
          printf("\"%s\" and \"%s\" are anagrams.\n", a, b);
       else
          printf("\"%s\" and \"%s\" are not anagrams.\n", a, b);
     
       return 0;
    }
     
    int check_anagram(char a[], char b[])
    {
       int first[26] = {0}, second[26] = {0}, c = 0;
     
       while (a[c] != '\0')
       {
          first[a[c]-'a']++;
          c++;
       }
     
       c = 0;
     
       while (b[c] != '\0')
       {
          second[b[c]-'a']++;
          c++;
       }
     
       for (c = 0; c < 26; c++)
       {
          if (first[c] != second[c])
             return 0;
       }
     
       return 1;
    }
    #include <stdio.h>
    #include <stdlib.h>
     
    int main()
    {
       char ch, file_name[25];
       FILE *fp;
     
       printf("Enter the name of file you wish to see\n");
       gets(file_name);
     
       fp = fopen(file_name,"r"); // read mode
     
       if( fp == NULL )
       {
          perror("Error while opening the file.\n");
          exit(EXIT_FAILURE);
       }
     
       printf("The contents of %s file are :\n", file_name);
     
       while( ( ch = fgetc(fp) ) != EOF )
          printf("%c",ch);
     
       fclose(fp);
       return 0;
    }
    #include <stdio.h>
    #include <stdlib.h>
     
    int main()
    {
       char ch, source_file[20], target_file[20];
       FILE *source, *target;
     
       printf("Enter name of file to copy\n");
       gets(source_file);
     
       source = fopen(source_file, "r");
     
       if( source == NULL )
       {
          printf("Press any key to exit...\n");
          exit(EXIT_FAILURE);
       }
     
       printf("Enter name of target file\n");
       gets(target_file);
     
       target = fopen(target_file, "w");
     
       if( target == NULL )
       {
          fclose(source);
          printf("Press any key to exit...\n");
          exit(EXIT_FAILURE);
       }
     
       while( ( ch = fgetc(source) ) != EOF )
          fputc(ch, target);
     
       printf("File copied successfully.\n");
     
       fclose(source);
       fclose(target);
     
       return 0;
    }
    #include <stdio.h>
    #include <stdlib.h>
     
    int main()
    {
       FILE *fs1, *fs2, *ft;
     
       char ch, file1[20], file2[20], file3[20];
     
       printf("Enter name of first file\n");
       gets(file1);
     
       printf("Enter name of second file\n");
       gets(file2);
     
       printf("Enter name of file which will store contents of two files\n");
       gets(file3);
     
       fs1 = fopen(file1,"r");
       fs2 = fopen(file2,"r");
     
       if( fs1 == NULL || fs2 == NULL )
       {
          perror("Error ");
          printf("Press any key to exit...\n");
          getch();
          exit(EXIT_FAILURE);
       }
     
       ft = fopen(file3,"w");
     
       if( ft == NULL )
       {
          perror("Error ");
          printf("Press any key to exit...\n");
          exit(EXIT_FAILURE);
       }
     
       while( ( ch = fgetc(fs1) ) != EOF )
          fputc(ch,ft);
     
       while( ( ch = fgetc(fs2) ) != EOF )
          fputc(ch,ft);
     
       printf("Two files were merged into %s file successfully.\n",file3);
     
       fclose(fs1);
       fclose(fs2);
       fclose(ft);
     
       return 0;
    }
    #include<stdio.h>
     
    main()
    {
       int status;
       char file_name[25];
     
       printf("Enter the name of file you wish to delete\n");
       gets(file_name);
     
       status = remove(file_name);
     
       if( status == 0 )
          printf("%s file deleted successfully.\n",file_name);
       else
       {
          printf("Unable to delete the file\n");
          perror("Error");
       }
     
       return 0;
    }
    #include <stdio.h>
    #include <stdlib.h>
     
    int main() {
      int c, n;
     
      printf("Ten random numbers in [1,100]\n");
     
      for (c = 1; c <= 10; c++) {
        n = rand() % 100 + 1;
        printf("%d\n", n);
      }
     
      return 0;
    }
    #include <stdio.h>
     
    struct complex
    {
       int real, img;
    };
     
    int main()
    {
       struct complex a, b, c;
     
       printf("Enter a and b where a + ib is the first complex number.\n");
       printf("a = ");
       scanf("%d", &a.real);
       printf("b = ");
       scanf("%d", &a.img);
       printf("Enter c and d where c + id is the second complex number.\n");
       printf("c = ");
       scanf("%d", &b.real);
       printf("d = ");
       scanf("%d", &b.img);
     
       c.real = a.real + b.real;
       c.img = a.img + b.img;
     
       if ( c.img >= 0 )
          printf("Sum of two complex numbers = %d + %di\n", c.real, c.img);
       else
          printf("Sum of two complex numbers = %d %di\n", c.real, c.img);
     
       return 0;
    }

    #include <stdio.h>
    #include <stdlib.h>  /* For exit() function */
    int main()
    {
       char sentence[1000];
       FILE *fptr;
    
       fptr = fopen("program.txt", "w");
       if(fptr == NULL)
       {
          printf("Error!");
          exit(1);
       }
       
       printf("Enter a sentence:\n");
       gets(sentence);
    
       fprintf(fptr,"%s", sentence);
       fclose(fptr);
    
       return 0;
    }
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        int num, i, *ptr, sum = 0;
    
        printf("Enter number of elements: ");
        scanf("%d", &num);
    
        ptr = (int*) malloc(num * sizeof(int));  //memory allocated using malloc
        if(ptr == NULL)                     
        {
            printf("Error! memory not allocated.");
            exit(0);
        }
    
        printf("Enter elements of array: ");
        for(i = 0; i < num; ++i)
        {
            scanf("%d", ptr + i);
            sum += *(ptr + i);
        }
    
        printf("Sum = %d", sum);
        free(ptr);
        return 0;
    }
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        int num, i, *ptr, sum = 0;
        printf("Enter number of elements: ");
        scanf("%d", &num);
    
        ptr = (int*) calloc(num, sizeof(int));
        if(ptr == NULL)
        {
            printf("Error! memory not allocated.");
            exit(0);
        }
    
        printf("Enter elements of array: ");
        for(i = 0; i < num; ++i)
        {
            scanf("%d", ptr + i);
            sum += *(ptr + i);
        }
    
        printf("Sum = %d", sum);
        free(ptr);
        return 0;
    }

    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        int *ptr, i , n1, n2;
        printf("Enter size of array: ");
        scanf("%d", &n1);
    
        ptr = (int*) malloc(n1 * sizeof(int));
    
        printf("Address of previously allocated memory: ");
        for(i = 0; i < n1; ++i)
             printf("%u\t",ptr + i);
    
        printf("\nEnter new size of array: ");
        scanf("%d", &n2);
        ptr = realloc(ptr, n2);
        for(i = 0; i < n2; ++i)
             printf("%u\t", ptr + i);
        return 0;
    }
    #include <stdio.h>
    #include <stdlib.h>
     
    int main()
    {
       system("C:\\WINDOWS\\System32\\shutdown /s");
     
       return 0;
    }
рдЖрдкрдХो рдЖрд░्рдЯिрдХрд▓ рдХैрд╕ा рд▓рдЧा? рдЕрдкрдиी рд░ाрдп рдЕрд╡рд╢्рдп рджें
Please don't Add spam links,
if you want backlinks from my blog contact me on rakeshmgs.in@gmail.com