C plus plus programme to count non-vowels in a file of test?
#include<iostream>
#include<fstream>
#include<string>
int main()
{
size_t count=0;
std::string vowels ("aeiouAEIOU");
std::ifstream ifs;
ifs.open ("test.txt", std::ios::in);
if (ifs.bad())
{
ifs.close();
std::cerr << "Invalid input file.\n" << std::endl;
return;
}
while (!ifs.eof())
{
char c = ifs.get();
if ((c>='a' && c<='z') (c>='A' && c<='Z'))
if (vowels.find (c) != vowels.npos)
++count;
}
ifs.close();
std::cout << "The file has " << count << " non-vowels.\n" << std::endl;
}
Is built-in data-type are abstract data-types in java?
All built-in data types are not abstract data types.
What are the advantages of case sensitive languages?
A case sensitive language gives you more flexibility in naming variables. It also lets you use the same variable name more than once for different purposes by changing different letters to upper or lower case, each version being treated as a separate variable. In practice, this is not recommended as it can cause confusion in reading programs and keeping track of which variable has what purpose.
How can you make diamond in C programming?
There is insufficient information in the question to answer it properly. What do you mean by "diamond". Are we talking Pascal's Triangle. Are we talking a diamond shaped field of stars? What? Please restate the question.
Program to check that given string is palindrome or not in C?
/*To check whether a string is palindrome*/
void main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }
Calculate the Time and Space complexity for the Algorithm to add 10 numbers?
The algorithm will have both a constant time complexity and a constant space complexity: O(1)
To display an input string vertically by c?
// get input
char input[256];
gets(input);
// print one character on each line
int i;
for(i = 0; input[i] != '\0'; ++i) {
printf("%c\n", input[i]);
}
Line drawing simple dda algorithm in c?
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<ctype.h>
#include<math.h>
#include<stdlib.h>
void draw(int x1,int y1,int x2,int y2);
void main()
{
int x1,y1,x2,y2;
int gdriver=DETECT,gmode,gerror;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi:");
printf("\n Enter the x and y value for starting point:\n");
scanf("%d%d",&x1,&y1);
printf("\n Enter the x and y value for ending point:\n");
scanf("%d%d",&x2,&y2);
printf("\n The Line is shown below: \n");
draw(x1,y1,x2,y2);
getch();
}
void draw(int x1,int y1,int x2,int y2)
{
float x,y,xinc,yinc,dx,dy;
int k;
int step;
dx=x2-x1;
dy=y2-y1;
if(abs(dx)>abs(dy))
step=abs(dx);
else
step=abs(dy);
xinc=dx/step;
yinc=dy/step;
x=x1;
y=y1;
putpixel(x,y,1);
for(k=1;k<=step;k++)
{
x=x+xinc;
y=y+yinc;
putpixel(x,y,2);
}
}
Write Shell programme to check number is perfect or not?
Write a shell program to test whether the given number is a perfect number or not.
#includeIs type checking on pointer variables stronger in assembly language or in c plus plus?
C++ imposes far greater restrictions on pointer typing than assembly language. There is only a single type of pointer in assembly, which is only "typed" in any sense when dereferenced, and even then only by size. C++ pointer typing takes into account not only the size of the type of the referent, but a number of other factors, such as its relationship to other types in the class hierarchy. The only way to disable these safety checks is to explicitly break the type system using reinterpret_cast.
How do you use sscanf() in C file handling?
You can find in-depth information on how to use sscanf() in C file handling on crasseux.com/books/ctutorial/sscanf.html
One more useful website of learning basic of "c programming" is cprogramming-bd.com
Why is searching in a sorted list faster than searching in an unsorted list?
With an unsorted list you have to search from the beginning to locate the item you're looking for. This is a linear search which takes linear time O(n) for n items. That is, the best case is constant time O(1) if the item you're looking for is the first item, it is O(n) if it is the last item (or the item doesn''t exist). Thus, on average, searches will take O(n/2) if the item exists, but always takes O(n) if it doesn't.
With a sorted list you start in the middle of the list. If the item you're looking for is less than this item, you can safely discard the upper half of the list but if it is greater you can discard the lower half. In other words you reduce the number of items to be searched by half. You then repeat the process with the remaining half. If the item you're looking for is equal to the middle item, you're done, but if the remaining half has no items the item does not exist. This is a logarithmic search with a best case of O(1), a worst case of O(log n) and an average case of O((log n)/2).
Logarithmic searches are clearly faster, on average, than linear searches. However, logarithmic searches require two separate comparison operations (equal to and less than) while linear searches require just one (equal to). Thus for a list of three or four items, a linear search is arguably quicker. But for larger lists, logarithmic search is quicker. Note that we don't need to test for greater than since it can be assumed that if an item is neither less than or equal to another item, then it must be greater.
What is the difference between passing by value and passing by difference?
Passing by value is where you pass the actual value (be it an integer, an array, a struct, etc.) to a function. This means that the value must be copied before the function is called and therefore the value in the caller cannot be modified within the callee. Passing by reference is where a reference/pointer to a value is passed to a function. The reference often takes up less space than copying the actual value (particularly when the value is a struct or an array) and allows you to manipulate the value in the caller within the callee.
Loops are used in C to speed up algorithms that do a process repeatedly with the same or very similar values. For example, if you have to write a program to add together all of the number 1 to 10 and print out the value you get you could do it 2 ways:
1. Without a loop:
int a = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;
printf("%d", a);
2. With a loop:
int a = 0;
for(int i = 1; i <= 10; i++){
a += i;
}
printf("%d", a);
As you can see, solution 2 took about the same amount of time to code as solution 1 BUT when you get into more complex things, or just things that involve more values, loops come in handy. For example, say you want to add up all of the numbers from 1 to 100 or 1 to 1000, it would take much longer to write that out as hard code rather than just to use a loop.
Does it matter if you get a stud or a loop for your first earlobe piercing?
Answer I wear hoops, 1 gauge, 1 body piercing, and studs. If it is your first Ear Lobe piercing it is best to get pierced with a stud, and go for a good strong noncorrosive metal (14k or titanium, cheaper stuff like copper, NOT A GOOD MOVE!). Studs have a less chance of being ripped out or caught on anything, Cleaning is simple and healing is rather quick in my opinion. You should never get pierced with a hoop you cause complications with the healing process and your piercer should know that.
Personally I wouldn't use a hoop because you will most likely changed the size of the hole. Studs are the way to go for the healing period with lobes. The process is quick and practically painless. But if you pierce any other part of your ear you are going to want to look for a piercer. - Hope that helped, Cheeky6682
AnswerIt's better to start with a ring, a good quality ring made of 316LVM Steel, Titanium, or 14kt gold or better.
Studs are made of cheap metal in most cases, and the design of the stud can impede your healing.
AnswerI would advise a stud because I have found them more comfortable to sleep on and keep clean, but a hoop works as well.
AnswerIt is easier to clean a hoop because it is harder to push the stud out to make sure the cleaning solution gets into the piercing but it is just personal preference.-Answer, Meyshi07- Well.. if you are ever wanting to wear a hoop, start with a hoop, its a LOT harder switching form a stud to a hoop because, well the stud is pierced straight,the hoop is curved, I got my cartilage pierced with a stud and had a hell of a time trying to wear a hoop, got all sorts of infected and took me a year to just give up and take the pain till the hoop fit and healed. I still have problems keeping the hoop comfortable at times. My advice go with a hoop if u plan on wearing one neways, and to the answer about rings catching on things, its reversed a stud catches on things easier than a hoop =P
Answer ; Get it pierced with a stud. After it heals then you can wear loops.
ANSWER: Now, I don't know where there people are getting their information from, but it's best to go to a PROFESSIONAL PIERCER who would put a hoop in instead of a stud. When you pierce anything, it's going to swell. HOOPS allow the piercing to heal and also allows the piercing to have room to swell. Cartilage is completely different than the ear lobe, and should be treated differently.
Piercing guns aren't very good for healing, because they actually blast the hole into your ear instead of making a clean hole.
Cleaning hoops are simple. Just wash off the crusties in the shower with antibacterial soap (Dial works well) and put a little bit of antibiotic gel (Neosporin) on the edge of the piercing/ring and work in back and forth.
(My credentials; I'm apprenticing at a body piercing shop.)
It's in essence (from a very high-level view), when a node is attacked and then "captured". So first we need to define "node". A node can be like your laptop, a switch at the ISP (CenturyLink, etc.), a router, etc.
Think of it like streets. The car (data), drives along through an intersection (a node), and keeps driving along until it makes it to wherever it's headed (say your computer. Well let's say your tired of always having red lights at a certain intersection, so one day you decide that you take over the "light control box". Traffic is still going through, but you control it. We could even say that the "light control box" is connected to the "traffic camera" box. So now, aside from controlling the cars (data/packets), you can also capture their license plates, and in essence "capture the packet". Now that you can control the traffic, and you know what cars drive through when and from where, and how often, you decide to do some "post-exploitation attacks". You decide that you'll redirect traffic from the highway to the one way street (flood attack), or hijack cars, switch license plates, etc.
Poor example, but hopefully that helps some.
What is polynomail time algorithm?
That means, roughly speaking, that for any input of size "x", the algorithm will take no longer than xn for some constant "n".
C program to copy one matrix to another matrix?
#include
What is a symbolic constant in c language?
symbolic constants are constants represented by symbols....
constants are values that does not change through out the program execution.
e.g
#include<stdio.h>
#include<conio.h>
#define NUM 15
void main()
{
int a=NUM;
printf("The constant is %d",a);
getch();
}
here #define is a preprocessor. its job is to replace all the entries named NUM as 15. So that the compiler works with the constant 15...
crash prob is at an elevated level
#include<iostream>
#include<map>
#include<string>
#include<sstream>
#include<conio.h>
struct Cellphone
{
std::string product_id;
std::string product_no;
std::string country;
std::string brand;
double cost;
};
std::ostream& operator<< (std::ostream& os, const Cellphone& phone)
{
os << "Product ID: " << phone.product_id << std::endl;
os << "Product No: " << phone.product_no << std::endl;
os << "Country: " << phone.country << std::endl;
os << "Brand: " << phone.brand << std::endl;
os << "Cost: " << phone.cost << std::endl;
return os;
}
// Global...
std::map<std::string, Cellphone> cellphones;
// forward declarations
size_t choice (std::string);
std::string get_string (std::string prompt);
double get_double (std::string prompt);
void add();
void remove();
void search();
void view();
int main()
{
while (1)
{
std::cout << "MAIN MENU\n=========\n\n";
std::cout << "[A] Add\n";
std::cout << "[V] View\n";
std::cout << "[S] Search\n";
std::cout << "[R] Remove\n";
std::cout << "[Q] Quit\n";
switch (choice ("AVSRQ"))
{
case 0: add(); break;
case 1: view(); break;
case 2: search(); break;
case 3: remove(); break;
default: return 0;
}
}
}
void add ()
{
std::cout << "\nAdd Cellphone\n\n";
Cellphone phone;
phone.product_id = get_string ("Product ID");
phone.product_no = get_string ("Product #");
phone.country = get_string ("Country");
phone.brand = get_string ("Brand");
phone.cost = get_double ("Cost");
cellphones[phone.product_id] = phone;
std::cout << std::endl;
}
void remove ()
{
std::cout << "\nRemove Cellphone\n\n";
std::string id = get_string ("Product ID");
cellphones.erase (id);
}
void search ()
{
std::cout << "\nSearch for Cellphone\n\n";
std::string id = get_string ("Product ID");
std::map<std::string, Cellphone>::const_iterator it = cellphones.find (id);
if (it choices.npos)
continue;
return pos;
}
}
Write a program in C language to find out the dot product of two vector quantities in Cartesian?
#include <stdio.h>
#include <ctype.h>
#define n[]
int main()
{
int n, result , answer;
int a[n], b[n];
printf("Enter number of terms you would like to use :");
scanf("%d", &n);
printf("Enter first vector:\n");
scanf("%d", &a[n]);
printf("Enter second vector:\n");
scanf("%d", &b[n]);
printf("The dot product is \n" );
return 0;
}
All data is stored in a computer as 0s and 1s. In order to make this more efficient, certain sets of bits can mean different things depending on what the data type is. Some languages, such as Java, make sure the programmer doesn't confuse these types and mess up the data. However, other languages allow you to do things like multiply a string and an array. If you don't pay careful attention to data types, you can easily end up with useless data.
Example of area of rect inheritance program in java?
Let us first define a generic Shape class. This will be an abstract class, since the term "shape" is, itself, very abstract.
Let us also assume that this shape is defined in only two dimensions, for the sake of simplicity.
abstract class Shape {
/*
One of the properties of any 2D shape is the area it takes up. Since calculating the area depends on the shape, we'll make this method abstract - all subclasses should implement it differently.
*/
abstract int getArea();
}
Now that we have our base class defined, we can create a rectangle subclass.
class Rectangle extends Shape {
/*
While a rectangle has other properties, we are really only interested in the ones required to calculate the area - width and height.
*/
int width;
int height;
/*
What's the area of a rectangular shape?
area = width x height
*/
int getArea() {
return width*height;
}
}