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

Write a program with a loop that lets the user enter a series of integers the user should enter -99 to signal the end of the series after the program should display the largest and smallest.?

#include<iostream.h>

#include<conio.h>

main()

{

int i,j;

i=0;

j=0;

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

{

if(i>j){

cout<"the value of i is="<<i;

}

else

{

cout<<"the value of j is="<<j;

}

}

getch();

}

How do you find the quartile in an even array of values?

Divide the array in half and get the median of each half

When should you void a check?

When ur not gonna use it after all.

This video helps you figure it out, quick and simple: http://www.howcast.com/videos/284366-How-To-Void-a-Check

What is the salary of a java programmer and a c plus plus c programmer?

Java programmers earn an average of £52,500.

C++ programmers earn an average of £57,500.

See sources and related links, below, for more information.

What is Max airspeed in Class C and D airspace?

Sec. 91.117 - Aircraft speed.

(a) Unless otherwise authorized by the Administrator, no person may operate an aircraft below 10,000 feet MSL at an indicated airspeed of more than 250 knots (288 m.p.h.).

(b) Unless otherwise authorized or required by ATC, no person may operate an aircraft at or below 2,500 feet above the surface within 4 nautical miles of the primary airport of a Class C or Class D airspace area at an indicated airspeed of more than 200 knots (230 mph.). This paragraph (b) does not apply to any operations within a Class B airspace area. Such operations shall comply with paragraph (a) of this section.

Program to perform binary search operations using dynamic memory allocation?

#include<iostream>

#include<iomanip>

#include<vector>

#include<algorithm>

#include<random>

#include<time.h>

void initialise (std::vector<unsigned>& data)

{

// Pseudo-random number generator (range: 1 to 99).

std::default_random_engine generator;

generator.seed ((unsigned) time (NULL));

std::uniform_int_distribution<unsigned> distribution (1, 99);

data.clear();

unsigned max_elements(50);

while (max_elements--)

data.push_back (distribution (generator));

}

int linear_search(std::vector<unsigned>& data, unsigned value, unsigned& comparisons)

{

int index(-1);

for( comparisons=0; comparisons<data.size() && index<0; ++comparisons)

if (data[comparisons] -1)

{

std::cout << "not found. ";

}

else

{

std::cout << "found at index " << binary_index << ". ";

}

std::cout << "Comparisons: " << binary_comparisons << std::endl;

}

}

What is the difference between a data file and a program file?

Technically they're BOTH "data" files, it's just that one is organized in a way that it can be "executed" by the computer.

Write an algorithm to find the transpose of a matrix?

-Algorithm-

1.START

2.Take m1 and m2 as integer matrix.

3.Input the values for original matrix and store it in m1.

4.Convert each row of the matrix ma in to column of matrix m2.

5.Display both matrix m1 and m2.

6.STOP.

'C' program

#include<stdio.h>

void main()

{

int m1[3][3],m2[3][3];

int i,j;

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

{

for(j=0;j<3;j++)

{

printf("\n Enter value of%d rows and %d cols: ",i+1,j+1);

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

}

}

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

{

for(j=0;j<3;j++)

{

m2[j][i]=m1[i][j];

}

}

printf("\n Original Matrix");

printf("\n ---------------\n");

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

{

for(j=0;j<3;j++)

{

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

}

printf("\n") ;

}

printf("\n Transpose Matrix");

printf("\n ----------------\n");

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

{

for(j=0;j<3;j++)

{

print("%d\t",m2[i][j]);

}

printf("\n")

}

Pointer to 3 dimensons array?

If the array is static you can simply point at the first element. For dynamic arrays you can allocate a contiguous block to a single pointer which can then be subdivided using a one-dimensional array of pointer to pointers, each of which points to a one-dimensional array of pointers, each of which points to a separate object within the array. For extremely large arrays, however, it is better to split the elements into separate one-dimensional arrays, by creating a one-dimensional array of pointer to pointers first, then allocating each of those pointers to a separate one-dimensional array of pointers, each of which points to a separate one-dimensional array of objects. Either way, you must destroy all the individual arrays in the reverse order of creation.

Write a C program that reads the contents of a text file and print the contents to the screen line by line preceded by line number?

#include<stdio.h>

#include<conio.h>

void main(void)

{

FILE *fp;

char ch;

int count=0;

clrscr();

fp=fopen("seo.c","r");

while((ch=fgetc(fp))!=EOF)

{

if(ch=='\n')

{

count++;

printf("%d\n",count); }

else

printf("%c",ch);}

fclose(fp);

getch();

}

How to declare scalar variable in ASP .Net?

you must have forgotten to add parameters , in sql and asp.net when u want some queries u must add parameter to your query like cmd.Parameters.AddWithValue("@student_name", txtName.Text); if u dont add @student_name it will show u a error needing to declare sclar variable

Meaning of signed integer in c language?

signed integer means that it has a sigh (+ or -). Using another words you say that signed variable can be positive as well as negative. unsigned variables can be only positive.

Check whether the character entered through the keyboard is a lower case alphabet or not by using conditional operater?

# include <stdio.h>

# include <conio.h>

int main ()

{

char a;

printf("Enter the number");

scanf("%c", &a);

(a>=97 && a<=122)?

printf("\n\nIt is a lower case alphabet"):printf("\n\nIt is not a lower case alphabet");

getch();

getch();}

Longest common subsequence problem program in c?

#include<stdio.h>

#include<string.h>

int max(int a,int b)

{

return a>b?a:b;

}//end max()

int main()

{

char a[]="xyxxzxyzxy";

char b[]="zxzyyzxxyxxz";

int n = strlen(a);

int m = strlen(b);

int i,j;

for(i=n;i>=1;i--)

a[i] = a[i-1];

for(i=m;i>=1;i--)

b[i] = b[i-1];

int l[n+1][m+1];

printf("\n\t");

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

{

for(j=0;j<=m;j++)

{

if(i==0 j==0)

l[i][j]=0;

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

l[i][j] = l[i-1][j-1] + 1;

else

l[i][j] = max(l[i][j-1],l[i-1][j]);

printf("%d |",l[i][j]);

}

printf("\n\t");

}

printf("Length of Longest Common Subsequence = %d\n",l[n][m]);

return 0;

}

How function can be used as reusability?

You mean reusable? Well it can be serially or parallel reusable.

How do you do matrix multiplication in c using structure?

You took an example of The Product AB is determined as the dot products of the ith row in A and the jth column in B,placed in ith row and jth column of the resulting m x p matrix C.

so: this may help you.

#include <stdio.h>

#include <stdlib.h>

// function prototypes

void Matrix_Mult( int a1[][3], int a2[][4], int a3[][4] );

void Matrix_MultAlt( int a1[][3], int a2[][4], int a3[][4] );

int dot3(const int a1[][3], const int a2[][4], int row, int col);

void PrnNx4 (int ar[][4], int n);

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

// Function: main(void)

// Description:

// demonstration of Matrix Multiplication

//

// Programmer: Paul Bladek

//

// Date: 10/31/2001

//

// Version: 1.0

//

// Environment: Hardware:IBM Pentium 4

// Software: Microsoft XP with .NET framework for execution;

// Compiles under Microsoft Visual C++.Net 2005

//

// Calls: Matrix_Mult(int a1[][3], int a2[][4], int a3[][4])

// Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4])

// PrnNx4(int ar[][4]

//

//

// Parameters: int a1[][3] -- left matrix

// int a2[][4] -- right matrix

// int a3[][4] -- answer matrix

//

// Returns: EXIT_SUCCESS

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

int main(void)

{

int A[2][3] = {{1, 3, 4},

{2, 0, 1}},

B[3][4] = {{1, 2, 3, 1},

{2, 2, 2, 2},

{3, 2, 1, 4}},

C[2][4] = {{0, 0, 0, 0},

{0, 0, 0, 0}};

Matrix_Mult(A, B, C);

PrnNx4(C, 2);

Matrix_MultAlt(A, B, C); // alternate form that calls dot3

PrnNx4(C, 2);

return EXIT_SUCCESS;

}

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

// Function: Matrix_Mult(int a1[][3], int a2[][4], int a3[][4])

// Description:

// multiplies a 2X3 matrix by a 3X4 matrix

//

// Programmer: Paul Bladek

//

// Date: 10/31/2001

//

// Version: 1.0

//

// Environment: Hardware:IBM Pentium 4

// Software: Microsoft XP with .NET framework for execution;

// Compiles under Microsoft Visual C++.Net 2005

//

// Calls: None

//

// Called By: main()

//

// Parameters: int a1[][3] -- left matrix

// int a2[][3] -- right matrix

// int a3[][3] -- answer matrix

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

void Matrix_Mult(int a1[][3], int a2[][4], int a3[][4])

{

int i = 0;

int j = 0;

int k = 0;

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

for( j = 0; j < 4; j++)

for( k = 0; k < 3; k++)

a3[i][j] += a1[i][k] * a2[k][j];

}

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

// Function: Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4])

// Description:

// multiplies a 2X3 matrix by a 3X4 matrix -- Alternate Form

//

// Programmer: Paul Bladek

//

// Date: 10/31/2001

//

// Version: 1.0

//

// Environment: Hardware:IBM Pentium 4

// Software: Microsoft XP with .NET framework for execution;

// Compiles under Microsoft Visual C++.Net 2005

//

// Calls: dot3(const int a1[][3], const int a2[][4], int row, int col)

//

// Called By: main()

//

// Parameters: int a1[][3] -- left matrix

// int a2[][3] -- right matrix

// int a3[][3] -- answer matrix

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

void Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4])

{

int i = 0;

int j = 0;

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

for( j = 0; j < 4; j++)

a3[i][j] = dot3(a1, a2, i, j);

}

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

// Function: dot3(const int a1[][3], const int a2[][4], int row, int col)

// Description:

// dot product of a1 row and a2 col

//

// Programmer: Paul Bladek

//

// Date: 10/31/2001

//

// Version: 1.0

//

// Environment: Hardware:IBM Pentium 4

// Software: Microsoft XP with .NET framework for execution;

// Compiles under Microsoft Visual C++.Net 2005

//

// Calls: None

//

// Called By: Matrix_MultAlt(int a1[][3], int a2[][4], int a3[][4])

//

// Parameters: int a1[][3] -- left matrix

// int a2[][3] -- right matrix

// int row -- the row number

// int col -- the column number

//

// Returns: the dot product

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

int dot3(const int a1[][3], const int a2[][4], int row, int col)

{

int k = 0;

int sum = 0;

for( k = 0; k < 3; k++)

sum += a1[row][k] * a2[k][col];

return sum;

}

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

// Function: PrnNx4(int ar[][4], int n)

// Description:

// prints out an NX4 matrix

//

// Programmer: Paul Bladek

//

// Date: 10/31/2001

//

// Version: 1.0

//

// Environment: Hardware:IBM Pentium 4

// Software: Microsoft XP with .NET framework for execution;

// Compiles under Microsoft Visual C++.Net 2005

//

// Called By: main()

//

// Parameters: int ar[][4] -- matrix to print

// int n -- number of elements

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

void PrnNx4 (int ar[][4], int n)

{

int i = 0;

int j = 0;

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

{

for( j = 0; j < 4; j++)

printf("%4d", ar[i][j]);

putchar('\n');

}

}

How many bytes are read in pointers by pointers dereferencing?

When you dereference a pointer you "read" the number of bytes determined by the pointer's type. That is, a char pointer dereferences a single byte while an int pointer dereferences 4 bytes (assuming a 32-bit int) -- regardless of the type actually stored at that address. However, note that a pointer can only actually point at a single byte since it only has storage for a single memory address. How many additional bytes are dereferenced is entirely dependant on the type of the pointer.

To determine how many bytes are actually allocated to an address, use the sizeof operator, passing a dereferenced pointer (the pointer must point at the start of the allocation). If the pointer points at several elements of the same type (an array), then divide the total bytes by the size of the pointer's type to determine the number of elements in the array.

Functions except gets and puts in c?

printf , scanf , getchar, putchar, getc are the other operators in C except gets and puts..

How do you reinstall c?

Your question makes no sense, you cannot "reinstall" programming languages (or vitamines, or letters, or Roman numbers)

Where do I find information about a J C Higgins 4xscope?

Weaver was the contractor for J C Higgins rifle scopes you are dealing with 46 to 55 year old product the 22 scopes came in two basic veriaties the delux grade rifle man very nice 4 power and simpler more basic version simply marked J C Higgins Sears and Roebuck & Co. it to is a 4 power the lesser version were sold in combination wit JCH .42 bolt action rifles 103 vendor code for Marlin the rifleman scopes were supplied with JCH model 28 30 and 33 22 semi auto and pump action rifles wich were marked 583 Sears House brand made by Sears / High standard . Sears owned High standard back then like Kenmore

What are advantages of visual c plus plus?

Well, there are really no disadvantages. If you are just starting programming, I would recommend using Visual Basic 2008. It is extremely easy to learn, and endless possiblities as far as making your program goes. The download link is right here: http://www.microsoft.com/express/vb/Default.aspx#webInstall It is free. If you are getting the registry key, make sure to use Internet Explorer.

The statement char ch equals 'z' would store in ch?

The statement char ch = 'z'; would store the character 'z' in the variable ch. This means that the variable ch would hold the value 'z'.