Posts

THE LEAD GAME solution in C language.- Codechef

  THE LEAD GAME Problem Code: TLG The game of billiards involves two players knocking 3 balls around on a green baize table. Well, there is more to it, but for our purposes this is sufficient. The game consists of several rounds and in each round both players obtain a score, based on how well they played. Once all the rounds have been played, the total score of each player is determined by adding up the scores in all the rounds and the player with the higher total score is declared the winner. The Siruseri Sports Club organises an annual billiards game where the top two players of Siruseri play against each other. The Manager of Siruseri Sports Club decided to add his own twist to the game by changing the rules for determining the winner. In his version, at the end of each round, the  cumulative score  for each player is calculated, and the leader and her current lead are found. Once all the rounds are over the player who had the maximum lead at the end of any round in th...

C Program To create book details using C-Structure

Image
Program:  #include <stdio.h> #include <string.h> #include <stdlib.h>   struct bookInfo{     char name[25];     char author[25];     int pages;     float price; }; int main() {     struct bookInfo book;     // Taking book name from user     printf("Enter Name Of Book: ");     fgets(book.name, sizeof(book.name), stdin);          // Taking author name from user     printf("Enter Name Of Book-Author: ");         fgets(book.author, sizeof(book.author), stdin);     // Taking number of total pages of book from user     printf("Enter Number Of Pages in Book: ");     scanf("%d",&book.pages);     // Taking price of book from user     printf("Enter the Price of Book: ");     scanf("%f",&book.price);          // Showing Book Information As Ou...

TURBO SORT solution in C language.- Codechef

  TURBO SORT Problem Code:  TSORT Given the list of numbers, you are to sort them in non decreasing order. Input t  – the number of numbers in list, then  t  lines follow [ t  <= 10^6]. Each line contains one integer:  N  [0 <=  N  <= 10^6] Output Output given numbers in non decreasing order. Example Input: 5 5 3 6 7 1 Output: 1 3 5 6 7 . . . Solution in C Language. # include <st dio.h> i nt mai n () { int t, i;      int a[1000001] = {0}; scanf ( " %d " ,&t);      while (t--) {           int n; scanf ( " %d " ,&n);          a[n]++;     }      for( i=0 ; i<1000001 ; i++ ) {           while (a[i]>0) {                printf ( " %d\n " ,i);          ...

Escape Sequence in C

An escape sequence is a sequence of characters that does not represent itself when used inside a character or string literal. In C, all sequences consist of two characters, the first of which is the backslash, \ (called the "Escape character"); the remaining characters determine the interpretation of the escape sequence. ESCAPE SEQUENCE MEANING \a Alarm or Beep \b Backspace \f Form Feed \n New Line \r Carriage Return \t Tab (horizontal) \v Vertical Tab \\ Backslash \’ Single Quote \” Double Quote \? Question Mark \nnn Octal Number \xhh Hexadecimal Number \0 Null Example programs of some of the commonly used escape sequences:- 1. '\n' # inclu...