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 is a peripheral graphic array?

its no big deal, nobody should be worrying about relationships in elementy school anyway, there kids. they dont know better,

What is field data type?

The data type of the Variable determines/indicates the type of data that can be stored in a field/variable

How do you calculate 2s complement of an integer?

Two's complement is the normal implementation of signed integers, so just take the negative.

int a = 123;

int b = -a; /* b now equals -123 */

The actual implementation of two's complement notation is that, to make something negative, simply invert the bits and then add 1.

12310 = 00000000011110112 (using 16 bit notation)

Invert and you get 111111111000100. Add one and you get 111111111000101, so...

-12310 = 1111111110001012

C program for worst fit algorithm?

#include<iostream.h>

#include<conio.h>

#include<string.h>

int main()

{

unsigned int n,j,i,size[10],m,x=0,t;

int cho=1,ch;

system("cls");

cout<<"\t\t STORAGE PLACEMENT STRATEGIES\n";

cout<<"\tEnter the number of holes:";

cin>>n;

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

{

cout<<"\n Enter The Size Of Hole "<<i<<":";

cin>>size[i];

}

while(cho==1)

{

cout<<"\nEnter the size of the incoming program:";

cin>>m;

cout<<"\nMenu";

cout<<"\n1.First Fit Strategy \n2.Best Fit Strategy";

cout<<"\n Enter your choice:";

cin>>ch;

x=0;

switch(ch)

{

case 1:

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

{

if(size[i]>=m)

{

cout<<"\nYour program is placed in hole "<<i;

size[i]-=m;

x=i;

break;

}

}

if(x==0)

cout<<"There is no room for your program.";

break;

case 2:

unsigned int temp=0,pos=0,t1;

if(m<=size[1])

{

temp=size[1]-m;

pos=1;

}

else

temp=size[1];

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

{

if(m<=size[i])

{

t1=size[i]-m;

if(temp>=t1)

{

temp=t1;

pos=i;

}

}

else temp=size[i];

}

if(pos==0)

cout<<"There is no room for your page.";

else

{

size[pos]=size[pos]-m;

cout<<"Your program is palced in hole "<<pos;

}

break;

case 4:

return;

}

cout<<"\nFree Storage List";

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

cout<<"\nHole "<<i<<"\t\t"<<size[i];

cout<<"\n\nPress 1 to continue:";

cin>>cho;

}

}

Write a program to find a substring in a given string in c?

#include<stdio.h>

#include<conio.h>

int main()

{

int i=0,j=0,k=0,count=0,l=0,k1=0;

char a[80],b[80];

clrscr();

printf("\nEnter main string:-\n");

gets(a);

printf("\nEnter sub-string:-\n");

gets(b);

l=strlen(b);

while (a[i]!=EOF)

{

if (a[i]==b[j])

{

i++;

j++;

k1=1;

if (j==l)

{

j=0;

k=1;

count=count+1;

}

}

else

{

if (k1==1)

{

j=0;

k1=0;

}

else

i++;

}

}

if (k==1)

{

printf("\n\nThe given sub-string is present in the main string.");

printf("\nIt is present %d times.",count);

}

else

{

if (k==0)

printf("\n\nThe given sub-string is not present in the main string.");

}

}

Why do we use double in java but do not use float?

Double is more precise than float. The 4 bytes saved on a float are usually not very relevant. However, if you need to save large amounts of numbers (e.g. in an array), and you don't need the extra precision, you might save some memory by using float.

What is a structure variable in computer programming?

A structure variable is a name that refers to a data structure. For example:

struct S {/*...*/};

int main (void) {

S x; /* x is a structure variable that refers to an instance of the structure S */

// use x...

return 0;

}

What is the perror function used for in C programming?

The perror() function is used to print a user-defined error message to stderr. Consider the following:

Example:

#include

int main ()

{

FILE * pFile;

pFile=fopen ("missing.txt","rb");

if (pFile==NULL)

perror ("missing.txt");

else

fclose (pFile);

return 0;

}

Possible Output:

missing.txt: No such file or directory

We can achieve the exact same effect with a more verbose fprintf() statement, such that the following are equivalent:

perror ("Error");

fprintf (stderr, "Error: %s\n", strerror (errno));

The following are also equivalent:

perror (NULL);

fprintf (stderr, strerror (errno));

We typically use fprintf() statement when we need to print messages other than those provided by strerror and/or wish to redirect the output to a device other than stderr. But for all error messages based upon the thread-local errno, perror is more concise and reduces the chances of introducing errors through typos (such as accidently redirecting errors to stdout instead of stderr).

Q squared plus 20 q plus c?

I'm not exactly sure what you mean by this, but if you'd like to know how to do this in C here:

q ^ 2 + 20 q + c

Algorithm for adjacency matrix representation?

To Find the number in that matrix and check that number adjacency elements...

import java.util.Scanner;

public class FindAdjacencyMatrix {

public static int[][] array1 = new int[30][30];

public static int i,j,num,m,n;

public static void main(String args[]) {

Scanner input = new Scanner(System.in);

//-------------------------------------------------------------------------------------------------

System.out.println("Enter the m ,n matrix");

m = input.nextInt();

n = input.nextInt();

//-------------------------------------------------------------------------------------------------

System.out.println("Enter the matrix Element one by one:");

for(i = 0; i < m; i++) {

for(j = 0; j < n; j++) {

array1[i][j] = input.nextInt();

}

}

System.out.println("The Given Matrix is :");

for(i = 0; i < m; i++) {

for(j = 0; j < n; j++) {

System.out.print(" "+array1[i][j]);

}

System.out.print("\n");

}

//-------------------------------------------------------------------------------------------------

System.out.println("Find The Adjacency Elements for Given Number : ");

System.out.println("Enter The Number : ");

num = input.nextInt();

for(i = 0; i < m; i++) {

for(j = 0; j < n; j++) {

if(num == array1[i][j]) {

System.out.println("Element is Found :"+num);

findAdjacency(num,i,j);

break;

}

}

}

//--------------------------------------------------------------------------------------

}

private static void findAdjacency(int elem,int row,int col) {

try {

if( array1[row][col-1]!=-1) {

System.out.println("Left Adjacency : "+array1[row][col-1]);

}

} catch(Exception e){

System.out.println(" Exception Throwing ");

}

try{

if(array1[row][col+1]!= -1) {

System.out.println("Right Adjacency : "+array1[row][col+1]);

}

}catch(Exception e){

System.out.println(" Exception Throwing ");

}

try {

if(array1[row-1][col]!= -1) {

System.out.println("Top Adjacency : "+array1[row-1][col]);

}

} catch(Exception e){

System.out.println(" Exception Throwing ");

}

try {

if(array1[row+1][col]!= -1) {

System.out.println("Botto Adjacency : "+array1[row+1][col]);

}

} catch(Exception e){

System.out.println(" Exception Throwing ");

}

}

//----------------------------------------------------------------------------------------------

}

Write a program to print prime number using loop?

#include<stdio.h>

int main()

{

int i=1,j,count,n;

printf("enter number range\n");

scanf("%d", &n);

printf("following numbers are prime numbers:\t");

while(i<=n)

{

j=1;

count=0;

while(j<=n)

{

if(i%j==0)

{

count++;

}

j++;

}

if(count==2)

{

printf("%d\t", i);

}

i++;

}

return 0;

}

What type of program is skyscape?

Skyscape is the medical app for iphones and ipads that many nurses and doctors use to help them study.Many medical professionals use this app to help diagnos paitents.

What is big-o notation for describing time complexity of algorithm?

Big O notation allows to specify the complexity of an algorithm in a simple formula, by dismissing lower-order variables and constant factors.

For example, one might say that a sorting algorithm has O(n * lg(n)) complexity, where n is the number of items to sort.
Big O notation is used in Computer Science to describe the performance or complexity of an algorithm. Big O specifically describes the worst-case scenario, and can be used to describe the execution time required or the space used (e.g. in memory or on disk) by an algorithm.

Where can you find file conout.h for c plus?

If it's a part of the standard package it has to be in visual C/Borland folder. Use search to find out exact location. In newer package standard libraries are archived, and it might tricky to find. The best way is to check the software (Microsoft, Borland, and so) producer website.