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

What are the four main types of SAE programs?

Ownership/Entrepreneurship, Placement, Exploratory, and Research.

Describe the difference between Interface-oriented Object-oriented and Aspect-oriented programming?

In object oriented programming cross cutting concerns cannot be implemented while in aspect-oriented these can be implemented easily, but if there is a logic mistake in implementing these cross-cutting concerns then the whole system will fail. In case of object-oriented whole system will not fail.(Excerpt from FrazzledDad blog @ http://frazzleddad.blogspot.com)Aspect-OrientedAspect-oriented programming looks at how many components or pieces of a system might need to interact. The intersections of these pieces are what are important in AOP. "Crosscutting" is a slice across several units, all of which interact during some operation. The article Discussing aspects of AOP in Communications of the ACM, Volume 44, Number 10 (2001) shows an example of a drawing editor with point and line elements. If the drawing is moved, both point and line elements need to update. A crosscut hits these elements for this event. Other examples might include logging or exception handling which hit several different layers in a system. (Viji Sarathy, Aspect Orienting .NET Components )Interface-OrientedInterface-oriented programming is a contract-based approach. Nether side of the interface cares how the other does its work, only that the two sides can communicate via an agreed-upon contract. WSDL-based web services are the prime example of this.Object-OrientedObject-Oriented programming is based on abstraction, encapsulation (data hiding), polymorphism and inheritance. Classes implement these concepts to build objects controlling or implementing a system.Abstraction allows loose coupling between components by providing a layer between objects so that one object isn't concerned with how the other implements its business rules. (Interfaces, layers) Great stuff when you want to isolate parts of the system so they can be swapped out without killing the rest of the sytsem.Encapsulation allows abstraction to work by hiding details of a class's implementation from calling classes. (Public vs. private fields)Inheritance enables base (parent) classes to have common functionality defined in it and passed down to child classes. A Shape class might have a field for color which is inherited by child classes of Square or Circle type.Polymorphism enables implementation of same-named public fields, allowing different classes to perform different actions on the same call - rendering a Square or Circle object differently in a graphic program, even though they might both be subclassed from a base Shape class. (Overriding)

Sort the following numbers 19 5 28 2 7 using bubble sort?

Passes:

bold are "sunk" into place

1: 5 19 2 7 28

2: 5 2 7 19 28

3: 2 5 7 19 28

4*: 2 5 7 19 28

*The last pass had no swaps, thus it breaks out of the sort

Efficiency: O(n^2) in random order O(n) when already sorted

In C how can you make a program that allowing the user press a key then process without pressing Enter key use getch but how?

How can I program that when the user press a key, it will automatically process like 4 example:

The user press w

You just press the key 'w'

Not scanf...

I think it's getch but I don't know how. It have errors.

What does the scope of an identifier refer to?

It refers to a place in your code where names or variable have meaning.

Write a c program with an append operation on an existing file?

#include<stdio.h>

#include<stdlib.h>

int main()

{

FILE *fp;

char a[60],b[60];

printf("Enter the name of the file\n");

scanf("%s",a);

fp=fopen(a,"a+");

printf("Enter a single line to append to the file %s :\n",a);

scanf(" %[^\n]s",b);

fprintf(fp,"%s",b);

printf("Append Successfully to the file %s",a);

fclose(fp);

return 0;

}

Which program translates an assembly language program into a high-level language?

A High level language is a language like C, Pascal, Fortran. To convert, the easiest way is to use a compiler.

A compiler will take the instructions written in a high level language and convert them into machine code which is the specific instruction set for that type of computer. Assembly language is just a human readable form of a machine code which is how the designers of the computer instruction set made it work.

A disassembler will show the assembly language from machine code. But the compiler usually includes a lot of optimisations from a the high level language and will not often generate very simple assembly.

How do you write a program in C that variables change value with each other?

void main()

{

//variable declaration

int a;

int b;

printf("\n Enter the first value");

scanf("%d",&a);

printf("\n Enter the second value");

scanf("%d",&b);

a=a+b;

b=a-b;

a=a-b;

printf("\n After swap the value");

printf("\n value of A=%d",a);

printf("\n value of A=%d",b);

getch();

}

When configuring GPOs which node contains the majority of account policies?

Computer Configuration node, Windows settings folder, security settings node.

Explain why interrupts are not appropriate for implementing synchronization?

Because they are completely unrelated things? Synchronization can be implemented with semaphores or mutexes.

Write a program to transpose of a matrix?

Program to find the Transpose of a Matrix

#include

#include

void main()

{

int i,j,n,t;

int m[5][5];

clrscr();

printf("Enter Order of Matrix : ");

scanf("%d",&n);

printf("Enter Elements of Matrix :\n\n");

for(i=0;i

{

for(j=0;j

{

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

}

}

printf("Transpose of the Matrix :\n\n");

for(i=0;i

{

for(j=i+1;j

{

t=m[i][j];

m[i][j]=m[j][i];

m[j][i]=t;

}

}

for(i=0;i

{

for(j=0;j

{

printf("\t%d",m[i][j]);

}

printf("\n");

}

getch();

}

Output:

Enter Order of Matrix : 3

Enter Elements of Matrix :

45 56 96

75 36 15

29 64 81

Transpose of the Matrix :

45 75 29

56 36 64

96 15 81

with out using temp variable:

#include

#include

void main()

{

int i,j,n,t;

int m[5][5];

clrscr();

printf("Enter Order of Matrix : ");

scanf("%d",&n);

printf("Enter Elements of Matrix :\n\n");

for(i=0;i

{

for(j=0;j

{

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

}

}

printf("Transpose of the Matrix :\n\n");

for(i=0;i

{

for(j=i+1;j

{

m[j][i]=(m[i][j]+m[j][i]-(m[i][j]=m[j][i]));

}

}

for(i=0;i

{

for(j=0;j

{

printf("\t%d",m[i][j]);

}

printf("\n");

}

getch();

}

What is the difference between data hidding and data abstraction?

Abstraction: Abstraction refers to removal/reduction of irrelevant data or unnecessary data or confidential data from a Class. Data hiding: Data hiding is a feature provided by the abstraction for hiding the data from the class.

What defines a variable?

A variable is a named storage location that can hold any data value. A variable has two associated values ; r value and l value.

Where the variables are stored in the computer?

Variable stored in the memory block inside the RAM. whenever we declare a variable it would take space in main memory and consume it's size from RAM.

Using three tuple representation of a sparse matrix?

#include<stdio.h> #include<unistd.h> #define SIZE 3000; void main() { int a[5][5],row,columns,i,j; printf("Enter the order of the matrix(5*5)"); scanf("%d %d",&row,&columns); printf("Enter the element of the matrix\n"); for(i=0;i<row;i++) for(j=0;j<columns;j++) { scanf("%d", &a[i][j]); } printf("3-tuple representation"); for(i=0;i<row;i++) for(j=0;j<columns;j++) { if(a[i][j]!=0) { printf("%d %d %d", (i+1),(j+1),a[i][j]); } } getchar(); }

You want the code of Discrete fourier transform in C language for your image processing program using a filter function to enhance the tiff image.?

/* Discrete Fourier Transform and Power Spectrum Calculates Power Spectrum from a Time Series Copyright 1985 Nicholas B. Tufillaro */ #include #include #define PI (3.1415926536) #define SIZE 512 double ts[SIZE], A[SIZE], B[SIZE], P[SIZE]; main() { int i, k, p, N, L; double avg, y, sum, psmax; /* read in and scale data points */ i = 0; while(scanf("%lf", &y) != EOF) { ts[i] = y/1000.0; i += 1; } /* get rid of last point and make sure # of data points is even */ if((i%2) == 0) i -= 2; else i -= 1; L = i; N = L/2; /* subtract out dc component from time series */ for(i = 0, avg = 0; i < L; ++i) { avg += ts[i]; } avg = avg/L; /* now subtract out the mean value from the time series */ for(i = 0; i < L; ++i) { ts[i] = ts[i] - avg; } /* o.k. guys, ready to do Fourier transform */ /* first do cosine series */ for(k = 0; k <= N; ++k) { for(p = 0, sum = 0; p < 2*N; ++p) { sum += ts[p]*cos(PI*k*p/N); } A[k] = sum/N; } /* now do sine series */ for(k = 0; k < N; ++k) { for(p = 0, sum = 0; p < 2*N; ++p) { sum += ts[p]*sin(PI*k*p/N); } B[k] = sum/N; } /* lastly, calculate the power spectrum */ for(i = 0; i <= N; ++i) { P[i] = sqrt(A[i]*A[i]+B[i]*B[i]); } /* find the maximum of the power spectrum to normalize */ for(i = 0, psmax = 0; i <= N; ++i) { if(P[i] > psmax) psmax = P[i]; } for(i = 0; i <= N; ++i) { P[i] = P[i]/psmax; } /* o.k., print out the results: k, P(k) */ for(k = 0; k <= N; ++k) { printf("%d %g\n", k, P[k]); } }

How do you write a program to make asterisk isosceles triangle using for loop in c plus plus?

*

**

***

****

simply use dis...

{

int x,y;

for(x=1;x<=4;x++)

{

for(y=1;y<=x;y++)

printf("*");

printf("\n");

}

}

Which os is build in Java compiler?

Java compiler available on multiple platforms, the class files it generates are platform-independent.

What is low-level symbolic programming language?

In contrast to a high-level language, which formats itself more to allow the programmer to understand his/her work and program flow, a low-level language formats itself in terms of a computer's or circuit's own internal structure. Rather than you saying what you want to do and letting the compiler figure out how to tell the machine what to do, you're basically telling the machine directly what to do: in its own "words," so to speak.

Assembler languages are perhaps the best-known low-level languages.

What is bak in C programming?

Nothing, but as a file-extension it means backup.

What to do to write a c program to input a number then a digit and findout the place value of that digit?

#include<stdio.h>

int main()

{

int d,j=1,i,flag=0,count=0,k=0;

int b[];

char a[],c;

printf("enter the number=");

scanf("%s",a);

printf("enter the digit=");

scanf("%c",&c);

printf("the place value of given digit is:");

for(i=0;a[i]!='\0';i++)

{

if(a[i]==c)

{

b[k]==a[i]-'0';

b[k]=b[k]=*j;

flag=1;

count++;

k++;

}

j=j*10;

}

if(flag==1)

{

printf("the place value of given digit %c is:",c);

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

printf("\n%d",b[i]);

}

else

printf("your entered digit is not present in number");

return 0;

}

Can a class c felon go to Mexico?

Anyone looking toescape the US can go to Mexico. They have no strict importation laws on anything, anyone.

Added: However. . . Mexico DOES have an extradition treaty with the US.