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 Lead to C C plus plus and java?

(C and Lisp, ... data type") was adopted by many later languages, such as ALGOL 68 (1970), Java, and C#. ... C++ has a separate Boolean data type ( 'bool' ), but with automatic conversions from ... "Report on the Algorithmic Language ALGOL 68

Write a program of pyramid to print 12345678910?

output will

1

12

123

1234

12345

//mycfiles.wordpress.com #include

#include

void main()

{

int i,j;

clrscr();

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

{

printf("\n");

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

printf("%d",j);

}

getch();

}

To reverse the output

12345

1234

123

12

1

//mycfiles.wordpress.com

#include

#include

void main()

{

int i,j;

clrscr();

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

{

printf("\n");

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

printf("%d",j);

}

getch();

}

improved::::::

#include

#include

#include

void main()

{

int i,j,k;

printf("Please enter your desired value:");

scanf("%d",&k);

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

{

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

printf("%d",j);

printf("\n");

}

printf("Press any key to close.");

getch();

}

What is the meaning of 2L in C programming?

2L is the literal constant for a long (int) type with the value 2.

In programming with C Write a program to find the age of the eldest and youngest person in a family maximum of 10 persons. It reads the ages of all the members of a family stores them in an array and?

#include using namespace std;int main() { int age[10]; int num=1;cout<<"How many persons are there in list ? "; cin>>num; for(int x=0; x { cout<<"Enter person"< cin>>age[x]; } int eldest = age[0]; int young = age[0]; for(int y=1; y < num; y++) { if(age[y] > eldest) { eldest = age[y]; } if(age[y] < young) {young = age[y]; } } cout<<"Age of eldest person is "<cout<<"Age of youngest person is "< return 0; }#include using namespace std; int main() { int age[10]; int num=1;cout<<"How many persons are there in list ? "; cin>>num; for(int x=0; x { cout<<"Enter person"< cin>>age[x]; } int eldest = age[0]; int young = age[0]; for(int y=1; y < num; y++) { if(age[y] > eldest) { eldest = age[y]; } if(age[y] < young) {young = age[y]; } } cout<<"Age of eldest person is "<cout<<"Age of youngest person is "< return 0; }

WHAT IS C program for FLAMES?

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{ char str1[20];

char str2[20];

int x,y,n,r,counter1,counter2,points=0;

clrscr();

printf ("Please enter a name: \n\n");

gets(str1);

printf ("\nEnter another name: \n\n");

gets(str2);

counter1=strlen(str1);

counter2=strlen(str2);

for (x=0; x<counter1; x++)

{ for (y=0; y<counter2; y++)

{ if (str1[x]==str2[y])

points++;

else;}

if(points!=0)

points++;

}

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

{ if (str1[0]==str1[n])

points++;

else;}

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

r=points%6;

switch®

{

case 1: printf ("\nFriends"); break;

case 2: printf ("\nLovers"); break;

case 3: printf ("\nAffection"); break;

case 4: printf ("\nMarriage"); break;

case 5: printf ("\nEnemies"); break;

case 0: printf ("\nSister"); break;

}

getch();

}

What is difference between C enum and C plus plus enum?

In C++, enum signifies a slightly stronger type than in C.

For example, in C, one could write:

enum Direction { UP, DOWN };

Direction d = 1;

In C++, this would be illegal, only UP or DOWN can be assigned to a variable of type Direction, though there is still implicit casting to integer, so one could still write:

int i = UP;

Another difference has to do with the way variable are declared in general in C++. In C, once the enum was declared as above, declaring variables of type Direction would have to be done through the enum keyword, like this:

enum Direction d = UP;

In C++, the name "Direction" becomes a type in itself, so you can write:

Direction d = UP;

How do you calculate water bill from C programming?

#include<iostream>

using namespace std;

#include<conio.h>

void main()

{

char m[100];

int units[100],i,j,n;

float x,tb;

cout<<"enter the total number of bills to be calculate:\n";

cin>>n;

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

{

cout<<"\nenter the name \n:==>";

cin>>m;

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

{

cout<<"\nenter the total units consumed \n:==>";

cin>>units[i];

}

}

if(units[i]<=100)

{

x=units[i]*0.6;

tb=50+x;

if(tb>300)

{

tb=0.15*tb+tb;

}

cout<<"\ncalculated bill:==>";

cout<<m<<tb;

}

else if(units[i]>100 && units[i]<=300)

{

tb=100*0.6+(units[i]-100)*0.8+50;

if(tb>300)

{

tb=0.15*tb+tb;

}

cout<<"\ncalculated bill:==>";

cout<<m<<tb;

}

else if(units[i]>300)

{

tb=100*0.6+200*0.8+(units[i]-300)*0.9+50;

if(tb>300)

{

tb=0.15*tb+tb;

}

cout<<"\ncalculated bill:==>";

cout<<m<<tb;

}

getch();

}

What is fifo data structure?

FIFO, means "First In, First Out". An example of such a data structure is a queue.

To check whether a string is a palindrome with using string header file?

#include #include
#include
void main()
{
char a[50],r[50];
int i,j;
printf("\n Enter the string:");
gets(a);
for(i=strlen(a)-1,j=0;i>=0;i--,j++)
r[j]=a[i];
r[j]='\0';
printf("\n Reverse string is %s",r);
if(strcmpi(a,r)==0)
printf("\n the original string is a pallindrome");
else
printf("\n the original string is not pallindrome");
getch();
}








Note:-If you want it case sensitive then use 'strcmp' instead of 'strcmpi'

C program to find square of number using do while loop?

class Abc

{

public static void main(String[] args)

{

System.out.println("Hello World!");

}

}

Using while loop Write a program find the factors of a number?

by this program you can find the factorial:

#include<iostream>

using namespace std;

main()

{

int n,x,f=1;

cin>> n;

x=0;

while(x<n)

{

x++;

f= f*x;

}

cout<<"factorial is"<<f<<"\n";

system("pause");

return 0;

}

Write a shell program to find the sum of odd and even numbers from the given set of numbers?

echo enter n value

read n

sumodd=0

sumeven=0

i=0

while [ $i -ne $n ]

do

echo "Enter Number"

read num

if [ `expr $num % 2` -ne 0 ]

then

sumodd=`expr $sumodd + $num`

sumeven=`expr $sumeven+$num`

fi

i=`expr $i + 1`

done

echo Sum of odd numbers = $sumodd

echo Sum of even numbers = $sumeven

Give a sample problem with the use of algorithm and flowchart symbols?

design a flowchart that will input three numbers and get their sum. If the sum is greater than 20, then print "sum>20",else print the sum.

How many leaf nodes does the full binary tree of height h 3 have?

For a full binary tree of height 3 there are 4 leaf nodes. E.g., 1 root, 2 children and 4 grandchildren.

What is strong number in C language?

Strong number is a number for which sum of factorials of the digits is equal to the given number.

Eg: let us consider 145 where sum of factorials of the digits= 1!+4!+5!=1+24+120=145 i,e., the given number.

c program for strong number is:

#include<stdio.h>

#include<conio.h>

void main()

{

int sof=0,n,dn,ctr,prod,rem;

printf("Enter the number\n");

scanf("%d",&n);

dn=n;

while(n!=0)

{

prod=1,ctr=1;

rem=n%10;

while(ctr<=rem)

{

prod=prod*ctr;

ctr=ctr+1;

}

sof=sof+prod;

n=n/10;

}

if(sof==dn)

{

printf("The number entered is strong number");

}

else

{

printf("The number entered is not a strong number");

}

}

By

Nagarjuna

sri indu ECE,

IBP.

Type of data communication?

What is the difference between data communication and telecommunication ?

What is the use of dim in one dimensional and two dimensional in array?

if one dimension means it have only rows but in two dimension means it have both row and coloumns

What assembly language is the best for making an OS?

The native Assembly language of the given platform.

For example it would be stupid to write anything in Motorola 68000 Assembly for Intel x86 platform: it wouldn't work.

How do you create an algorithm to convert a persons weight from pounds to kilograms?

hi

since

1 pound = 0.45359237 kilograms

so

weight_in_kilo = weight_in_pounds * 0.45359237

Write a C program that will ask the user for 4 integer values and then produce the following output 1 The sum of the four numbers 2 The sum of the first two numbers minus the sum of the las?

#include<stdio.h> main() { int a,b,c,d; // The four integers to be asked printf("Give the first integer: "); //asks for the first integer scanf("%d",&a); // puts the user input in the address of the integer "a" printf("Give the second integer: "); //same explanations scanf("%d",&b); printf("Give the third integer: "); scanf("%d",&c); printf("Give the fourth integer: "); scanf("%d",&d); printf("1. The sum of the four integers is: %d",a+b+c+d); //prints the sum of the four integers given by the user, notice the "a+b+c+d" at the end) printf("2. The sum of the first two numbers minus the sum of the last: %d",a+b-c-d); //prints the second condition by putting the correct operations return 0; //ends the program } I never tested this program though, but i think it would work.

How do you raise a number to a power We can use pow function using math.h file?

Unfortunately, there is no power function in C/C++, so you'll have to make one yourself. I made one a few days ago, here it is:

int power (int one, int two)

{

int temp = one, counter = 1;

while (counter

{

temp *= one;

counter++;

}

return temp;

}

/* PROGRAM TO CALCULATE THE VALUE OF X RAISED TO GIVEN POWER*/

#include <stdio.h>

#include <math.h>

#include <conio.h>

main()

{

int x,power;

float result;

clrscr();

printf("Enter the value of x:");

scanf("%d",&x);

printf("Enter the value of power:");

scanf("%d",&power);

result=pow(x,power);

printf("The value of %d^%d is %f",x,power,result);

getch();

return;

}