Adak 419 Nearly a Posting Virtuoso

Would you post the program? I'd have to see how the program is set up to receive input. Also, I want to be sure you actually wrote the password program. I want to avoid even the appearance of helping someone crack a password.

rubberman commented: This is getting a little to "picky" in my opinion -3
Adak 419 Nearly a Posting Virtuoso

Obviously, it should be titled: "Steak and Chicken Dinner Problem"

A wedding reception will have 200 guests and the dinner budget is $9,000.

Wedding Catering Prices:
===================
Chicken Dinner: $40
  Steak Dinner: $50

What is the highest number of steak dinners you can serve at this reception, and stay within the budget?

Let x = maximum number of steak dinners.

Now express the number of chicken digits, in terms of the number of the
number of steak dinners.

Cost per steak dinner * number of steak dinners + cost per chicken dinner(200 - x) = 9,000
=========================================================================

50x + 40(200-x) = 9,000
50x + 8000 -40x = 9,000
10x + 8000 = 9,000
10x = 1,000
x = 100
	 
steak dinners   = 100 
chicken dinners = 100
	 
100 * 50 = 5,000
100 * 40 = 4,000
================
200       $9,000

Could we squeeze in just one more steak dinner?

101 * 50 = 5050
 99 * 40 = 3960
===============
200       $9,010 (nope, over budget)

This would be done in just a few lines of code, using the above math. A short and sweet way to solve this kind of problem.

Adak 419 Nearly a Posting Virtuoso

That's an acronym, WaltP. DNA, RNA, Nasa, etc., are all acronyms.

An anagram has to have every letter of the word or phrase it can be rearranged to form.

WaltP commented: Duh! Notice my smiley? -4
Adak 419 Nearly a Posting Virtuoso

Selection sort has nothing to recommend it, *except* it makes the absolute minimum number of comparisons. Other than those rare times that comparisons are inordinately costly, it's not a sort to use.

The fastest general purpose sort on Windows (since Windows 2000), is to use the system sort, with a command line on the terminal window:

sort <Unsorted.txt >Sorted.txt ( ;) )

Why? Because MS set aside special resources for sorting, that your program can't begin to match. I have several versions of Quicksort (optimized with Insertion sort for small sub arrays), Radix, Flash, Merge, Comb 11, etc., in C, and none of them come close to the system sort. And they never will. Easy squeezy also, since it does the merging of the temp files for you.

After that, in general, it's faster to sort in memory than on the HD (SSD might change this a bit). Sequentially reading the data, instead of bouncing the read head back and forth, is what you want here.

So, an array that is a multiple of 32 or 64 (depends on your OS size), and your drive's own buffer, is called for.

Fastest general purpose sorter I have is the tweaked Quicksort mentioned above. If you can get away with leaving the data unsorted, but making it appear as if it's sorted by using an index array, then use the index array method. Combine that with Quicksort, or your favorite fast sorter.**

Fill your array, …

-Powerslave- commented: Though this will be a zombie post, I'd disagree with you. User-to-system transitions are costly whch means you can create an even more optimized sorting code. Using the system is still right if getting the job done quickly has priority over performance. +0
Adak 419 Nearly a Posting Virtuoso

Hello can you help me please... im making the program that will display the smallest number using function in array...please help me...thank you in advance...hoping for your positive responds....

#include<stdio.h>

void accept();  //should be void accept(void);
void findsmallest(int num[],int size);  //well done!
int a;           //should be removed
int main(void)
 {

   accept();
   getch();
   return 0;
 }

 void accept()
  {
    int size=0, a;    //a goes down here
    int num[]=size;
    scanf("%d",size);   //should be &size, not just size

     
   for(a=0,small=num[a];a<size;a++) //assign small a value
    {                               //unassigned local variables   
      scanf("%d",&num[a]);          //could have any value    
      if(num[a]<small)              //to start with    
       {
	 num[a]=small;     //wrong! see below
	}
     }
   }

 void findsmallest(num,size);
  {
    return;
  }
}

I'm trying to be nice here, but this program is making it tough. It never even calls findsmallest (which has ZERO code in it, BTW. The code for it is up in the accept function (where it should be for efficiency), but the logic is wrong:

if(num[a]<small)
       {
     num[a]=small;     //wrong -- remove this line

     small = num[a];  //correct -- use this one.
    }

If you want to find the smallest value, in the findsmallest function, I have no problems with that. Just remove the if statement from the accept function, and put it into the findsmallest. You'll also need to have a separate for loop for it, in findsmallest.

Then, just call findsmallest like the prototype shows, and be sure to print out the smallest value.

There are LOTS of C tutorials on the web, some video tutorials from major colleges …

Adak 419 Nearly a Posting Virtuoso

We're not a "do the program for you", forum. We help people with THEIR programs, if we can.

If you really have no code or pseudo code, at all, check out Google for homework sites, and see if you can find a "do it for you", forum.

Maybe hire a programmer? Won't help in a test, but it's something.

WHITE_BOLT commented: not helpful +0
Adak 419 Nearly a Posting Virtuoso

The backslash char is an escape char in C. It's paired up with another char to represent something difficult to type: like \n for a newline char, or \t for a tab, etc.

Two backslashes is used when you want to delineate just one backslash itself.

Adak 419 Nearly a Posting Virtuoso

The path to the BGI drivers.

Adak 419 Nearly a Posting Virtuoso

I can't get it to work, but I can see that it's close. This is with the C compiler in Turbo C/C++ ver. 1.01.

This uses direct video writing, and oddly, direct video writing still works with Windows XP (32 bit), as the operating system. That's for certain!

But I can't *quite* get this program to work as it should. (it should spell out "praveen", of course).

Can you double check with the source code that does work? See what differences there are?

Adak 419 Nearly a Posting Virtuoso

It may not be guaranteed to be portable by the C standard, but I've never heard of a C compiler that doesn't have signed and unsigned char's.

I'm sure there's some minimalist one that is that way, but it's designed for embedded applications, I'd bet $$$.

Narue commented: void main is harmless 99.9% of the time, but we don't cut any slack for it. -4
Adak 419 Nearly a Posting Virtuoso

An outline in pseudo code:

char map[10][10]
char myString[12]

for(each row) {
  
  fgets(myString, 10, filePointer);
  k = 0
  for(each column in the row) {
     map[row][col] = myString[k++]
  }  
}
jephthah commented: sorry man, that's just sloppy. -1
Adak 419 Nearly a Posting Virtuoso

Are you trying to make ONE knights tour from every square on the board, or are you trying to find EVERY knight's tour that is possible, from every square on the board?

Adak 419 Nearly a Posting Virtuoso

my advice is that for a beginer first get an binary file of an image and read the file and display using put pixel statement in c.
As u r going to display black and white image u need to set an threshold value above which all the values should be displayed using black colour n rest r white.
Try out this.

I added some code to a program some years back for this. Helped out someone who had a program to enhance MRI images.

I'll have to scour around and find it. As I recall, the array should be unsigned char, and you open the file in binary mode. Raju D sounds like he's on the right path.

As others have mentioned, you need to understand the file format you'll be working with. (there are so many!. :p

@Narue, ygPM

jephthah commented: this thread is 5 years old. the person you are "responding" to posted 1-1/2 years ago. after 200 posts, you should know better than this -1
Adak 419 Nearly a Posting Virtuoso

hi every body.......
here i want to ask something about base64 algorithm which is used for the encryption of passwords.........i just want to know that how it works ?????what are the functions used in this algorithm?????any type help.....any link...????

I'm not sure which cryptographic algorithms use base64, but here's some good reads on it:

1) Cryptology portal on Wikipedia - many pages covering old and new methods.

2) Google "nist encryption standard", for a thorough discussion of their selection of the new(er) advanced encryption standard for the USA. Lots of technical details!

If what you want is ONLY base64 info, then I'd google it, directly, and see what it has.

Adak 419 Nearly a Posting Virtuoso

hey, i'm a one-man army on a mission from god.

J, Have you been talking to god again?

You remember what the nice doctor said about talking to god, last time?

;) ;) ;)

Adak 419 Nearly a Posting Virtuoso

@aianne
I would recommend you scrap that compiler (which supports non-standard header files) and get yourself a new one that supports C99
I would recommend Code::Blocks.

You don't know WTF you're talking about!

Turbo C/C++ has EVERYTHING already laid out for her, in the help file - with example programs of EVERYTHING she has to do, except the square - (which is just draw 4 lines)

All she has to do is use her keyboard, and I gave her the keystrokes even to use, in the Turbo C/C++ IDE, to find what she needs, inside the help file.

I don't know why she is unable or unwilling to do this.

Code::Blocks may be nice, but for this assignment, Turbo C/C++ has all the easy answers.

jephthah commented: lighten up the hostile tone. his suggestion is relevant and politely addressed the larger issue, if not the immediate solution. -1
Adak 419 Nearly a Posting Virtuoso

You can't run Turbo C graphics on another compiler. I couldn't compile your program in Turbo C, since it was missing a parameter (noted on the line in question, below).

But Turbo C is pretty sweet for doing small assignments and programs. I use it a great deal.

The first program below, is yours, the second one is the help example from Turbo C, itself. Yes, it runs in WindowsXP.

/* This is your code. It will not compile, as is, in Turbo C.
#include<stdio.h>
#include"graphics.h"
#include<stdlib.h>
#include<conio.h>
void main()
{
     int graphdriver=DETECT,graphmode;
     int color,n,m;
     initgraph(&graphdriver,&graphmode);  //missing last paramenter!
     for(n=0;n<10;n++)
     {
                      putpixel(250+n,350,BLUE);
     }
     for(m=0;m<10;m++)
     {
                      int x=getpixel(250+m,350);
                      printf("%d",x);
     }
      getch();
*/
//This is the help file from Turbo C, which runs fine in WindowsXP, //with a default install of Turbo C.
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;

   /* initialize graphics mode */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();

   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);             /* return with error code */
   }

   /* draw a line */
   line(0, 0, getmaxx(), getmaxy());

   /* clean up */
   getch();
   closegraph();
   return 0;
}

i

jephthah commented: no, turbo c is not sweet at all, for anything. it sucks and perpetuates suckiness everywhere its use is forced onto hapless students by incompetent administrators in sloppy Second World programming courses. -1
Adak 419 Nearly a Posting Virtuoso

Turbo C has it's quirks, but here's some hints I use (and I use Turbo C/C++ (the C compiler portion), very often.

1) Use Turbo C/C++, NOT "Turbo C". Turbo C was an earlier product, and is buggy. Turbo C/C++ is fine - I recommend ver. 2.0, but 1.01 is also good.

2) Make the default properties of TC's window, just big enough for a full screen console (not graphic), window. If you set it up with a larger buffer, or a smaller buffer, you'll have problems, because it runs in a small amount of memory

You CAN get a full window, and a nice screen look, with no "black" screen, when you exit.

This is a legacy product and it's free - and very useful for small programs. I use it all the time (almost daily). Very easy interface, and help is quick, just one key combo.

Meaco, what kind of a pointer program are you trying to make? What is the part that is difficult?

If you have some code, please post it, and describe in detail about the program.

Ancient Dragon commented: Every version of Turbo C or Turbo C++ is terrible. -5
Adak 419 Nearly a Posting Virtuoso

Fscanf() has it's place, but the whole family of scanf() is very "fragile" and leads to code that breaks easily.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int i, j, regnum; 
  FILE * fp;
  char str[50] = { '\0' };
  char number[10] = { '\0' };

  /* if the file is in another directory, you need to include
  the full path and filename: C:\\directory\filename with two 
  backslashes on the first directory, or C:/directory/filename
  using just one forward slash.

  Weird eh? ;)
  */
  fp = fopen("C:/Rtest.txt", "rt");
  if(fp==NULL) {
    printf("\nFile Error - terminating the program");
    return 1;
  }

  fgets(str, sizeof(str), fp); 
  printf("\n\n%s\n\n\nYour number is: ", str);
  for(i = 0, j = 0; i < strlen(str); i++) {
    if((str[i] >= '0') && (str[i] <= '9')) {
      putchar(str[i]);
      number[j++] = str[i];
    }
  }
  number[j] = '\0';
  regnum = atoi(number);  

  printf("\nRegistration Number is: %d", regnum);

  fclose(fp);       
  printf("\n\n\t\t\t     press enter when ready");

  i = getchar();
  return 0;
}

Edit: Added some code to save the digits in a separate integer, regnum.

WaltP commented: We don't do other's homework for them. We help them do their own. -2
Aia commented: To balance the negative of Mr WaltP, just because you added a couple lines more. +8
jephthah commented: i am not a fan of giving away code wholesale. And while scanf() is usually a poor choice for input, fscanf and sscanf are powerful functions and are very good choices when the input is constrained. -1
Adak 419 Nearly a Posting Virtuoso

hi cld anybody explain me the concepts of continue,break,return statement with an example using c program

Sure. Then we could write your text book, your website tutorial, take your tests, etc.

I don't mean to be harsh, but we're not Google, we're not auditioning to be your tutor, and we're not a replacement for your text books.

Life is way too short for that. We did our homework or individual studying, and you should do yours. Don't take us for granted, please.

The way it works is YOU post your code or pseudo code that you're working on/having trouble with or don't understand, and we'll try to help you solve THAT problem, on your posted code.

jephthah commented: everyone makes mistakes no need to get personal. -1