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 c plus plus program to find all number from 112 to 212 with the cumulative total?

int total = 0;

int n;

for( n = 112; n <= 212; ++n) {

total += n;

}

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

C program to read and print a scalar matrix?

Here is the C program to check whether the inputted matrix is scalar matrix or not. ( its not my creation, its get from other website,am not check)

#include<stdio.h>

#include<conio.h>

int main()

{

int a[10][10],i,j,m,n,f=0;

printf("Enter the order of the matrix\n");

scanf("%d%d",&m,&n);

printf("Enter the matrix\n");

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

{

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

{

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

}

}

if(m!=n)

{

printf("The matrix is not identity");

}

else

{

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

{

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

{

if((i==j&&a[i][j]!=a[0][0])(i!=j&&a[i][j]!=0))

{

printf("The matrix is not scalar\n");

f=1;

break;

}

}

if(f==1)

{

break;

}

}

if(f==0)

{

printf("The matrix is scalar\n");

}

}

getch();

return 0;

}

3 examples of if else statement?

if (i==1) puts ("i==1");

if (i==2) if (j==3) puts ("i==2, j==3);

else puts ("i==2, j!=3");

if (i==2) if (j==3) puts ("i==2, j==3);

else puts ("i==2, j!=3");

else if (j==3) puts ("i!=2, j==3);

else puts ("i!=2, j!=3");

What is the programming language used by motoman?

The Yaskawa Electric Corporation uses a wide variety of programming languages. Robots are typically controlled via a high-level interpretive language or script. These languages are typically bespoke languages, often developed in-house, but are generally very easy to use due to their high-level nature. These languages are used to invoke the machine's low-level routines which are typically developed in C++.

How many structure variables of a given type can you use in a C program?

You can use unlimited number of variables for a structure and you can also declare array of structures.

Is struct is user defined data type?

yes, a structure is a user-made data type so that user can manipulate multiple data types simultaneously. a structure covers up sum limitation of arrays as in it provides heterogenous data type.

Write a program in java to print total salary of an employee?

/* hra=25% of salary

* ca=15% of salary

* ea=10% of salary

* total salary= hra + ca + ea

*/

import java.io.*;

class pay

{

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the salary: ");

int sal=Integer.parseInt(in.readLine());

float tsal=sal;

if(sal>5000)

{

float hra,ca,ea;

hra=sal/4;

ca=(sal*3)/20;

ea=sal/10;

tsal=sal+hra+ca+ea;

}

System.out.print("Total Salary= "+tsal);

}

}

What is a structure in c programing?

A rectangle might have a width, a height, a color, and a fill

pattern. C lets us organize these four items into one group called a

structure. Example

struct rectangle {

int width; /* Width of rectangle in pixels */

int height; /* Height of rectangle in pixels */

color_type color; /* Color of the rectangle */

fill_type fill; /* Fill pattern */

}; Another example suppose we want to record

the time a runner completes each lap of a four -lap race. We define a structure to

store the time:

struct time {

int hour; /* hour (24 hour clock ) */

int minute; /* 0-59 */

int second; /* 0-59 */

}; A rectangle might have a width, a height, a color, and a fill

pattern. C lets us organize these four items into one group called a

structure. Example

struct rectangle {

int width; /* Width of rectangle in pixels */

int height; /* Height of rectangle in pixels */

color_type color; /* Color of the rectangle */

fill_type fill; /* Fill pattern */

}; Another example suppose we want to record

the time a runner completes each lap of a four -lap race. We define a structure to

store the time:

struct time {

int hour; /* hour (24 hour clock ) */

int minute; /* 0-59 */

int second; /* 0-59 */

};

What is 5.2 in percent 5.2f in c language?

while printing if we specify printf("%5.2f",answer)

5 here means that the value of answer will print after leavin 5 space from the begining of the screen

while 2 means that we want float to show 2 nos. after the decimal place

How is compiler and run of Linux c program with example?

You start by writing your c code in a text editor. An example of some c code (syntax not guaranteed to be correct):

#include <stdio.h>

int main ();

{

printf("Hello, World!!\n");

return 0;

}

Then, you save this file, as whatever, for this example as 'Hello.c'.

Then, open a Terminal window (command line) and change your directory to where your Hello.c is saved at, using 'CD <filepath>' (sans brackets). Then, type 'gcc Hello.c -o Hello'. The 'gcc' command compiles your code, and the -o flag changes the output filename to whatever you specify, in this case Hello. Then, to run your new program, type './Hello'. The ./ specifies the current directory.

Congrats, you have written, compiled, and ran your first program in C using a Linux platform.

Write a program in c plus plus to read 2 numbers and an operator then calculate result defined of this operator?

#include<iostream>

#include<string>

#include<sstream>

unsigned input_num (std::string prompt)

{

unsigned id = 0;

while (1)

{

std::cout<<prompt<<": ";

std::string input="";

getline (std::cin, input);

std::stringstream ss (input);

if (ss>>id)

break;

std::cout<<"Invalid input.\n";

}

return (id);

}

char input_op (std::string ops)

{

char op = 0;

while (1)

{

std::cout<<"Enter an operator ("<<ops<<"): ";

std::string input="";

getline (std::cin, input);

std::stringstream ss (input);

if (ss>>op && ops.find (op) != std::string::npos)

break;

std::cout<<"Invalid input.\n";

}

return (op);

}

int main()

{

unsigned num1 = input_num ("Enter a number");

unsigned num2 = input_num ("Enter another number");

// division is invalid if num2 is zero

char op = input_op (num2?"+-*/":"+-*");

unsigned result = 0;

switch (op)

{

case ('+'): result = num1+num2; break;

case ('-'): result = num1-num2; break;

case ('*'): result = num1*num2; break;

case ('/'): result = num1/num2;

}

std::cout<<num1<<op<<num2<<'='<<result<<std::endl;

}

What did the P C Modem invented By Dennis C. HayesDo?

The modem, which is short for modulator/demodulator, "packages" data according to a certain protocol for transmission to another computer, and it unpacks incoming data so the receiving computer can understand it.

What statement can be used to transfer control back to the main program after the execution of a subroutine?

It depends what language you are using. Structured languages provide the easiest method, simply call the function containing your subroutine and control will automatically return to the point of the call when the function ends. You can even use functions to return a value to the caller. If functions are not an option, the language might provide a gosub statement. This is similar to a goto statement but returns control to the caller, much like a function would in a structured language.

What is the maximum time limit before my decree nisi runs out?

There is no time limit for the Petitioner to apply to the Court for Decree Nisi once the Acknowledgement of Service has been received from the Respondent, however if the time lapse is excessive it may be necessary for the Petitioner to explain the reason for the delay.

Once the Decree Nisi has been granted the Petitioner can apply for Decree Absolute six weeks later.

If the Petitioner does not apply to have the Decree made absolute, once three months have elapsed from the earliest date on which the Petitioner could have applied for Decree Absolute, the Respondent may apply for Decree Absolute.

Therefore the earliest that the Respondent can apply is three months and six weeks after the pronouncement of the Decree Nisi. If neither the Petitioner nor Respondent has applied for the Decree Absolute after twelve months then any application for Decree Absolute must be referred to a District Judge who must ensure that various information is provided."

What are the five 5 major Operating system activities with regards to process management?

a. The creation and deletion of both user and system processes

b. The suspension and resumption of processes

c. The provision of mechanisms for process synchronization

d. The provision of mechanisms for process communication

e. The provision of mechanisms for deadlock handling

Write a socket program in C to implement a listener and a talker?

In socket programming, there are two sides to every conversation: the listener (or server), and talker (the client).

The server first opens a desired port, receives a socket handle, and begins listening for connections. It polls the socket every so often to listen for attempted connections by clients. Once a connection has been established, communication begins.

A client merely indicates an IP address and port to connect to. Once the connection is made, communication begins.

Then there are blocking and non-blocking sockets, which applies to both servers and clients. Blocking socketsforce the program to wait until there's activity before continuing its operation. So a server process will pause while waiting for a connection, and a client process will pause while waiting for the server to send data.

Under most conditions, non-blocking sockets are preferred. This allows the program to give up timeslices to the operating system, as well as conduct any activities in the background like listening to multiple connections (for servers).

Writing a socket program is about the same between Windows and Unix/Linux based systems, but there are some differences in setting up non-blocking sockets as well as initializing and closing the socket interface.

More information on both Win32 and Linux socket programming can be found in the related links below.

What is the significance of test condition in a loop?

The test condition in a loop is what's used to determine when the loop should end.

What is lint in c language?

Lint is suspicious or non-portable code. Lint is also the name of a program that looks for suspicious or non-portable code.

Different parts of the C language?

Lexical elements are groups of characters that may legally appear in a source file. Common categories for lexical elements are keywords, numeric and alphanumeric constants, variable references and special tokens, but the exact categorization is subject to the compiler's implementation.