How do you increment strings in c?
Not possible. If you think otherwise, then please increment manually this string: "/"
#include<stdio.h>
main()
{
int num1;
int num2;
int a;
printf("Enter any two numbers :");
scanf("%d%d",&num1,&num2);
for(a=num1;num1<=num2;a++)
{
if ( a % 2 == 1);
{
printf("%d",a);
}
}
getch();
}
#include
#include
#include
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::toupper;
struct Employee
{
string getFullName()
{
return (firstName + " " + lastName);
}
string getGender()
{
if (toupper(gender) == 'M')
{
return ("Male");
}
else if (toupper(gender) == 'F')
{
return ("Female");
}
else
{
return ("Gender was not specified");
}
}
int getAge()
{
return age;
}
string getMartialStatus()
{
if (toupper(martial_status) == 'M')
{
return ("Married");
}
else if (toupper(martial_status) == 'S')
{
return ("Single");
}
else
{
return ("Martial status is not defined!");
}
}
int getNumberOfChildren()
{
return numberOfChildren;
}
string firstName;
string lastName;
char gender;
int age;
char martial_status;
int numberOfChildren;
};
int main()
{
Employee newEmployee;
cout << endl << "Enter first name: ";
getline(cin, newEmployee.firstName);
cout << endl << "Enter last name: ";
getline(cin, newEmployee.lastName);
cout << endl << "Enter gender (M for Male and F for Female): ";
cin >> newEmployee.gender;
cout << endl << "Enter age: ";
cin >> newEmployee.age;
cout << endl << "Enter martial status (M for married and S for single): ";
cin >> newEmployee.martial_status;
cout << endl << "Enter number of children: ";
cin >> newEmployee.numberOfChildren;
cout << endl << "Employee's full name: " << newEmployee.getFullName()
<< endl << "Gender: " << newEmployee.getGender()
<< endl << "Age: " << newEmployee.getAge()
<< endl << "Martial status: " << newEmployee.getMartialStatus()
<< endl << "Children: " << newEmployee.getNumberOfChildren()
<< endl;
system("PAUSE");
return 0;
}
Is array list a value type or reference type?
Array lists are objects and are of the reference data types. If you pass an array list from a java method to another as an argument, you need not return this from the target method because the modifications to the list would be happening in its value and hence would be available in the parent or calling method without being received as an output from the called method.
Who and where made c language?
c language is designed at "AT and T'S laboratories" of USA in 1972. It was written by dennis ritchie.
What is the difference between c and c plus plus and c minus minus?
The main difference between the two is that C++ is an object oriented programming language while C is a structured programming language. Although C++ is derived from C, they are in fact completely separate languages that share a common syntax. However, C++ is backwardly compatible with C so while you may include C-style code within C++ programs, you cannot include C++ code in C programs.
What is prori analysis and posteriori testing of algorithms?
A priori analysis of an algorithm refers to its time and space complexity analysis using mathematical (algebraic) methods or using a theoritical model such as a finite state machine. (In short, analysis prior to running on real machine.)
A posteriori analysis of an algorithm refers to the statistical analysis of its space and time complexity after it is actualy run on a practical machine. (in short, anaysis of its statistics after running it on a real machine)
How do you print series 1 10 2 9 3 8 4 7 5 6 using for loop in c language?
#include<iostream.h>
#include<conio.h>
long int counter1, counter2=10;
int main(){
do{
counter1++;
cout<<counter1<<"-"<<counter2<<"-";
counter2--;
}while(counter1<10);
getch();}
this is the code, is quite easy -- but it is not in C, sadly.
Try this:
int main (void)
{
int i;
for (i=1; i<=5; ++i) printf ("%d %d ", i, 11-i);
printf ("\n");
return 0;
}
What types of disk arrays provide the MOST fault tolerance?
RAID 6 provides the most fault tolerance of any standard RAID disk arrays
(RAID 0, 1 , 5, 6, and RAID 10).
If any two disks in a RAID 6 array fail and are removed, then two new blank disks can be installed and no data has been lost.
RAID 1+1 or most other "layered" RAID systems can provide more fault tolerance than RAID 6, tolerating the failure of any 3 disks.
Some experimental non-standard disk arrays can provide more fault tolerance with less overhead, such as the parchive system.
Nearly all distributed file systems and distributed version control systems can be set up so that if one machine is completely destroyed by fire, all the data can be recovered from a backup machine in another building.
#include<iostream>
#include<string>
int main()
{
std::string input, invert;
bool ok = false;
while (!ok)
{
std::cout << "Enter a 5-digit binary number:";
std::getline (std::cin, input);
if (input.size()==5)
{
invert = input;
ok = true;
for (auto c = invert.begin(); c!=invert.end(); ++c)
{
switch (*c)
{
case ('1'): *c = '0'; break;
case ('0'): *c = '1'; break;
default: ok = false;
}
}
}
if (!ok)
{
std::cout << "Bad input\n";
invert.clear();
input.clear();
}
}
std::cout << "Input:\t" << input << std::endl;
std::cout << "Invert:\t" << invert << std::endl;
}
Menu driven program that implements singly linked list for the following operations?
#include<stdio.h>
int a[10],i=(-1),st=(-1);
void push();
void pop();
void isfull();
void isnull();
void display();
main()
{
int st=(-1);
int a[10],n,ch,i=(-1);
char choice='Y';
while(choice=='Y' choice=='y')
{
printf(" 1.PUSH\n 2.POP\n 3.IS FULL\n 4.IS NULL\n 5.DISPLAY\n");
printf("Enter your choice :");
scanf("%d",&ch);
switch(ch)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
isfull();
break;
case 4:
isnull();
break;
case 5:display();
break;
default:
printf("you have entered a wrong entry.");
}
printf("Do you want to continue?");
scanf(" %c",&choice);
}
}
void push()
{
if(st==(-1))
printf("The stack is empty.");
i=i+1;
if(i>=10)
printf("The stack is full.");
else
{
printf("Enter a number :");
scanf("%d",&a[i]);
st=st+1;
}
}
void pop()
{
if(st==(-1))
printf("The stack is empty. UNDERFLOW condition");
if(st>(-1))
{
printf("The deleted element is :%d",a[i]);
i=i-1;
st=st-1;
}
}
void isfull()
{
if(st<9)
printf("The stack is not full\n");
if(st>=9)
printf("The stack is full");
}
void isnull()
{
if(st==(-1))
printf("The stack is empty");
if(st>(-1))
printf("The stack is not empty");
}
void display()
{
int z;
if (st==(-1))
printf("The stack is empty.");
else
printf("The elements present in the array are :");
for(z=0;z<=i;z++)
printf(" %d",a[z]);
printf("\n");
}
Differentitate between overload function and function template?
An overloaded function is a function that has two or more implementations that each operate upon a different type.
Function templates allow the compiler to generate overloaded functions on an as required basis for any function where the implementations only differ by type.
How is the data structure of system R different from the relation structure?
Unlike Relational systems in System R
? Domains are not supported
? Enforcement of candidate key uniqueness is optional
? Enforcement of entity integrity is optional
? Referential integrity is not enforced
begin open:=[start]; closed:=[]; while open<>[]do begin remove left state from open,call it X. if X is a goal then return SUCCESS else begin generate children of X; put X on closed; discard children of X if already on open or closed; put remaining children on the left end of open; end end return FAIL; end
What tool can you search to find the database where a journal is available in full text?
journal finder
What are different types of computing environments?
1) personal c.e
2)distributed c.e
3)cloud c.e
4)time saving c.e
Why mcculloch-pitts model widely used in logic functions?
The McCulloch-Pitts model was an extremely simple artificial neuron. The inputs could be either a zero or a one. And the output was a zero or a one. And each input could be either excitatory or inhibitory.
Now the whole point was to sum the inputs. If an input is one, and is excitatory in nature, it added one. If it was one, and was inhibitory, it subtracted one from the sum. This is done for all inputs, and a final sum is calculated.
Now, if this final sum is less than some value (which you decide, say T), then the output is zero. Otherwise, the output is a one.
Here is a graphical representation of the McCulloch-Pitts model
In the figure, I represented things with named variables. The variables w1, w2 and w3 indicate which input is excitatory, and which one is inhibitory. These are called "weights". So, in this model, if a weight is 1, it is an excitatory input. If it is -1, it is an inhibitory input.
x1, x2, and x3 represent the inputs. There could be more (or less) inputs if required. And accordingly, there would be more 'w's to indicate if that particular input is excitatory or inhibitory.
Now, if you think about it, you can calculate the sum using the 'x's and 'w's… something like this:
sum = x1w1 + x2w2 + x3w3 + …
This is what is called a 'weighted sum'.
Now that the sum has been calculated, we check if sum < T or not. If it is, then the output is made zero. Otherwise, it is made a one.
Now, using this simple neuron model, we can create some interesting things. Here are a few examples:
NOR GateThe figure above is a 3 input NOR gate. A NOR gate gives you an output of 1 only when all inputs are zero (in this case, x1, x2 and x3) You can try the different possible cases of inputs (they can be either zero or one).Note that this example uses two neurons. The first neurons receives the inputs you give. The second neuron works upon the output of the first neuron. It has no clue what the initial inputs were.
NAND GateThis figure shows how to create a 3-input NAND gate with these neurons. A NAND gate gives a zero only when all inputs are 1. This neuron needs 4 neurons. The output of the first three is the input for the fourth neuron. If you try the different combinations of inputs.The McCulloch-Pitts model is no longer used. These NOR and NAND gates already have extremely efficient circuits. So its pointless to redo the same thing, with less efficient models. The point is to use the "interconnections" and the advantages it has.
It has been replaced by more advanced neurons. The inputs can have decimal values. So can the weights. And the neurons actaully process the sum instead of just checking if it is less than or not.
How do we write a program to assist a teacher in calculating students' grades in Turbo C?
#include <stdio.h>
#include <conio.h>
void main()
{
char color;
clrscr();
printf("Enter character (R/G/B): ");
color= getchar();
switch (color)
{
case 'R': printf ("Red") ;
break; case 'G':
printf("Green"); break;
case 'B': printf("Blue"); break;
}
getch();
}
### posted by Pulkit and Puneet from D.Y.Patil college/pune The ans is NO......... bcoz c compiler already contains the basic functions of STDIO.H in its code segment. ok guys..... ### posted by Pulkit and Puneet from D.Y.Patil college/pune The ans is NO......... bcoz c compiler already contains the basic functions of STDIO.H in its code segment. ok guys.....
What is the difference between Typecast and Typedef?
Typecasting is to make a variable of one type, act like another type for one single operation.
Type-def is to assign alternative names to existing types.
How would you write a program that read an integer for display each of digit of integer in English?
Use an enum if you are using a c style language. Or a map data structure. Assign each integer an English value and then match it to what the user inputs.
What is difference between zero value and NULL strings?
Programming languages store data in different data types. A zero value would belong to a numeric data type such as float, single, double, integer, long, etc. A null string is a variable that references a string (sequence of characters) that is not yet pointing to anything.
AnswerA null string can also be a string of zero length.
How to create a DLL in C language?
Into the specified class, insert the following two lines: Collapse | Copy Code
[DllImport("TestLib.dll")] public static extern void DisplayHelloFromDLL ();
In C#, keyword extern indicates that the method is implemented externally.
Your code should look something like this: Collapse | Copy Code
using System; using System.Runtime.InteropServices; // DLL support class HelloWorld { [DllImport("TestLib.dll")] public static extern void DisplayHelloFromDLL (); static void Main () { Console.WriteLine ("This is C# program"); DisplayHelloFromDLL (); } }
Please, note that System.Runtime.InteropServices is required for operations with the DLL.
(The answer in very good, the question is wrong.)
What is the difference between a computer file and a computer directory?
Files
A file on a computer system is any block of information being stored on the drive of that system. Files are used to hold all the information that makes a computer system function. Furthermore, most people have plenty of personal computer files with their own content within. For example, any text document you create and save on your computer is saved as a file. This also includes music, video and other application files that contain content for the user or functions for the computer itself. Folders Every computer system comes with a file system to keep all its files organized in groups. Folders serve to hold files inside them as well as other sub-folders and subsequent files. Folders help sort all the files on a system so the user (or the computer itself) can find and access files in an easier and more coherent fashion than just arranging all the files in one single directory. Many people have common folders on their computer such as a pictures folder and a music folder. Most folders can hold as much information as the computer can store on its drive and can hold any type of files. It would be possible to store photos in the music folder if the user so desired. Differences While files and folders are both stored on a computer drive, they are different items and each serves a specific purpose. While files store all the physical computer data within themselves, they are located somewhere within the directory located on the computer. These directories are also known as folders and contain all the files on the system.