answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

How do you get the output12345 1234 123 12 1?

printf ("12345 1234 123 12 1\n");

... or, did you mean to do it with loops ? ...

int i, j;

for (i=5; i>0; i--) {

for (j=1; j<=i; j++) printf ("%d", j);

printf (" ");

}

printf ("\n");

What is the value of expression 72 divided by c?

There is not enough information available to answer this question. The result of 72 divided by c will be an error if c is zero (0), a positive number if c is positive, and a negative number if c is negative.

How do youuse the 'long' function in turbo c?

#include

#include

void main()

{

long 11;

clrscr();

cout<<"size of long="<

getch();

}

What is the difference between a disk and a tape?

Disk allows for writing and reading any part of the disk at any time. This allows us to be playing games, surfing the web, and listening to music all at the same time. If we were to do this on tape, we would be able to only access the things in order they were on the tape, or we would have to wait while it scans the tape for our music, looking for empty space so we could download that latest patch.

Tape is a great way to backup your data because it's pretty cheep and easily stored and moved, but its only real use is bulk reading and writing (batch processing) of large amounts of data and other similar processes.

Disks are prone to mechanical failure, but allow for reading and writing files much easier and quicker but for a cost.

Tape is still widely used in a cooperate setting for off-site backups and for internal backups as accessing time while looking for a file to recover are not a concern where getting the file for your presentation in 5 minutes needs to be instant.

A program in c to copy text file?

File Operations in C are accomplished by the use of pointers.Pointers are use to point to a particular memory location.File are read and written by using file pointers.The Keyword FILE is used to declare a file pointer.

The Complete Program for writing text to a file and saving it and copying it to a new location is given at http://c-madeeasy.blogspot.com/2011/07/program-in-c-to-write-data-to-file-and.html

Program for implementation of non recursive predictive parser?

Aim:

Parse the following grammar.

E --> E + T / T

T --> T * F / F

F --> ( E ) / id

Program:

#include

#include

#include

#include

void err(const char* s)

{

perror(s);

exit(0);

}

int factor()

{

int val,i;

char ch[0];

scanf("%s",ch);

switch(ch[0])

{

case '(':

val=expr();

scanf("%s",ch);

if(ch[0]!=')')

err("Missing closing paranthesis in factor.");

break;

default :{

for(i=0;i

{

if((ch[i]>'0')&&(ch[i]<='9'))

continue;

else

err("Illegal character sequence in place of factor.");

}

val=atoi(ch);

}

}

return val;

}

int term()

{

int val;

char ch[10];

val=factor();

while(1)

{

scanf("%s",ch);

if(ch[0]=='*')

{

val=val*factor();

}

else

break;

}

ungetc(ch[0],stdin);

return val;

}

int expr()

{

int val;

char ch[10];

val=term();

while(1)

{

scanf("%s",ch);

if(ch[0]=='+')

val=val+term();

else

break;

}

ungetc(ch[0],stdin);

return val;

}

main()

{

printf("\nEnter the expression: ");

printf("\n Result: %d\n",expr());

}

Output:

nn@linuxmint ~ $ gcc rec.c

nn@linuxmint ~ $ ./a.out

Enter the expression: 5 * ( 3 + 1 )

;

Result: 20

nn@linuxmint ~ $

Flowchart for linear search?

PROGRAM:

//LINEAR SEARCH USING FUNCTIONS

#include

void linear(int [],int,int);

main()

{

int n,i,x,a[10];

printf("\nEnter the limit:");

scanf("%d",&n);

printf("\nEnter the elements:");

for(i=0;i

{

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

}

printf("\nEnter the element to be searched:");

scanf("%d",&x);

linear(a,n,x);

}

void linear(int a[],int n,int x)

{

int i,flag=0;

for(i=0;i

{

if(x==a[i])

{

flag=1;

break;

}

}

if(flag==1)

printf("\nElement %d is in the position %d",a[i],i+1);

else

printf("\nElement is not in the list");

}

Does break statement terminate only the inner loop in c?

Yes. Break terminates only the innermost control structure, loop, switch, etc. If you want to break out of nested control structures, you can set a variable to induce a second break, or you can throw an exception.

If you input names of students from the user terminated by ZZZ and create a data file GRADES with records of the form test1 test2 test3 will all the test scores show in the file?

This is a tricky one. The tripple 'ZZZ' indicates a location for source data. Start a file named 'Grade' (spead sheet). There are 3 sets of test scores to be logged. In this file all scores should be logged from highest to lowest.

What is executable code?

short answer: executable code is a program that is ready to be used write now.

long answer:

writing a computer program is generally a 2 part process (there are exceptions):

1) programmer writes the code

2) programmer runs his code through a special program called a Compiler

the Compiler is responsible for taking code that a programmer can understand, and turning it into something that a computer can understand. executable code is (usually) code that has been compiled.

What is incomplete binary tree?

Incomplete Binary Tree is a type of binary tree where we do not apply the following formula:

1. The Maximum number of nodes in a level is 2

What is 18 factorial?

18 factorial is 6,402,373,705,728,000.

Why doesn't the main function need a prototype statement?

Because we usually don't call it from the program, but if we do, you should have a prototype:

int main (int argc, char **argv);

int foobar (const char *progname)

{

char *param[2];

...

param[0]= progname;

param[1]= "help";

main (2, param);

...

}

int main (int argc, char **argv)

{

...

foobar (argv[0]);

...

}

What is a jurisdictional statement?

The section of an appellate brief that asserts the basis of appealability and the suitability of the court to hear the claim.

Wap to display the Fibonacci series?

#include<stdio.h>

main()

{

int a=0,b=1,n,c,i;

printf("enter number");

scanf("%d",&n);

printf("%d\n",a);

for(i=1;i<=n;i++)

{

c=a+b;

printf("%d\n",c);

b=a;

a=c;

}

getch();

}