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

C program to find the largest and smallest of three numbers using IF IF ELSE?

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c;

clrscr();

printf("Enter any three numbers");

scanf("%d%d%d",&a,&b,&c);

if(a>b&&a>c)

printf("A is greatest");

else if(b>a&&a>c)

printf("B is greatest");

else if(c>a&&c>b)

printf("C is greatest");

if(a<b&&a<c)

printf("A is smallest");

else if(b<a&&b<c)

printf("B is smallest");

else if(c<a&&c<b)

printf("C is smallest");

getch();

}

How can you accept sum and print numbers without creating variables?

It is very easy.

The program begins here.....

/*Program to sum and print numbers without creating variables*/

#include<stdio.h>

main()

{

clrscr();

printf("%d+%d=%d",5,2,5+2);

getch();

}

/*Program ends here*/

Now just by changing the numbers in the "printf" statement we can add, subtract, multiply and divide the numbers without using variables.

Hence the problem is solved..........

Why in Access can you not set an index to an OLEobject?

You use OLE Object fields to insert documents (Word, PDF, bitmap images, etc) into records. The OLE Object itself is actually a binary data field and the only way to compare any two OLE Objects is to compare the binary data itself. This makes no sense because we normally compare documents by type, size, author, title, creation date, last modified date, and so on, we don't compare their physical representations (the binary data itself). If we want to sort documents, we must extract the properties we wish to sort by and insert them as separate fields in our records, and use those fields as our index/sort keys.

Sometimes we really do need to use binary data as a sort key, but we cannot use an OLE Object to store that data because OLE Objects cannot be used as sort keys. Instead, we must use the built-in binary data field which can be indexed and sorted. Binary data fields can be fixed-length (binary) or variable length (varbinary). Note that OLE Objects are variable length with a theoretical limit of 1 GB, which is yet another reason why they are unsuitable for indexing. The fixed-length binary field has an upper limit of 510 bytes, making it ideal for indexing and sorting small amounts of binary data.

Unfortunately, the built-in binary data fields cannot be created using the table designer for no practical reason other than Microsoft decreed that you couldn't. Instead you must use DDL or VBA/DAO. Using DDL, the following will create a binary and a varbinary field. For completeness, I've also included an OLE Object field:

CREATE TABLE tblBinTestSQL (

Id counter NOT NULL PRIMARY KEY,

VarbinaryColumn varbinary(100) NULL,

BinaryColumn binary(100) NULL,

OLEColumn Longbinary NULL

);

Here's the VBA/DAO method of achieving the same thing:

Public Sub CreateBinaryColumns()

Dim td As DAO.TableDef

Dim db As DAO.Database

Dim fd As Field

Set db = CurrentDb

Set td = db.CreateTableDef("tblBinTestDAO")

Set fd = td.CreateField("ID", DataTypeEnum.dbLong)

fd.Attributes = fd.Attributes Or dbAutoIncrField

td.Fields.Append fd

Set fd = td.CreateField("BinaryColumn", DataTypeEnum.dbBinary, 100)

fd.Attributes = fd.Attributes Or dbFixedField

td.Fields.Append fd

Set fd = td.CreateField("VarbinaryColumn", DataTypeEnum.dbBinary, 100)

td.Fields.Append fd

Set fd = td.CreateField("OLEColumn", DataTypeEnum.dbLongBinary)

td.Fields.Append fd

db.TableDefs.Append td

End Sub

Once you have at least one table with a binary or varbinary field, you can simply copy that field to other tables. You can also modify the properties of those fields in table designer; you just can't use table designer to create those fields.

How do you convert the hexadecimal number ff to binary?

Any base that is itself a power of 2 is easily converted to and from binary. With base 4, each digit represents 2 bits. With base 8 (octal), each digit represents 3 bits. And with base 16 (hexadecimal), each digit represents 4 bits. Thus two hexadecimal digits represent an 8-bit binary value. This is convenient because we typically refer to a unit of computer memory as an 8-bit byte, thus every byte value can be represented using just 2 hex digits. If we had a system with a 9-bit byte we'd use 3 octal digits instead. A 24-bit value can either be represented using 6 hex digits or 8 octal digits.

To convert a hexadecimal value to binary, we simply consult the following table (note that 0x is the conventional prefix for a hexadecimal value):

hex = binary

0x0 = 0000

0x1 = 0001

0x2 = 0010

0x3 = 0011

0x4 = 0100

0x5 = 0101

0x6 = 0110

0x7 = 0111

0x8 = 1000

0x9 = 1001

0xA = 1010

0xB = 1011

0xC = 1100

0xD = 1101

0xE = 1110

0xF = 1111

Here, hexadecimal digit 0xF has the binary value 1111, thus 0xFF would be 11111111. Note that the bit patterns are in the same order as the hexadecimal digits. Thus 0x0F becomes 00001111 and 0xF0 becomes 11110000.

Knowing this, we can easily convert binary values into hexadecimal, we simply divide the binary value into groups of 4 bits and convert each group to the corresponding hex digit. Thus 101101001100 becomes B4C (1011=B, 0100=4 and 1100=C). If there aren't enough bits, we simply pad the first group with leading zeroes.

We can use a similar technique to convert between octal and binary, we simply divide the bits into groups of 3:

octal = binary

00 = 000

01 = 001

02 = 010

03 = 011

04 = 100

05 = 101

06 = 110

07 = 111

Note that a leading 0 is the conventional prefix for octal values. Thus binary value 100010 would be written 042 in octal to avoid confusion with 42 decimal.

What is TRACERT and when is it function?

Short for traceroute: it is a utility program to check IP-routing.

When you start it, e.g: tracert www.ibm.com

What is d command for square root in C programming in Linux?

No commands in C; the name of function sqrt is sqrt (include math.h; and use -lm at linkage)

What is a flow void seen in the brain?

A flow void in the brain refers to an area on an MRI scan where blood flow is absent or significantly reduced, typically seen in blood vessels. This phenomenon is often characterized by a dark appearance on T2-weighted images, indicating the presence of high-velocity blood flow or the absence of blood in certain regions. Flow voids are commonly associated with normal vascular structures, such as arteries and veins, but can also indicate pathological conditions, such as vascular occlusions or malformations. Identifying flow voids is crucial for diagnosing various neurological conditions.

What is structure packing?

Structured Packing ----www.rubbersealing.com

Gauze structured packing from T.C.I is recognized worldwide as the leader in applications with low liquid-loading systems or temperature-sensitive compounds. Vacuum distillations, specialty chemicals, and many highly refined, value-added processing operations also benefit from gauze packing efficiency-improving capabilities.

Koch-Glitsch wire gauze packing is the most efficient commercial tower packing available on the market today. Koch-Glitsch wire gauze packing has a proven track record of providing superior performance in thousands of diverse applications around the world. Koch-Glitsch Mass Transfer Technology has more than 85 years of combined experience. Our process and design expertise, coupled with superior manufacturing and pilot plant test facilities, provide Koch-Glitsch customers with solutions to mass transfer problems.

The packing is fabricated from sheets of metal gauze. Type BX gauze structured packing, with 500 m2/m3 specific surface area, is manufactured using the same geometric configuration as FLEXIPAC® packing. For even higher requirements, Type CY gauze packing with 750 m2/m3 specific surface is available.

Matching this high-efficiency packing with our custom-designed internals offers our customers complete systems engineered to maximize tower performance.

Features: for Gauze structured packing

Hgih number of theoretical plate, best loading factor 1.5-2m/s, min. liquid load 0.2m3/m2.h。

Materials: for Gauze structured packing

stainless steel, carbon steel, 304, 316L, phosphor bronze etc. Upon clients' request.

Spec. for Gauze structured packing

C program to find the sum of odd positioned digits and even positioned digits of a number seperately?

#include<stdio.h>

#include<conio.h>

main()

{

int n,s,r,t;

clrscr();

printf("enter n");

scanf("%d",&n);

s=0;t=0;

while(n!=0)

{

r=n%10;

{

if(r%2!=0)

t=t+r;

if(r%2==0)

s=s+r;

}

n=n/10;

}

printf("sum of even position digits%d\n",s);

printf("sum of odd position digits%d\n",t);

getch();

}

C program for string replacing function using pointers?

What U exactly want?

Here I am giving "complete c program for string manipulation using pointer "

/*********************************PRACT.*********************************
Title:: STRING MANIPULATION(functions implemented with pointers).
Operations covered :1:Accept 2:Display 3:String Length 4:String Copy 5:String Reverse
------------------- 6:Check for Palindrome 7:String Comparison
8:Substring(String Searching) 9:StrConcatinate
*************************************************************************/
#include
#include
/*
I Am Just Giving FUNCTION DEFINATION 1'st & then "main function.
*/

//Fun.str
void str()
{ int i;
printf("\n\n");
for(i=0;i<30;i++)
printf("*~");
}
//Fun.1 for Accepting string.
void Accept(char *a)
{ printf("\nEnter The String : ");
scanf("%s",a);
}
//Fun.2 Displaying string which is accepted in Fun.1
void Disp(char *a)
{ printf("\n\tString =%s",a);
}

//Fun.3 Displaying length of string.
int len(char *a)
{ char *p;
int count=0;
for(p=a;*p!='\0';p++)
count++; //incrementing count till for loop exists
return(count);
}

//Fun.4 To copy string a/b.
void copy(char *a,char *r)
{ while(*a!='\0')
{ *r=*a; //coping the string character by character.
r++;a++;
}
*r='\0';
}

//Fun.5 To find out reverse of string a/b.
void reverse(char *a)
{ char *p,*q;
int count=0;
for(p=a;*p!='\0';p++)
count++;
while(*p!='\0')
p++;
while(count>0)
{ p--;
count--;
printf("%c",*p);
}
}

//Fun.6 Check for palindrome
int pl(char *a)
{ char *p,*q;
p=q=a;
while(*q!='\0')
q++; // q represents the null character.
q--;//q represents the last character of string.
while(p{ if(*p!=*q)
return(0);
p++;q--;
}
return(1);
}

//Fun.7 comparing 2 strings .
int compare(char *a,char *b)
{ while(*a!='\0')
{ if(*a==*b)
return(1);
a++;b++;
}
return(0);
}

//Fun.8 searching a string
int Substr(char *a ,char *b)
{ int N1,N2,count=0;
char *p,*q,*k;
for(N1=0;*(a+N1)!='\0';N1++); //N1=length of string1
for(N2=0;*(b+N2)!='\0';N2++); //N2=length of string2

for(p=a;p<=a+N1-N2+1;p++)
{ k=p;
for(q=b;*k==*q&& *q!='\0';q++,k++); // string b[] is matched in string a[] from the position p.
if(*q=='\0')
{ count++;
printf("\nLOCATION = %d",p-a+1);
}
} return(count);
}

//Fun.9 String concatination.
void StrCon(char *a,char *b)
{ char *p,*q;
while(*a!='\0')
a++;
while(*b!='\0')
{ *a=*b;
a++; b++;
}
*a='\0';
}


/**************** "main function " ****************************/
void main()
{ char a[25],b[25],c[25],s;
int k,l;
clrscr();
do
{str();
printf("\n\t\tSTRING MANIPULATION WITH POINTER.");
str();
printf(" \n\t1:Accept \n\t2:Display \n\t3:String Length \n\t4:String Copy \n\t5:String Reverse \n\t6:Check for Palindrome \n\t7:String Comparison\n\t8:Substring(String Searching) \n\t9:StrConcatinate \n\t10:Exit.");
printf("\nEnter The Choice..... . . . . " );
scanf("%d",&k);
switch(k)
{ case 1:Accept(a);
break;
case 2:Disp(a);
break;
case 3:l=len(a);
printf("Length of string %s = %d",a,l);
break;
case 4:copy(a,c);
printf("Copied String = %s",c);
break;
case 5:reverse(a);
break;
case 6:l=pl(a);
if(l==0)
printf("\n%s : NOT a PALINDROME.",a);
else
printf("\n%s is PALINDROME.",a);
break;
case 7:Accept(b);
l=compare(a,b);
if(l==1)
printf("\nStrings (%s & %s )are SAME",a,b);
else
printf("\nStrings (%s & %s )are Different",a,b);
break;
case 8:Accept(b);
l=Substr(a,b);
if(l>=1)
printf("\n%s is SubString of %s \nOccurunce : %d times.",b,a,l);
else
printf("\n%s is NOT a SubString of %s .",b,a);
break;
case 9:Accept(b);
StrCon(a,b);
printf("Concatinated string = %s ",a);
break;
case 10:exit();
default:printf("\nPlease enter Proper Value. ");
}
printf("\nDo U want to Continue(y/n)? ");
scanf("%s",&s);
}while(s=='y's=='Y');
if(s=='n')
exit();
getch();
}

/* Hope it is helpful */

Write a program to print following series 1 01 010 1010 .?

Program to print one & zero Alternatively

#include
#include
void main()
{
int i,j,n,k=1;
clrscr();
printf("Enter the Iteration Value : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",k);
if(k==1)
k=0;
else
k=1;
}
printf("\t");
}
getch();
}

Output :
Enter the Iteration Value : 5
1 01 010 1010 10101

Does a subprogram always return a value to the program or subprogram that calls it?

No. In some languages PROCEDUREs don't return a value, FUNCTIONs do; in C (and derivatives) return-type void means no return value. Example:

void Hello (const char *msg) { puts (msg); }

Code to implement memcpy in c?

unsigned char *

memcpy(unsigned char * s1, unsigned char * s2, long size)

{

long ix;

s1= (char *)malloc(sizeof(strlen(s2)));

for(ix=0; ix < size; ix++)

s1[ix] = s2[ix];

return s1;

}

Passing an array name to a pointer assigns the first memory location of the array to the pointer variable?

Yes, passing an array name to a pointer assigns the first memory location of the array to the pointer variable. An array name is the same as a pointer to the first location of the array, with the exception that an array name is a r-value, while a pointer is an l-value.

How do you swap two numbers without using third one using pointers?

How do you do.

I am doing well thank you.

Swap two number by using reference operators

A tough assignment, it will make you think.

I think you are confusing reference operators with pointers.

Were I you I would study the section on pointers in your text book or course material.

Write a program to compare two strings with out using strcmp function?

#include

main()

{

//please read two strings int str1 and str2//

while(str1[i]!='/0' &&str2[i]!='/0')

if(str1[i]!=str2[i])

flag=1;

if(flag==1)

printf("equal");

} #include

main()

{

//please read two strings int str1 and str2//

while(str1[i]!='/0' &&str2[i]!='/0')

if(str1[i]!=str2[i])

flag=1;

if(flag==1)

printf("equal");

}

What is a header code?

Header codes, or tags, are used in html language. They are used to identify the page and can be text, banner or logo.

Write your name and address in c?

int main (void) { puts ("Your name and address"); return 0; }

Why fixed size array is not efficient?

It's not exactly true. Array with fixes size are efficient, but do not work well when you have to resize your array. This actually is the answer for your question. Fixed size arrays are not efficient if you have to change the size. Also you cannot destroy them and release memory used to save the array (for that you have to use operator new).

In C Programming Language Can someone write a program that will interact with the user by name and allow for the recording of grades for three classes Tech History and Math?

More info;

You will write a program that will interact with the user by name and allow for the recording of grades for three classes: Tech, History, and Math. The program will allow the user to determine how many assignments to enter in each class, the name of each assignment, the total value of each assignment, and the users score on each assignment. The program will will write the scores to a file and have the ability to:

  • Tell the user the high and low score in each class along with the assignment name

  • Repeat entries back to user by assignment name and score to ensure accuracy

  • Tell the user their current grade in each class

  • Tell the user their current gpa based on the overall percentage of each class

How many bytes does an Boolean take in a c program?

There is no boolean in C, we usually use int/short/char to store logical values.