Programming Questions

Q:

Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix Notation

Answer

Prefix Notation:


^ - * +ABC - DE + FG

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

1 2122
Q:

What would be the output of the following program?

/* sample.c */

main ( int argc, char **argv )

{

     argc = argc - (argc -1);

     printf ("%s", argv[argc - 1]);

}

Answer

C: \SAMPLE.EXE

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2077
Q:

What is Autosys?

Answer

AutoSys is an automated job control system for scheduling, monitoring, and reporting. These jobs can reside on any AutoSys-configured machine that is attached to a network.


 


However, in real business, you need to fire jobs not just based on scheduled time, but also based on events (like an arrival of a file), and, based on the success or failure of other jobs. Autosys is a total job scheduling solution that allows you to define these events, dependencies, time schedules, alerts, etc, making it a complete data center automation tool.

Report Error

View answer Workspace Report Error Discuss

5 2071
Q:

What would be the output of the following program?

# define SQR(x) (x * x)

main()

{

    int a, b = 3;

    a = SQR ( b + 2 );

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

}

Answer

11


Because, on preprocessing the expression becomes  a = ( 3 + 2 * 2 + 3),  as Ist preference is multiply & then addition, it evalvates as(3+ 2 * 3 +2) = (3+6+2)=11.

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

1 2049
Q:

Undefined reference to 'pthread_create'

How to Fix this error?

Answer

This is a common error while compiling C program in Linux. This error occurs when you are using pthread_create function to create threads in your programs.


To fix this problem ensure following points:
Include header file pthread.h in your program.
Add –lpthread linker flag with compilation command.
1- Include Header file
#include <stdio.h>
#include <pthread.h>
...
...
2- Compile command
gcc main.c -o main -lpthread

Report Error

View answer Workspace Report Error Discuss

0 2014
Q:

Write a c program for selection sort.

Answer

include<stdio.h>
int main(){

  int s,i,j,temp,a[20];

  printf("Enter total elements: ");
  scanf("%d",&s);

  printf("Enter %d elements: ",s);
  for(i=0;i<s;i++)
      scanf("%d",&a[i]);

  for(i=0;i<s;i++){
      for(j=i+1;j<s;j++){
           if(a[i]>a[j]){
               temp=a[i];
              a[i]=a[j];
              a[j]=temp;
           }
      }
  }

  printf("After sorting is: ");
  for(i=0;i<s;i++)
      printf(" %d",a[i]);

  return 0;
}

Output:
Enter total elements: 5
Enter 5 elements: 4 5 0 21 7
The array after sorting is:  0 4 5 7 21

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2002
Q:

How would you obtain segment and offset addresses from a far address of a memory location?

Answer

#include "dos.h"


main()


{


    Char far *scr = ( char far *) 0xB8000000;


    Char *seg, *off;


    Seg = (char *) FP_SEG ( scr );


    Off = ( char *) FP_OFF ( scr );


}


 

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 1994
Q:

Write a program to generate the Fibonacci series in c?

Answer

 #include<stdio.h>
int main(){
    int k,r;
    long int i=0l,j=1,f;

    //Taking maximum numbers form user
    printf("Enter the number range:");
    scanf("%d",&r);

    printf("FIBONACCI SERIES: ");
    printf("%ld %ld",i,j); //printing firts two values.

    for(k=2;k<r;k++){
         f=i+j;
         i=j;
         j=f;
         printf(" %ld",j);
    }
 
    return 0;
}

Sample output:
Enter the number range: 15
FIBONACCI SERIES: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 1992