Jump to content

Recommended Posts

Posted

AS the topic says only TC supports i think gotoxy function and delay but moden compilers like code::blocks doesn't support hence we need to make our own header file i'm not yet finished functions chapter so probly its obvious i don't know how to make headers.Please someone make for me or tell me any alternate to that functions if exist.!

And second problem is

Q: I made a program in which user will enter rows and columns from keyboard and according to matrix would be made on the no.'s user will enter but i want the 2 matrix user entered it should be displayed TOO so i included a set of code but it never prnt and a blank space is printed in thr place but same code is used in end to display addtion of both matrix.See code please help.!

#include<stdio.h>

#include<conio.h>

void main()

{

    int k,j,r1,c1,r2,c2;

    int a[10][10],c[10][10],b[10][10];

    printf("enter rows and columns of first matrix.");

    scanf("%d%d",&r1,&c1);

    printf("enter rows and columns of second matrix.");

    scanf("%d%d",&r2,&c2);

    if(r1 != r2 && c1!=c2)

    {

        printf("addtition not possible");

        return;

    }

    printf("\nenter first matrix\n");

    for(i=0; i<r1; i++)

    {

        printf("\nenter %d no :",c1);

        for(j=0; j<c1; j++)

        {

            scanf("%d",&a[k][j]);

        }

    }

{

        printf("\n-------------------------------\n");

        printf("\n-First matrix you have entered-\n");

        printf("\n-------------------------------\n");

        printf("--------Matrix One--------------\n");

        for(i=0;i<r1;i++)

        {

            printf("\n");

            for(j=0;j>c1;j++)

            {

                printf("%d\t",a[k][j]);

            }

        }

}

    printf("\nenter second matrix\n");

    for(i=0; i<r2; i++)

    {

        printf("\nenter %d no :",c2);

        for(j=0; j<c2; j++)

        {

            scanf("%d",&b[k][j]);

        }

    }

    {

        printf("\n-------------------------------\n");

        printf("\n-Second matrix you have entered-\n");

        printf("\n-------------------------------\n");

        printf("--------Matrix TWO--------------\n");

        for(i=0;i<r2;i++)

        {

            printf("\n");

            for(j=0;j>c2;j++)

            {

                printf("%d\t",b[k][j]);

            }

        }

}

    for(i=0; i<r1; i++)

    {

        for(j=0; j<c1; j++)

        {

            c[k][j]=a[k][j]+b[k][j];

        }

    }

      printf("\n------------------------------\n");

      printf("\n-Addition of both matrix you have entered-\n");

      printf("--------Matrix Addition-----------\n");

    for(i=0; i<r1; i++)

    {

        printf("\n");

        for(j=0; j<c1; j++)

        {

            printf("%d\t",c[k][j]);

        }

    }

    printf("\n-------------------------------\n");

    getch();

}

I want a orintation like this of those.! but gotoxy functiion not working so i orientate it  :(
Posted

u taking a b c as 2D array..but while scanning u r passing only dimension

use this &a[j] to scan

to print use a[j]

now see it was a forum problem(not actually problem) is a BB cde for italic i fixed that.!
Posted

hmm...so actually what prob u are facing..!!

Dude u can see it was clearly understandble that the first matrix which user will enter would be printed.! but it just print

---------------------------------------

-First matrix you have entered-

-------------------------------

----------Matrix ONE-----------

(here should be the printed matrix)

But it didn't printed ..! :(

Posted

Dude u can see it was clearly understandble that the first matrix which user will enter would be printed.! but it just print

---------------------------------------

-First matrix you have entered-

-------------------------------

----------Matrix ONE-----------

(here should be the printed matrix)

But it didn't printed ..! :(

abbe study books..

Not computer.. :crazy:

Posted

abbe study books..

Not computer.. :crazy:

Dude i have joined an institude who teach me C and hence i practise too doubts are cleared by my teacher but today he was gone somewhere so he can't see my prob and next class is on tuesday and if i don't solve this problem by that it will be a problem for me..!

And my current status u can see in pic i missed my tution today and hence i'm studying what i missed.!Previously i scored poor marks now i want decent marks.!

Posted

Dude u can see it was clearly understandble that the first matrix which user will enter would be printed.! but it just print

---------------------------------------

-First matrix you have entered-

-------------------------------

----------Matrix ONE-----------

(here should be the printed matrix)

But it didn't printed ..! :(

hey ur syntax is wrong...

while scanning use a [ i ] [j] not a[k][j]..

because u r not incrementing k..so use i instead of k

Posted

hey ur syntax is wrong...

while scanning use a [ i ] [j] not a[k][j]..

because u r not incrementing k..so use i instead of k

while printing ur are using j>c1 use j<c1...

thanks bro me so dumb i always make teis mistake.! it was taking anything greator tha c1 and r1 SO dumb i was..! +1 dude and BTW u were wrong about taking i instead of k because i didn't even took variable i so y would i take variable i instead of k?previously i choose i but forum was was messing up so i took k and changed all variables and arrays to k..! but it worked now no issues..!

Now 2nd problem dude..! i want an orientation that kinda (see pic).but gotoxy function not working in my compiler.! :(

Posted

dude i think new compilers don't support this function..BTW which compiler u using

i'm using code::blocks but tell me which compiler support this but thr must be an alternate fuction for that too?Tc is a domeed compiler broo.!
Posted

i'm using code::blocks but tell me which compiler support this but thr must be an alternate fuction for that too?Tc is a domeed compiler broo.!

i didn't used that function much...i have only used in TC.....so i dont know which compilers supports this..!!
Posted

Add this function at the beginning of your program to make gotoxy and delay function work in code::blocks

You must include stdio.h,time.h

void gotoxy(int x,int y)
{
printf("%c[%d;%df",0x1B,y,x);
}

void delay(unsigned int mseconds)
{
    clock_t goal = mseconds + clock();
    while (goal > clock());
}
Posted

Add this function at the beginning of your program to make gotoxy and delay function work in code::blocks

You must include stdio.h,time.h

void gotoxy(int x,int y)
{
printf("%c[%d;%df",0x1B,y,x);
}

void delay(unsigned int mseconds)
{
    clock_t goal = mseconds + clock();
    while (goal > clock());
}
dude didn't got the printf part it ain't c i think n y u.2 tyms wrote int?we can directly toll many variable like this int x,y; explain me that printf u wrote..//
Posted

gotoxy is not a standard c++ library function. It was a custom made function made for turbo C compiler and hence no modern compiler supports it. The delay function on the other hand can be implemented using the sleep function.

For delay: Include <windows.h> and use sleep(micro-seconds) function.

For gotoxy: This sort of work should ideally be done using ncurses but you can also implement it using Windows API commands or escape sequences.

Implementation using Windows API commands

#include <windows.h>

void gotoxy(int x, int y)

{

  COORD ord;

  ord.X = x;

  ord.Y = y;

  SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), ord);

}

Explanation: In the Windows API, COORD is a structure used to hold cursor position data and SetConsoleCursorPosition() is a built in function for setting the cursor on screen. SO in the program we have declared a variable ord of COORD type and set its attributes. Next we just passed that variable to the SetConsoleCursorPosition() function.

Implementation using Escape sequences

This has been done by shivam94 in his version of he code.

Posted

gotoxy is not a standard c++ library function. It was a custom made function made for turbo C compiler and hence no modern compiler supports it. The delay function on the other hand can be implemented using the sleep function.

For delay: Include <windows.h> and use sleep(micro-seconds) function.

For gotoxy: This sort of work should ideally be done using ncurses but you can also implement it using Windows API commands or escape sequences.

Implementation using Windows API commands

#include <windows.h>

void gotoxy(int x, int y)

{

  COORD ord;

  ord.X = x;

  ord.Y = y;

  SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), ord);

}

Explanation: In the Windows API, COORD is a structure used to hold cursor position data and SetConsoleCursorPosition() is a built in function for setting the cursor on screen. SO in the program we have declared a variable ord of COORD type and set its attributes. Next we just passed that variable to the SetConsoleCursorPosition() function.

Implementation using Escape sequences

This has been done by shivam94 in his version of he code.

Thanks dude.See i made this in sing gotoxy it runs in Turbo C by including dos.h file but not running in code::blocks

#include<stdio.h>

#include<conio.h>

#include<gotoxy.h>

void gotoxy(int x,int y){

{

    struct student

    {

        char name[999];

        int marks,rollno;

    };

    int i;

    char ch=219;

    struct student pehla,dusra;

    printf("\n Enter name class and roll no. of first student");

    scanf("%s%d%d",&pehla.name,&pehla.marks,&pehla.rollno);

    printf("\n Enter name class and roll no. of second student");

    scanf("%s%d%d",&dusra.name,&dusra.marks,&dusra.rollno);

    printf("\n Here's summary what you have just entered:- ");

    for(i=22; i<=53; i++)

    {

        gotoxy(i,18);

        printf("%c",ch);

        delay(100);

    }

    for(i=18; i<=23; i++)

    {

        gotoxy(53,i);

        printf("%c",ch);

        delay(100);

    }

    for(i=53; i>=22; i--)

    {

        gotoxy(i,23);

        printf("%c",ch);

        delay(100);

    }

    for(i=23; i>=18; i--)

    {

        gotoxy(22,i);

        printf("%c",ch);

        delay(100);

    }

    gotoxy(25,19);

    printf("name");

    gotoxy(35,19);

    printf("rollno");

    gotoxy(45,19);

    printf("marks");

    gotoxy(25,20);

    printf("%s",pehla.name);

    gotoxy(35,20);

    printf("%d",pehla.marks);

    gotoxy(45,20);

    printf("%d",pehla.rollno);

    gotoxy(25,21);

    printf("%s",dusra.name);

    gotoxy(35,21);

    printf("%d",dusra.marks);

    gotoxy(45,21);

    printf("%d",dusra.rollno);

    getch();

}

}

What u said just i goot it but little bit if u convert just a single peice of gotoxy function writtent here with what u said i'll understand use same cordinates..!!

And u said to use sleep instead of delay so i done but still same problem..(see attachment)

Posted

Thanks dude.See i made this in sing gotoxy it runs in Turbo C by including dos.h file but not running in code::blocks 

What u said just i goot it but little bit if u convert just a single peice of gotoxy function writtent here with what u said i'll understand use same cordinates..!!

Why have used gotoxy() in the definition of gotoxy() in your code? I think there are some brackets missing in your code. Anyways just declare gotoxy() as a user defined function before void and use it. You dont have to replace anything else in the code.

And u said to use sleep instead of delay so i done but still same problem..(see attachment)

Sleep should be written with a capital S. The function is Sleep(milisec). Now try it. It'll work.

Posted

Why have used gotoxy() in the definition of gotoxy() in your code? I think there are some brackets missing in your code. Anyways just declare gotoxy() as a user defined function before void and use it. You dont have to replace anything else in the code.

Sleep should be written with a capital S. The function is Sleep(milisec). Now try it. It'll work.

Ok dude see The program i wrote with gotoxy has no bracets eror as u can copy the program and paste as it is in turbo C it will work w/o any error.And isn't there any alternate available orientation is an imp thing in program And we can't orientate programs w/o it..+ We can't give border to things w/o it too(most probly).

And sleep worked dude with capital S but another doubt is it said we should use int main rather than void main it worked with int main() but why?The function should not return a value i think.And if yes too than its than returning integer value only If we somehow included char data type too than how it will return values when its clearly written to return a integer value?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...