How do you calculate array of 10 number using array in c?
#inculde<iostream>
using namespace std;
int smallestIndex(int[],int) //function prototype
void main()
{
int arr[10]={2,5,6,9,3,7,1,15,12,10};
int position;
position=smallestIndex(arr,10);
cout<<"the smallestIndex
No, but useful.
Example without stdio.h:
extern int puts (const char *s);
int main (void) { puts ("without"); return 0; }
Example with stdio.h:
#include <stdio.h>
int main (void) { puts ("without"); return 0; }
The C.I.A., or Central Intelligence Agency, is a civilian foreign intelligence service of the United States federal government. Its primary mission is to gather, process, and analyze national security information from around the world, particularly related to foreign governments, organizations, and individuals. The agency also engages in covert operations and counterintelligence activities to support U.S. foreign policy and national security objectives. Established in 1947, the C.I.A. operates under the jurisdiction of the Director of National Intelligence.
Write a C program to remove duplicate elements in an array?
#include
int main(){
int arr[50];
int *p;
int i,j,k,size,n;
printf("\nEnter size of the array: ");
scanf("%d",&n);
printf("\nEnter %d elements into the array: ",n);
for(i=0;i scanf("%d",&arr[i]); size=n; p=arr; for(i=0;i for(j=0;j if(i==j){ continue; } else if(*(p+i)==*(p+j)){ k=j; size--; while(k < size){ *(p+k)=*(p+k+1); k++; } j=0; } } } printf("\nThe array after removing duplicates is: "); for(i=0;i < size;i++){ printf(" %d",arr[i]); } return 0; } By Amandeep Singh :)
What is machine language called and what numerals represent this language?
A machine language is called as machine code and it is represented as binary numbers 0 and 1
void swap (int *a, int *b) {
*a ^= *b;
*b ^= *a;
*a ^= *b;
return;
}
C program to calculate x to the power y without using operator and standard function?
void main()
{
int x=100,y=3;
//lets calculate x to the power of y now
int result=0,i,j,a=x;
for(i=0;i<(y-1);i++)
{
for(j=0;j<x;j++)
result=result+a;
a=result;
result=0;
}
printf("%d",a);
}
What are the Similarities between c and .Net?
Many syntaxs are very similar in both the languages C and C# .NET.
C++ supports Object Oriented Programming and .NET also supports that.
Infact C++ is derived from C language and C# .NET is derived from C++ language.
What advantages did salons have over earlier forms of communication in spreading ideas?
Philosophers, writers, artists, scientists, and other great intellects all gathered at salons to discuss ideas. With everyone gathered together, it would be much more effective than writing down ideas and discussing it over time or just by word-of-mouth.
Differentiate c constant and c variables?
Constants
variables
characteristics
Value is not changeableduring the course of the program
Value can be changedanytime during the course of the program
usage
Use constant when you want to declare something that won't change midway in your program execution.
Use variable to store data thatmay or will change during the running of the program.
Extreme Programming:
Extreme Programming is when you design the test cases first, and then program backwards. This creates an easier to use programming flow.
#include<iostream>
#include<sstream>
unsigned input_num (std::string prompt, unsigned min, unsigned max)
{
unsigned num = 0;
while (1)
{
std::cout << prompt << " (range " << min << " - " << max << "): ";
std::string input = "";
std::getline (std::cin, input);
std::stringstream ss (input);
if (ss >> num)
{
if (num >= min && num <= max)
break;
else if (num<min)
std::cout << "Index must be greater than or equal to " << min << std::endl;
else
std::cout << "Index must be less than or equal to " << max << std::endl;
}
else
std::cout << "Invalid input." << std::endl;
}
return (num);
}
void print_substring (std::string input, unsigned left, unsigned right)
{
std::cout << input.substr (left, right - left + 1) << std::endl;
}
int main()
{
std::cout << "Input string:\t";
std::string input = "";
std::getline (std::cin, input);
unsigned left = input_num ("Enter the start index of the substring", 0, input.size()-1);
unsigned right = input_num ("Enter the end index of the substring", left+1, input.size()-1);
print_substring (input, left, right);
}
What is a location drawing used for?
This type of drawing explains where the buildings location is and tells you what other buildings are surrounding it.
An equivalence relation ~ on A partitions into pairwise disjoint subsets called equivalence classes so that 1. Within each class, every pair relates 2. Between classes there is no relation i.e. [x] = {a (element) A | a~x} and given two equivalence classes [a] and [b], either [a] = [b] or [a] intersect [b] = the empty set
Three times the sum of c and d?
Sum means to add.. so the equation would look like 3(c+d) or (c+d)*3. You could also add them separately. 3c+3d Hope that helps!
An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.
An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.
An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.
An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.
Write a c program to find the sum of the first 15 even numbers and calculate the square of the sum?
#include<stdio.h>
#include<conio.h>
void main()
{
int c=1,i;
unsigned int s=0;
clrscr();
for(i=1,(i<=15;i++))
{
if(i%2==0)
{
s=s+i;
c=c+i;
}
}
printf("/n sum of the first 15 even numbers is%d",s);
printf("/n square of the sum is: %d",(s*s));
getch();
}
I dont know how to generate the nos. randomly.I think it should follow some logic.So the following prog is made upon the inputs given by a user.
#include
#include
void main()
{ int a[5][5],i,j,s;
printf("\nEnter elements of the 5X5 matrics:\n");
for(i=0;i<5;i++)
{ for(j=0;j<5;j++)
{ scanf("%d",&a[i][j]);
if(a[i][j]<0 a[i][j]>100)
{ printf("\nThe no. should be between 1 & 100\nEnter Again:");
scanf("%d",&a[i][j]);
}
}
}
printf("\nThe given matrix is:\n");
for(i=0;i<5;i++)
{ for(j=0;j<5;j++)
printf("%d",a[i][j]);
printtf("\n");
}
printf("\nThe sum of each row:");
for(i=0;i<5;i++)
{ for(j=0;j<5;j++)
s+=a[i][j];
printf("%d->%d\n",i+1,s);
}
getch();
}
Hope this would help you.
How do you do a backwards slash?
Since the backwards slash is the prefix of an escape character, in order to encode a backwards slash in a constant, simply use two of them.
char backslash = '\\';
If you need to know where it is look under the backspace key : ) // \\