xavier666 56 Junior Poster

Hello vanan4u

These are your errors
1) You have declared the return type of main as void but returned an integer. It is recommended to use int main(). See here
2) You have made a system call, however forgot to include the necessary header files for the function (stblib.h). However, system calls are not recommended. See here

It is recommended to use a function like char get_grade(int marks) instead of repeating it

xavier666 56 Junior Poster

its so easy!!!!

It's the I-know-the-answer-but-I-won't-tell syndrome.
It generally happens to people who suffer from I-don't-know-the-answer

Don't be too hard on him...

xavier666 56 Junior Poster

Do you know this feature of characters in C?

char ch = 'A';
ch = ch + 1;
printf("%c", ch);

Output

B

Now, you said ASCII code of 'A' = 65 & ASCII code of 'a' = 90, hence try to figure how much you should add/subtract from a character to convert into uppercase/lowercase

xavier666 56 Junior Poster

OMG! Here comes my "Turbo-C-Knee-jerk"
I see you are using an outdated compiler. When we copy and paste your program in our compiler (unless someone has Turbo C), it won't run because your program uses outdated header files (conio.h)

I suggest you get Code::Blocks

Now, technically speaking, what you have done is not a linked list, but simply a list. You have not done the delete function. For an array, you have to shift all of the elements to one side. But for a linked list, deletion is very easy. Since you have asked for a linked version of the phone book problem, could you show us the linked list version, even if it's incomplete?

PS - Try to avoid using global variables

xavier666 56 Junior Poster

@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.

xavier666 56 Junior Poster

Currently, i was assigned to create an array, which i have no idea what array is.

Oh come on! Then I (along with several others) would suggest you to read your C Programming book before diving into such problems

WaltP commented: Thank you for beating me to this thread! +11
xavier666 56 Junior Poster

it's about binary trees but we'll use names instead of numbers or single chars

Can you make a binary tree using numbers or single characters?
If you can, post that attempt.
If you can't, you have to go back to square one and read the theory first.

tux4life commented: :) +8
xavier666 56 Junior Poster

Can't your teacher(if any) solve the problems that you are facing in pointers?
If you have none, experiment with pointers. You'll learn a lot.
You can post your doubts here but don't expect instant answers.

xavier666 56 Junior Poster

Use Code::Blocks
No problems and no hassles!

xavier666 56 Junior Poster

And try not to use gets() . It's an erratic function. To cut a long post short, look here

tux4life commented: Exactly. +6
xavier666 56 Junior Poster

Could you please help me to solve this?

Sure we could help you but at least show us what you have come up with so far

Salem commented: Indeed it is so +18
xavier666 56 Junior Poster

I would suggest Code::Blocks

xavier666 56 Junior Poster

I have tried but can't

Show us how much or whatever you have tried.
Before moving into such questions on programming, think how you would solve the problem sequencially.
Can you atleast do it without pointers, using array-index?

Assume matrices stored in column order

In C, 2D Arrays lements are stored in Row-major format. As per my knowledge, column-major is only used in Fotran and MATLAB (and this is the C forum)

xavier666 56 Junior Poster

Are you trying something like this?

*
	   * *
	  *   *
	 *     *
	*********

If possible, try to generalize the program for a triangle of order n (where n could be the height).
One method of solving this could be for you to first develop a program for a triangle without spaces like this one

*
	   ***
	  *****
	 *******
	*********

After that, you could modify the program to print stars only during starting and ending of loops, otherwise spaces. However, you should keep it in mind to print the entire line of stars in the last iteration for the base of the triangle.

xavier666 56 Junior Poster

I just made a 'Hello World' program

#include<stdio.h>
int main()
{
	printf("Hello World\n");
    return 0;
}
exe file size    = 15.5 KB
Source file size = 79.0  B

Then i made a data structure program (implementing stack, queue, deque)

exe file size    = 21.9 KB
Source file size = 17.3 KB

So i guess it's not linearly dependent with its source file
So what really decides the size of an exe file.
PS - I think it is also compiler dependent 'coz exe files on turbo c++ are larger compared to those of code blocks

xavier666 56 Junior Poster

The errors were :-

  • Writing %C instead of %c
  • Placing the brackets incorrectly

The corrected code is as follows:-

#include <stdio.h>
#include <stdlib.h>
//GIGO.c- Coded by Ross Camarillo aka Bubonic_88
// on 12/02/2009
//Created by Randy Gibson
#define SYMB '*' // character to show in the letters



void letter_G (char SM);
void letter_I (char SM);
void letter_O (char SM);
void displayline (void);

int main (void)
{
	letter_G(SYMB);
	displayline();
	letter_I(SYMB);
	displayline();
	letter_G(SYMB);
	displayline();
	letter_O(SYMB);
	getchar(); // to cause system pause
	return(0);
}

// child functions

void displayline (void) // display the line break in the main function
{
	printf("-----\n");
}
void letter_G (char SM)
 //display ther letter g
{
	printf(" %c%c%c \n",SM,SM,SM);
	printf("%c   \n",SM);
	printf("%c %c%c%c\n",SM,SM,SM,SM);
	printf("%c   %c\n",SM,SM);
	printf(" %c%c%c \n",SM,SM,SM);
}
void letter_I (char SM)
 // display the letter i
{
	printf("%c%c%c%c%c\n",SM,SM,SM,SM,SM);
	printf("  %c  \n",SM);
	printf("  %c  \n",SM);
	printf("  %c \n",SM);
	printf("%c%c%c%c%c\n",SM,SM,SM,SM,SM);
}
void letter_O(char SM)
{
	printf(" %c%c%c \n",SM,SM,SM);
	printf("%c   %c\n",SM,SM);
	printf("%c   %c\n",SM,SM);
	printf("%c   %c\n",SM,SM);
	printf(" %c%c%c \n",SM,SM,SM);
}

A better program would be writing it in a single line

xavier666 56 Junior Poster

If your aim is to do the thing in one line, you can use ?:

salesTrend = (soldYesterday > soldToday) ? -1 : 0
xavier666 56 Junior Poster

This is just a linked list program for those who need help understanding the fundamentals. Put comments if you find some bugs.
The program is about maintaining a student database (their roll number and their age)
I've used Turbo C++ 4.5 as the compiler

:icon_cool: