#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;
What programming statement did Edsger Dijkstra want to eliminate?
He considered the "goto" statement to be harmful.
What is the definition of symbolic constants in c language?
constants are values that does not chnage through out the program exceution..
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
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'
What does the function counter do and what are its parameters?
There is no builtin function 'counta' in C.
C program to find square of number using do while loop?
class Abc
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
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.
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;
}
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.
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 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.
What is the difference between data communication and telecommunication ?
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.
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
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
#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;
}
What is the name of the software that is use to create your own game?
Game Maker 7 (you can find it on "YoYoGames" )
Draw a flowchart that will add all integers from 1 to 50?
A Sample java method that can do this sum of all numbers between 1 to 50
public int sumNumbers(){
int retVal = 0;
for(int i = 0; i <=50; i++){
retVal = retVal + i;
}
return retVal;
}
How do you write negative numbers on a calculator?
Enter the number, then press the button marked with +/-
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.