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 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;

}

What is the difference bw cached memory and uncached memory?

Cached memory is read each time the file is read. This can increase the computers performance. Uncached memory is not read each time.

Who wrote the Bash Shell?

The Bourne Again Shell (bash) was originally written by Brian Fox. It is maintained as part of the GNU project and has several developers, now led by Chet Ramey.

In IT What is the difference between a user variable and a system variable?

A user variable is a memory which is used in specific function or functionality. A system variable is kinda of generic, accessible to all users of the system. It does not bind to specific process as such.

How do you get an A plus in class when im a C?

To get an A+ in class when you are a C, you work very, very hard and get all A+'s from here on end.

Unfortunately, if the professor grades on the average of all your work, your C status might prevent you from becoming an A student, particularly if you are near the end-of-term. Talk to the professor.

Often, C status is an indication of inability to meet the demands of the work. This could be due to not being prepared to do the work, being overloaded with coursework, or not being committed to doing the work, possibly due to the tendency to party, drink, do drugs, etc.

If the latter is true, and you really want an A, you have some hard decisions to make. Talk to your Counselor. School is not a party. School is a job, and your job is to work at school and do well enough to be recognized by potential employers.

Sorry for the preaching, but it is true. The first two "inabilities" applied to me, though I knew many to which the third "inability", partying, brought them down. Now I pay for it by not having a degree. Even though I am a successful engineer, some things are out of my grasp because of the lack of the degree.

Note: You have to concentrate on what you are doing, for example if you ask a question about grades, please make sure you don't put it in the 'Programming' category.

How do you know whether the function is 'user define' or 'library functions'?

If you have written it yourself, then it is the former, otherwise it is the latter.

I am getting core dump in sun OS for a c plus plus program. But the same program is running without generating any core at a different machine with same sun OS.. what may be the reason for this.?

What OS is the other machine, and what program are you running? I believe Sun uses a different architecture than most other machines, but I can't remember off the top of my head.

What is MFC?

MFC is the Microsoft Foundation Class library which provides the Windows Application Framework Extensions (AFX). The library is really nothing more than a class wrapper to make it easier to work with the Windows API using C++ classes. Although still used today it has largely been replaced by the .NET framework.

How do you write roulette program in C?

try this:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <time.h>

#define MAX_LINE_LEN 80

#define WS1 " \t$"

#define WS2 " \t"

#define N_MAX 36

const char *p0 = "How much money do you have?";

const char *p1 = "Enter 1 for odd, 2 for even";

const char *p2 = "Place your bet";

typedef enum { false = 0, true } bool;

int getInt(const char *prompt, const char *ws);

int main(int argc, char *argv[]) {

time_t t;

int balance, bet, choice, ball;

bool betOk, win;

srand((unsigned)time(&t));

balance = getInt(p0, WS1);

while (balance > 0) {

do {

choice = getInt(p1, WS2);

} while ((choice < 1) (choice > 2));

for (betOk = false; betOk false) {

printf("invalid input, try again: ");

}

}

return z;

}

What is the Syntax of remainder operator in c language?

% = Shift + 5

Example:

printf ("7%%3=%d\n", 7%3);

result: 7%3=1

one more thing this operator works only with integer type numbers not floating numbers.

How do you program a robot?

Many ways, depending on the robot complexity, how it is being ran and other factors. Conventional 'robots' have motors, sensors, and a computer. Usually the computer runs a program that does all the programming, this can be done in ANY language that the programmer fancies the most. There are some robots called BEAM robots that aren't programmed using code or programming, but instead react as a neural network (like an organic brain) or reactions from the pre built electronics in the robot. This is a VERY open question

Write a C program to implement relocatable loader?

#include<stdio.h>

#include<conio.h>

#include<string.h>

#include<stdlib.h>

struct object_code

{

int locctr;

char add[10];

}obcode[300];

void main()

{

char input[100][16],output[100][16],binary[20],address[20],stloc[10];

int len,bitmask,loc,tlen=0,tloc,textloc,i=0,location,j,k,count=0,start,n,num=0,inc=0;

FILE *fp1,*fp2;

clrscr();

fp1=fopen("linput.dat","r");

fp2=fopen("reloadout.dat","w");

printf("Enter the location where the program has to be loaded:");

scanf("%s",stloc);

start=atoi(stloc);

location=start;

tloc=start;

fscanf(fp1,"%s",input[i]);

while(strcmp(input[i],"T")!=0)

{

strcpy(output[i],input[i]);

i++;

fscanf(fp1,"%s",input[i]);

strcpy(output[i],input[i]);

}

itoa(start,output[2],10);

while(strcmp(input[i],"E")!=0)

{

strcpy(output[i],input[i]);

if(strcmp(input[i],"T")==0)

{

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

{

i++;

fscanf(fp1,"%s",input[i]);

strcpy(output[i],input[i]);

}

bitmask=atoi(output[i]);

itoa(bitmask,binary,2);

strcpy(output[i],NULL);

textloc=atoi(output[i-2]);

textloc=textloc+start;

itoa(textloc,output[i-2],10);

for(n=0;n<(textloc-(tloc+tlen));n++)

{

strcpy(obcode[inc].add,"xx");

obcode[inc++].locctr=location++;

}

tlen=atoi(output[i-1]);

tloc=textloc;

k=0;

}

else

{

if(binary[k]==1)

{

num=0;

len=strlen(output[i]);

strcpy(address,NULL);

for(j=2;j<len;j++)

{

address[num]=output[i][j];

output[i][j]='\0';

num++;

}

loc=atoi(address);

loc=loc+start;

itoa(loc,address,10);

strcat(output[i],address);

}

k++;

len=strlen(output[i]);

num=0;

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

{

obcode[inc].add[num++]=output[i][n];

if(num>1)

{

obcode[inc++].locctr=location++;

num=0;

}

}

}

i++;

fscanf(fp1,"%s",input[i]);

}

strcpy(output[i],input[i]);

i++;

fscanf(fp1,"%s",input[i]);

loc=atoi(input[i]);

loc=loc+start;

strcpy(output[i],itoa(loc,address,10));

count=0;

i=0;

n=0;

fprintf(fp2,"%d\t",obcode[n].locctr);

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

{

fprintf(fp2,"%s",obcode[n].add);

i++;

if(i>3)

{

fprintf(fp2,"\t");

i=0;

count++;

}

if(count>3)

{

fprintf(fp2,"\n%d\t",obcode[n+1].locctr);

count=0;

}

}

getch();

}

What programming language should I learn if I want to program softwares?

There is a lot of different ones, so it really depends on what kind of software you want to design.

Can you use two main function?

AnswerYes, if they are in separate source-files, and one of them is static. Of course the execution will start with the non-static 'main' function.

Answer1. If it is a multithreaded operating system (and it probably is) then you can have the Main method start another thread on another method.
2. For C programs in a Win32 console project template, Visual Studios C++ does not allow static on a main method or two main methods in one application, but you can create two separate projects which will create two separate programs.

Using function create a program that will ask the user if he wants to compute the perimeter or the area of the triangle in your main program If the perimeter is wanted ask the measures of the three si?

//Perhaps this is what you want.

//@author Rosencrantz

import java.util.Scanner;

class TriangleFun

{

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

boolean done = false;

while(true)

{

System.out.print("Calculate AREA or PERIMETER? Type DONE to quit.");

String input = scan.nextLine().trim();

if(input.equalsIgnoreCase("DONE"))

break;

if(input.equalsIgnoreCase("AREA"))

{

System.out.print("Enter the base length: ");

double base = scan.nextDouble();

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

double height = scan.nextDouble();

System.out.println("Area is: " + (1/2.0) * base * height);

}

else

{

System.out.print("Enter length of side 1: ");

double length1 = scan.nextDouble();

System.out.print("Enter length of side 2: ");

double length2 = scan.nextDouble();

System.out.print("Enter length of side 3: ");

double length3 = scan.nextDouble();

System.out.println("Perimeter is: " + (length1 + length2 + length3));

}

scan.nextLine();

}

}

}

//A better edited version is in the links

What computer language java or C plus plus should you use to design an app for the ipod or should i use a software?

You would use neither Java nor C++, you would use Objective-C, in conjunction with the Apple iPod API (iPod Library Access).

What function that call themselves are called to c programme?

Functions in C language may call themselves (ie can be recursive) without restrictions.

How do you delete an ith element in singly linked list?

You will need to traverse the list i times to get to the element you want deleted. Each time you go thru the list you will need to remember the forward pointer from the previous element because when you get to the element you want to delete the previous forward pointer needs to be pointed to the I + 1 element of the list.