How To find a maximum number in a 2D array?
// Pseudocode
int findMax( int[][] data ) {
// Return if data is empty
if( data.length 0 ) {
return 0;
}
int max = data[0][0];
// Iterate through each element in the array
for( int r = 0; r < data.length; ++r ) {
for( int c = 0; c < data[0].length; ++c ) {
// If we find a value greater than the current max, update max
if( data[r][c] > max ) {
max = data[r][c];
}
}
}
return max;
}
What type of expression is obtained in relational operators?
A boolean is an expression obtained in relational operators.
Random access and sequential access file in vb 6.0?
To access a particular data item in a sequential file, you need to read in all items in the file prior to the item of interest. This works acceptably well for small data files of unstructured data, but for large, structured files, this process is time-consuming and wasteful. Sometimes, we need to access data in non-sequential ways. Files which allow non-sequential access are random access files.
How do you convert c file to jar file?
1:Downlaod jcreator
2: download jdk
3:make a project class in the src folder only like this
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class youclassname extends JFrame implements ItemListener {
String colors[] =
{"White", "Black", "Blue", "Red", "Orange", "Green"};
JComboBox cboColors = new JComboBox(colors);
Container cnt = getContentPane();
youclassname (){
super("What ever you want");
cnt.setLayout (null);
cnt.add(cboColors);
cboColors.addItemListener (this);
cboColors.setBounds(30, 20, 80, 30);
setSize(270, 180);
setVisible(true);
}
public void itemStateChanged(ItemEvent e) {
int intN = -1;
if (e.getStateChange() 5) cnt.setBackground(Color.GREEN);
}
public static void main(String[] agrs) {
nameofyourclass myframe = new nameofyourclass();
myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
4:Go to run then type cmd.
5:a black box should open.
If its in a different drive type the letter of the drive where it is saved plus : no \.
It shold be on that drive type dir to see whats in the drive.
Once you found your project type CD thenameofyourproject.
it should say thename of your drive then the name of your project next to it.
type CD src it should look the same bu with src next to it.
type dir to see what you've made.
5:You will have to make the .class file now.
The way to do that is type javac the name of your src project.java.
If it says some kind of error do this (you must hava jdk installed) type where you downloaded your jdk like this my one was in program files and called jdk i would do this.
C:\ProgramFiles\jdk\bin\javac name of your src .java.
if that dosent work sorry but it always does.
if you've made no errors you should have a .class file.
6:Almost done.
now you must have jdk, type jar cfe what ever you want to name it.jar name of your src class without the.class name of your src class with the class so myne would be like.
(my one was called bc.class)
jar cfe Backroundcolours.jar bc bc.class. hit enter and done if it shows a sort of error do the same thing you did to make the .class.
C:\ProgramFiles\jdk\bin\jar cfe Backroundcolours.jar bc bc.class. hit ener and done.
Thanks for reading.
What is a standard built function in pascal?
Platform-dependent. For Turbo Pascal a few examples are: Length, Copy, Pos, Ord, Chr
How do you write a C program for a matrix multiplication using array?
include <stdio.h>
int main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[10][10], second[10][10], multiply[10][10];
printf("Enter the number of rows and columns of first matrix\n");
scanf("%d%d", &m, &n);
printf("Enter the elements of first matrix\n");
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
scanf("%d", &first[c][d]);
printf("Enter the number of rows and columns of second matrix\n");
scanf("%d%d", &p, &q);
if ( n != p )
printf("Matrices with entered orders can't be multiplied with each other.\n");
else
{
printf("Enter the elements of second matrix\n");
for ( c = 0 ; c < p ; c++ )
for ( d = 0 ; d < q ; d++ )
scanf("%d", &second[c][d]);
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < q ; d++ )
{
for ( k = 0 ; k < p ; k++ )
{
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum;
sum = 0;
}
}
printf("Product of entered matrices:-\n");
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < q ; d++ )
printf("%d\t", multiply[c][d]);
printf("\n");
}
}
return 0;
}
What is the difference between recursive and non recursive program?
A recursive system is one in which the output is dependent on one or more of its past outputs while a non recursive system is one in which the output is independent of any past outputs.e.g feedforward system having no feedback is a non recursive system.
Can c plus plus run on windows?
Windows 7 supports programs written in any language, including C and C++. However, the question is whether these programs support Windows 7 or not. If they were written for another platform entirely, such as the Apple Mac, then obviously they won't be supported.
Note that neither the C nor C++ languages, by themselves, support any particular operating systems, but they are generic enough to be able to create console applications that can run on most platforms without major modification. But in order to target a specific platform you need the appropriate headers and libraries for that platform. These are generally provided by your integrated development environment (IDE) of which there are many to choose from for each platform. In order to cater for multiple platforms code must be written specifically for each platform (using precompiler directives to filter out unwanted code) and must be compiled separately upon each supported platform.
What is the function of dos.h?
You can find a copy of that file in here:
http://ftp.ibiblio.org/pub/micro/PC-stuff/freedos/files/devel/c/dos.h
in case the server is down check the extracted file:
#ifndef __DOS_H
#define __DOS_H
#include <_defs.h>
#include <stddef.h>
#ifdef __WATCOMC__
#pragma pack( __push, 1 )
#endif
struct _R16BIT {
unsigned short ax, bx, cx, dx, si, di, es, cs, ss, ds, flags;
unsigned char cflag;
};
struct _R8BIT {
unsigned char al, ah, bl, bh, cl, ch, dl, dh;
};
union _INTR {
struct _R16BIT x;
struct _R8BIT h;
};
#define INTR _INTR
struct country {
int co_date; /* date format */
char co_curr[ 5 ]; /* currency symbol */
char co_thsep[ 2 ]; /* thousands separator */
char co_desep[ 2 ]; /* decimal separator */
char co_dtsep[ 2 ]; /* date separator */
char co_tmsep[ 2 ]; /* time separator */
char co_currstyle; /* currency style */
char co_digits; /* significant digits in currency */
char co_time; /* time format */
long co_case; /* case map */
char co_dasep[ 2 ]; /* data separator */
char co_fill[ 10 ]; /* filler */
};
#define COUNTRY country
struct DOSERROR {
int de_exterror; /* extended error */
char de_class; /* error class */
char de_action; /* action */
char de_locus; /* error locus */
};
struct date {
unsigned int da_year; /* current year */
unsigned char da_day; /* day of the month */
unsigned char da_mon; /* month (1 = Jan) */
};
struct dosdate_t {
unsigned char day; /* 1--31 */
unsigned char month; /* 1--12 */
unsigned int year; /* 1980--2099 */
unsigned char dayofweek; /* 0--6; 0 = Sunday */
};
struct devhdr {
long dh_next;
short dh_attr;
unsigned short dh_strat;
unsigned short dh_inter;
char dh_name[ 8 ];
};
struct dfree {
unsigned df_avail; /* Available clusters */
unsigned df_total; /* Total clusters */
unsigned df_bsec; /* Bytes per sector */
unsigned df_sclus; /* Sectors per cluster */
};
struct diskfree_t {
unsigned total_clusters;
unsigned avail_clusters;
unsigned sectors_per_cluster;
unsigned bytes_per_sector;
};
typedef struct {
char drive;
char pattern [ 13 ];
char reserved [ 7 ];
char attrib;
short time;
short date;
long size;
char nameZ [ 13 ];
} dosSearchInfo;
struct fatinfo {
char fi_sclus; /* sectors per cluster */
char fi_fatid; /* the FAT id byte */
int fi_nclus; /* number of clusters */
int fi_bysec; /* bytes per sector */
};
struct ffblk {
#ifdef __CLIB_LFN__
unsigned short cr_time; /* time of file creation */
unsigned short cr_date; /* date of file creation */
unsigned short ac_time; /* time of last file access */
unsigned short ac_date; /* date of last file access */
char ff_reserved[ 13 ]; /* reserved for use by DOS */
#else
char ff_reserved[ 21 ]; /* reserved for use by DOS */
#endif
char ff_attrib; /* attribute byte for file */
unsigned short ff_ftime; /* time of last write to file */
unsigned short ff_fdate; /* date of last write to file */
unsigned long ff_fsize; /* length of file in bytes */
#ifdef __CLIB_LFN__
char ff_name[ 256 ]; /* null-terminated filename */
unsigned short lfnhandle;/* DOS LFN support handle */
#else
char ff_name[ 13 ]; /* null-terminated filename */
#endif
};
struct find_t {
#ifdef __CLIB_LFN__
unsigned short cr_time; /* time of file creation */
unsigned short cr_date; /* date of file creation */
unsigned short ac_time; /* time of last file access */
unsigned short ac_date; /* date of last file access */
char reserved[ 13 ]; /* reserved for use by DOS */
#else
char reserved[ 21 ]; /* reserved for use by DOS */
#endif
char attrib; /* attribute byte for file */
unsigned short wr_time; /* time of last write to file */
unsigned short wr_date; /* date of last write to file */
unsigned long size; /* length of file in bytes */
#ifdef __CLIB_LFN__
char name[ 256 ]; /* null-terminated filename */
unsigned short lfnhandle;/* DOS LFN support handle */
#else
char name[ 13 ]; /* null-terminated filename */
#endif
};
#define _find_t find_t
struct fcb {
char fcb_drive;
char fcb_name[ 8 ],
fcb_ext[ 3 ];
short fcb_curblk,
fcb_recsize;
long fcb_filsize;
short fcb_date;
char fcb_resv[ 10 ],
fcb_currec;
long fcb_random;
};
struct xfcb {
char xfcb_flag;
char xfcb_resv[ 5 ];
char xfcb_attr;
struct fcb xfcb_fcb;
};
struct dostime_t {
unsigned char hour; /* Hours */
unsigned char minute; /* Minutes */
unsigned char second; /* Seconds */
unsigned char hsecond; /* Hundredths of seconds */
};
struct time {
unsigned char ti_min; /* minutes */
unsigned char ti_hour; /* hours */
unsigned char ti_hund; /* hundredths of seconds */
unsigned char ti_sec; /* seconds */
};
#ifdef __WATCOMC__
#pragma pack( __pop )
#endif
extern int __getversion( void );
extern char ** environ;
#define _version (*__getversion)()
extern unsigned char _osmajor;
extern unsigned char _osminor;
extern int absread( int drive, int sects, long lsect, void *buffer );
extern int abswrite( int drive, int sects, long lsect, void *buffer );
extern int allocmem( unsigned size, unsigned *seg );
extern int bdos( int ah, unsigned dx, unsigned al );
extern int bdosptr( int ah, void *argument, unsigned al );
extern int _callint( union INTR *regs );
extern struct COUNTRY *
country( int xcode, struct COUNTRY *ct );
extern void ctrlbrk( int ( *handler )( void ) );
extern void delay( unsigned mill );
extern void _disable( void );
extern unsigned _dos_allocmem( unsigned size, unsigned *seg );
extern unsigned _dos_close( int handle );
extern unsigned _dos_creat( const char *path, int attr, unsigned *handle );
extern unsigned _dos_creatnew( const char *path, int attr, unsigned *handle );
extern int __cdecl dosexterror( struct DOSERROR *errblk );
extern unsigned _dos_findfirst( char *filename, int attrib, void *strptr );
extern unsigned _dos_findnext( void *strptr );
extern unsigned _dos_findclose( void *strptr );
extern unsigned _dos_freemem( unsigned seg );
extern void __cdecl _dos_getdate( struct dosdate_t *ptr );
extern unsigned __cdecl
_dos_getdiskfree( unsigned char dr, struct diskfree_t *d );
extern unsigned _dos_getdrive( unsigned *disk );
extern unsigned _dos_getfileattr( const char *filename, unsigned *attrs );
extern unsigned __cdecl
_dos_getftime( int handle,
unsigned *date,
unsigned *time );
extern void __cdecl _dos_gettime( struct dostime_t *timeptr );
extern void ( interrupt far *
_dos_getvect( unsigned intno ) )( );
extern void _dos_keep( unsigned char retcode, unsigned size );
extern unsigned _dos_open( const char *path, unsigned flags, unsigned *handle );
extern unsigned _dos_read( int handle,
void far *buf,
unsigned len,
unsigned *nread );
extern unsigned _dos_setblock( unsigned newsize,
unsigned seg,
unsigned *max );
extern void _dos_setdate( struct dosdate_t *ptr );
extern void _dos_setdrive( unsigned disk, unsigned *total );
extern unsigned _dos_setfileattr( const char *filename, unsigned attrs );
extern unsigned _dos_setftime( int handle, unsigned date, unsigned time );
extern unsigned _dos_settime( struct dostime_t *timeptr );
extern void _dos_setvect( unsigned intno,
void ( interrupt far *vect )() );
extern time_t dostounix( struct date *date, struct time *time );
extern unsigned _dos_write( int handle,
void far *buf,
unsigned len,
unsigned *bytes );
extern void _enable( void );
extern int freemem( unsigned seg );
extern int getcbrk( void );
extern void __cdecl getdate( struct date *datep );
extern void __cdecl getdfree( unsigned char drive, struct dfree *dtable );
extern char * getdta( void );
extern void getfat( unsigned char drive, struct fatinfo *dtable );
extern void getfatd( struct fatinfo *dtable );
extern unsigned getpsp( void );
extern void __cdecl gettime( struct time *timeptr );
extern void ( interrupt far *
getvect( int intno ) )( );
extern int getverify( void );
extern int inp( unsigned id );
extern unsigned inpw( unsigned id );
extern unsigned inport( unsigned id );
extern unsigned char inportb( unsigned id );
extern void keep( unsigned char retcode, unsigned size );
extern void nosound( void );
extern int outp( unsigned id, int value );
extern unsigned outpw( unsigned id, unsigned value );
extern void outport( unsigned id, unsigned value );
extern void outportb( unsigned id, unsigned char value );
extern char * parsfnm( const char *cmdline, struct fcb *ptr, int al );
extern int peek( unsigned seg, unsigned offs );
extern char peekb( unsigned seg, unsigned offs );
extern void poke( unsigned seg, unsigned offs, int value );
extern void pokeb( unsigned seg, unsigned offs, char value );
extern int randbrd( struct fcb *buf, int rnum );
extern int randbwr( struct fcb *buf, int rnum );
extern int setblock( unsigned newsize, unsigned seg );
extern int setcbrk( int value );
extern void setdate( struct date *datep );
extern void setdta( char far *dta );
extern void setpsp( unsigned psp );
extern void settime( struct time *timeptr );
extern void setvect( int intno, void ( interrupt far *vect )() );
extern void setverify( int flag );
extern void sleep( unsigned x );
extern void sound( unsigned frequency );
extern void unixtodos( time_t longtime,
struct date *date,
struct time *time );
extern int unlink( const char *filename );
#define disable _disable
#define enable _enable
#define _A_NORMAL 0x00
#define _A_RDONLY 0x01
#define _A_HIDDEN 0x02
#define _A_SYSTEM 0x04
#define _A_VOLID 0x08
#define _A_SUBDIR 0x10
#define _A_ARCH 0x20
#define FA_NORMAL _A_NORMAL
#define FA_RDONLY _A_RDONLY
#define FA_HIDDEN _A_HIDDEN
#define FA_SYSTEM _A_SYSTEM
#define FA_LABEL _A_VOLID
#define FA_DIREC _A_SUBDIR
#define FA_ARCH _A_ARCH
#define NFDS 20
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define MK_FP( seg, ofs ) ( ( void * )\
( ( ( unsigned long )( seg ) << 16 ) |\
( unsigned )( ofs ) ) )
#define FP_SEG(fp) ( ( unsigned )( ( unsigned long )( fp ) >> 16 ) )
#define FP_OFF(fp) ( ( unsigned )( fp ) )
#define __peek( a,b ) ( *( ( int far * ) MK_FP ( ( a ), ( b ) ) ) )
#define __peekb( a,b ) ( *( ( char far * ) MK_FP ( ( a ), ( b ) ) ) )
#define __poke( a,b,c ) ( *( ( int far * ) MK_FP ( (a),(b)) ) = ( int )(c))
#define __pokeb( a,b,c ) ( *( ( char far * ) MK_FP ( (a),(b)) ) = ( char )(c))
#define peek( a,b ) ( *( ( int far * ) MK_FP ( ( a ), ( b ) ) ) )
#define peekb( a,b ) ( *( ( char far * ) MK_FP ( ( a ), ( b ) ) ) )
#define poke( a,b,c ) ( *( ( int far * ) MK_FP ( (a),(b)) ) = ( int )(c))
#define pokeb( a,b,c ) ( *( ( char far * ) MK_FP ( (a),(b)) ) = ( char )(c))
#ifndef __NO_INLINE_FUNCTIONS
#pragma aux _enable = "sti";
#pragma aux _disable = "cli";
#pragma aux inp = "in al, dx" parm [dx] value [al] modify [ax dx];
#pragma aux inpw = "in ax, dx" parm [dx] value [ax] modify [ax dx];
#pragma aux inport = "in ax, dx" parm [dx] value [ax] modify [ax dx];
#pragma aux inportb = "in al, dx" parm [dx] value [al] modify [ax dx];
#pragma aux outp = "out dx, al" parm [dx] [al] value [al] modify [ax dx];
#pragma aux outpw = "out dx, ax" parm [dx] [ax] value [ax] modify [ax dx];
#pragma aux outport = "out dx, ax" parm [dx] [ax] modify [ax dx];
#pragma aux outportb = "out dx, al" parm [dx] [al] modify [ax dx];
#endif
#endif
What is the basic syntax of C?
+ +=
- -=
* *=
/ /=
% %=
=
==
!=
<=
>=
& &&
|
^
~
<< <<=
>> >>=
,
[]
()
are the basic operator in TURBO C
What are the merits and demerits of array based implementation over linked implementation?
The merits of an array are that it provides the most compact storage mechanism of any data container, and enables constant-time, random access to that data.
The demerits are that insertions and extractions can be costly in terms of performance due to the need to copy/move elements within the array. For large arrays, the cost can become prohibitive. Also, arrays can only be used to store elements of the same type.
What is difference between procedure oriented and Object Oriented?
Write a c program to reverse a digit 123?
Program to reverse ANY given number in C
#include
main()
{
int num,mod,rev=0;
printf("Enter a number:");
scanf("%d", &num);
while(num>0)
{
mod=num%10;
rev=(rev*10)+mod;
num=num/10;
}
printf("Reverse of the given number: %d", rev);
getchar();
}
Other Ideas! Use the While Loop
#include
main()
{
int a,b,c,d,e;
printf("Enter the Number to Find it's Reverse\n");
scanf("%d",&a);
while(a!=0)
{
b=a%10;
c=a/10;
printf("%d",b);
a=c;
}
getchar();
}
Before compiling include stdio.h
-----------------------------------------------------------------------------
Using sprintf/atoi functions./..
int _tmain(int argc, _TCHAR* argv[])
{
int inumber;
printf("\n\n Enter a Number:");
scanf("%d",&inumber);
char pNumber[10];
sprintf(pNumber, "%d", inumber);
int iLength=strlen(pNumber);
char temp;
for(int i=0;i temp=pNumber[i]; pNumber[i]=pNumber[iLength-1]; pNumber[iLength-1]=temp; iLength--; } inumber=atoi(pNumber); printf("\n\nReverse no is %d",inumber); getchar(); return 0; }
What are the largest and smallest values that can be reliably stored in a variable of type int?
In C programming, the range of integer values that we can reliably represent with an int data type is exactly the same as for a char data type: -127 to +127. While an int is usually capable of covering a much wider range of values than a char, this range is the absolute minimum we can guarantee across all C implementations.
Note that while most (all?) modern systems support twos-complement signed notation to yield a minimum range of -128 to +127, we cannot guarantee this range on a ones-complement system because these systems have two separate representations for the value 0, reducing the range by 1 value. 0 is neither positive nor negative, hence the introduction of twos-complement notation.
If we need to determine the maximum guaranteed range we can represent with a built-in type upon any given implementation, then we must use the implementation-defined constants declared in the C standard library header,
#include
int minimum = INT_MIN;
int maximum = INT_MAX;
Note that on any given system, we can always make the following assertions in C programming:
assert (8<=CHAR_BIT); // CHAR_BIT is defined in
assert (sizeof(char)==1);
assert (sizeof(short)<=sizeof(char));
assert (sizeof(int)<=sizeof(short));
assert (sizeof(long)<=sizeof(int));
assert (sizeof(long long)<=sizeof(long));
These limitations are defined by the C standard. Note that while a char is always 1 byte in length, the length of a byte (in bits) is implementation-defined but is always at least 8 (bits). Systems with 9-bit or 16-bit bytes are not uncommon, but are catered for by the standard. Older systems that support a 7-bit byte are not catered for by the standard, however non-standard implementations do exist to cater for these specific systems.
Different between compiler and interpreater?
The execution of a program can happen either natively -- the intructions are actual CPU instructions, or it can happen through an interpreter. The interprer thus takes instructions (which are typically not native CPU instructions), and performs the actions associated with the instruction (open a file, write a character to the screen, etc). The interpreter is thus in charge of the execution of the program instructions.
Now consider a program written in spoken English. It is obvious that the CPU does not understand spoken English. We can either use an interpreter to execute this program, or we can translate to "another form" (typically machine code specific to a particular CPU) -- using a compiler. This "other form" may require additional things to happen, so the compiler may insert extra instructions to cater for these things. The end result is our spoken English program, in another form -- either native, which can be executed by the CPU, or an a form which requires that an interpreter be used to execute it.
The interested reader is encouraged to read Allan Turing's groundbreaking paper on computing machines entitled "On computable numbers: With an application to the Entscheidungsproblem". You can find this easily by simply searching for this title with your favourite search engine.
Another AnswerWe usually prefer to write computer programs in languages we understand rather than in machine language, but the processor can only understand machine language. So we need a way of converting our instructions (source code) into machine language. This is done by an interpreter or a compiler.An interpreter reads the source code one instruction or line at a time, converts this line into machine code and executes it. The machine code is then discarded and the next line is read. The advantage of this is it's simple and you can interrupt it while it is running, change the program and either continue or start again. The disadvantage is that every line has to be translated every time it is executed, even if it is executed many times as the program runs. Because of this interpreters tend to be slow. Examples of interpreters are Basic on older home computers, and script interpreters such as JavaScript, and languages such as Lisp and Forth.
A compiler reads the whole source code and translates it into a complete machine code program to perform the required tasks which is output as a new file. This completely separates the source code from the executable file. The biggest advantage of this is that the translation is done once only and as a separate process. The program that is run is already translated into machine code so is much faster in execution. The disadvantage is that you cannot change the program without going back to the original source code, editing that and recompiling (though for a professional software developer this is more of an advantage because it stops source code being copied). Current examples of compilers are Visual Basic, C, C++, C#, Fortran, Cobol, Ada, Pascal and so on.
You will sometimes see reference to a third type of translation program: an assembler. This is like a compiler, but works at a much lower level, where one source code line usually translates directly into one machine code instruction. Assemblers are normally used only by people who want to squeeze the last bit of performance out of a processor by working at machine code level.
Compiler
A Compiler is a program that translates code of a programming language in machine code
*****Translated source code into machine code***** .
A compiler is a special program that processes statements written in a particular programming language and converts them into machine language, a "binary program" or "code," that a computer processor uses.
A compiler works with what are sometimes called 3GL and higher-level languages (3rd-generation languages, such as Java and C
Interpreter
Interpreters translate code one line at time, executing each line as it is "translated," much the way a foreign language interpreter would translate a book, by translating one line at a time. Interpreters do generate binary code, but that code is never compiled into one program entity.
Interpreters offer programmers some advantages that compilers do not. Interpreted languages are easier to learn than compiled languages, which is great for beginning programmers. An interpreter lets the programmer know immediately when and where problems exist in the code; compiled programs make the programmer wait until the program is complete.
Interpreters therefore can be easier to use and produce more immediate results; however the source code of an interpreted language cannot run without the interpreter.
Compilers produce better optimized code that generally run faster and compiled code is self sufficient and can be run on their intended platforms without the compiler present.
When do you use protected visibility specifier to a class member in C?
a class member declared as private can only be accessed by member functions and friends of that class
a class member declared as protected can only be accessed by member functions and friends of that class,and by member functions and friends of derived classes
Algorithm for calculating the average of 3 numbers?
Algorithm
Step1: Read A, B, C
Step2: If A > B is True, then check whether A > C, if yes then A is greatest otherwise C is greatest
Step3: If A > B is False, then check whether B > C, if yes then B is greatest otherwise C is greatest
Following these steps flowchart can be made.
What is the difference between ANSI C and C plus plus?
C is a programming language and ANSI is the standardization committee. The C language is under the auspices of the ANSI committee, which monitors the grammar and structure of the language in a standard way that compiler writers must adhere to.
ANSI C means that it is a standardized version of the C language according to the rules of the committee and should work/compile the same way on any system that uses an ANSI C compliant compiler.
#include<stdio.h>
#include<conio.h>
int find_gcd(int,int);
int find_lcm(int,int);
int main(){
int num1,num2,gcd,lcm;
clrscr();
printf("\nEnter two numbers:\n ");
scanf("%d %d",&num1,&num2);
gcd=find_gcd(num1,num2);
printf("\n\nGCD of %d and %d is: %d\n\n",num1,num2,gcd);
if(num1>num2)
lcm = find_lcm(num1,num2);
else
lcm = find_lcm(num2,num1);
printf("\n\nLCM of %d and %d is: %d\n\n",num1,num2,lcm);
return 0;
}
int find_gcd(int n1,int n2){
while(n1!=n2){
if(n1>n2)
return find_gcd(n1-n2,n2);
else
return find_gcd(n1,n2-n1);
}
return x;
}
What are the advantage of header linked list?
Header linked list contains a special node at the top,this header node need not represent the same type of data that succeding nodes do,it can have data like,no. of nodes,any data...
header node can access the data of all your nodes
How you find factorial of 100 in c?
hi friend
hope u got the ans:
int main()
{
int count=1,n,fact=1;
printf("Enter the value which u need for factorial");
scanf("%d",&n);
while(count<=n)
{
fact=fact*count;
count++;
}
printf("%d",fact);
getch();
}
The answer will get out of the scope of "int" when reaching 10! or 12!, so the upper answer is not accurate but in case of syntax it is good.
Below I have used array rather than simple int or long to store the multiplied results.
#include
#include
#define MAX 10000
int len = 0;
int fact[MAX];
void factorial(int);
void multiply(int);
void main()
{
int n,i;
clrscr();
printf("\nEnter any integer number : \n");
scanf("%d",&n);
fact[0]=1;
factorial(n);
printf("\nFactorial of %d is :\n",n);
for(i=len;i>=0;i--){
printf("%d",fact[i]);
}
getch();
}
void factorial(int n)
{
int i;
for(i=2;i<=n;i++){
multiply(i);
}
}
void multiply(int n)
{
long i,r=0;
int arr[MAX];
for(i=0;i<=len;i++)
{
arr[i]=fact[i];
}
for(i=0;i<=len;i++)
{
fact[i] = (arr[i]*n + r)%10;
r = (arr[i]*n + r)/10;
}
if(r!=0)
while(r!=0)
{
fact[i]=r%10;
r= r/10;
i++;
}
len = i-1;
}
void printStarts (void);
What is the limitation of DDA line generation algorithm?
1.It drift away from the actual line path because of rounding off float values to integer
2.It causes jaggies or stair-step effect
----------------------------------------------------------------------------------------------------------------
Disadvantage:The accumulation of round of error is successive addition of the floating point increments is used to find the pixel position but it take lot of time to compute the pixel position.----------------------------------------------------------------------------------------------------------------
More Informationhttp://knol.google.com/k/thiyagaraaj-m/dda-line-algorithm/1lfp8o9xxpx13/78#http://i.thiyagaraaj.com/articles/articles/dda-line-algorithm
----------------------------------------------------------------------------------------------------------------
the standard version of dda given as in one of its steps as
if(abs(dx)>abs(dy)) steps=abs(dx);
else steps=abs(dy);
this part just supports the positive slop with starting point on left side. Take an example of any other end points as {(8,3) to (2,2) or (4,5) to ( 8,2) or (8,3) to (5,5) } where the slop needs to be negative( for the last two cases) only.
can anyone correct me by suggesting the accurate version of DDA? Or is this the actual DDA??.
What is object oriented programming language in C plus plus?