Swap Two Numbers in C

  Swap Two Numbers in C In this example, you will learn to swap two numbers in C programming using two different techniques. To understand this example, you should have the knowledge of the following C programming topics: C Data Types C Programming Operators C Input Output (I/O) Swap Numbers Using Temporary Variable # include <stdio.h> int main () { double first, second, temp; printf ( "Enter first number: " ); scanf ( "%lf" , &first); printf ( "Enter second number: " ); scanf ( "%lf" , &second); // Value of first is assigned to temp temp = first; // Value of second is assigned to first first = second; // Value of temp (initial value of first) is assigned to second second = temp; printf ( "\nAfter swapping, firstNumber = %.2lf\n" , first); printf ( "After swapping, secondNumber = %.2lf" , second); return 0 ; } Output ...

ANSI-Color-Code in c language

ANSI-Color-Code in c language :

#include<stdio.h>

int main()

{

    printf("\033[0;31m");

    printf("hello to all");

    printf("\033[0m");

    printf("\033[0;35m");

    printf("\nthis is a c program from which see how the colour coding (ANSI Colors) works ");

    printf("\033[0m");

    printf("\033[1;36m");

    printf("\n\nfollow these steps :\nfirstly you must now about the colour codes ");

    printf("\033[0m");

  printf("\033[0;34m");

  printf("\nthese are some ansi codes for colour changing::::");

    printf("\033[0m");

    printf("\033[0;35m");

  printf("\nplease see the code how i use the colour code");

  printf("\033[0m");

  printf("\033[0;31m");

  printf("\nbecause the compiler tries also to run the syntax in printf statement");

    printf("\033[0m");

    printf("\033[0;31m");

    printf("\n\nred==[0;31m");

    printf("\033[0m");

    printf("\033[1;31m");

    printf("\nbold red==[1;31m");

    printf("\033[0m");

    printf("\033[0;32m");

    printf("\ngreen==[0;32m");

    printf("\033[0m");

    printf("\033[1;32m");

    printf("\nbold green==[1;32m");

    printf("\033[0m");

    printf("\033[0;33m");

    printf("\nyellow==[0;33m");

    printf("\033[0m");

    printf("\033[1;33m");

    printf("\nbold yellow==[1;33m");

    printf("\033[0m");

    printf("\033[0;34m");

    printf("\nblue==[0,34m");

    printf("\033[0m");

    printf("\033[1;34m");

    printf("\nbold blue==[1;34m");

    printf("\033[0m");

    printf("\033[0;35m");

    printf("\nmagenta==[0;35m");

    printf("\033[0m");

    printf("\033[1;35m");

    printf("\nbold magenta==[1;35m");

    printf("\033[0m");

    printf("\033[0;36m");

    printf("\ncyan==[0;36m");

    printf("\033[0m");

    printf("\033[1;36m");

    printf("\nbold cyan==[1;36m");

    printf("\033[0m");

    printf("\033[0m");

    printf("\n reset or to end the change in colour==[0m");

    printf("\033[0m");

    printf("\033[0;34m");

    printf("\nby using this colour coding scheme you can make your code look good");

    printf("\033[0m");

    printf("\033[1;32m");

    printf("\nthank you ");

    printf("\033[0m");

}

Code in Terminal :

















Output :





Comments

Popular posts from this blog

Find GCD of two Numbers in C

Swap Two Numbers in C