Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
CPP : Showcase: All Recent Posts Grouped
Concept Learning Code Sheets View all
Finding string class string length .length() .size() .c_str() methods #3009  (25-Jan-2018)
In Topic(s) : Strings - string class type   

Program to demonstrate string class based string in c++ using different methods length() size() and conversion to c_str()


Structure passed as a reference #2979  (24-Jan-2018)
In Topic(s) : Structures passing/returning   

A program to demonstrate how an structure is passed as a reference argument to a function.


Using some popular escape sequence characters. #2288  (6-Jan-2018)
In Topic(s) : Tokens Keyword and Identifiers   

Using some escape sequences in c++ for common tasks.


Sum of digits program using a function #2189  (5-Jan-2018)
In Topic(s) : Functions - user defined   

Writing function sumofdigits() to add the digits in any integer number and then using this function in the main function.


Print till Z with while loop boundary crossing #2038  (30-Dec-2017)
In Topic(s) : Simple Loops   

As user enters a lower case or upper case alphabet the program prints from that alphabet till z using the faster technique of while loop iteration and checking for outside boundary condition


Print till Z with loop count calculation #2034  (29-Dec-2017)
In Topic(s) : Simple Loops   

As user enters a lower case or upper case alphabet the program prints from that alphabet till z.


For and while loop comparison #1995  (28-Dec-2017)
In Topic(s) : Simple Loops   

Comparing simple for and while loop with a simple number printing example


Checking if character entered is a vowel – switch-case #1973  (28-Dec-2017)
In Topic(s) : Switch case selection   

Entering a character from console and then checking if entered character is a vowel or something else.


Territory-wise volume based sales commission – nested if #1945  (27-Dec-2017)
In Topic(s) : Multiple-Nested-Ladder of If Else   

Finding the volume based sales commissions based on multiple territories using the nesting of if conditions


Making a number absolute using If #1861  (22-Dec-2017)
In Topic(s) : Simple If and If Else   

A number is made absolute by removing its negative sign if present.


Solved ProblemsView all
Searching elements from one array into another array #5617 (1-Jan-2019)
In Topic(s) : Arrays Concepts and 1-D Arrays   

Write a program to search members of integer array 1 in array 2 and print the members of array 1 that are also found in array 1. Also print the total number of members found.
For e.g. if array 1 is [12,19,23,3,2] and array 2 is [13,12,2,3,14,21],
the output would be
12 3 2
count = 3

Write a program to search members of integer array 1 in array 2 and print the


Output Writing – Three dimensions in structure passed by reference #5596 (22-Dec-2018)
In Topic(s) : Structures passing/returning   

Write down the output of the program.

struct three_d{int x,y,z;};

void movein(three_d &t,int step=1) 
{ 
  t.x+=step; t.y-=step; t.z+=step;
} 
void moveout(three_d &t,int step=2) 
{ 
  t.x-=step; t.y+=step; t.z-=step;
} 

int main()
{
  three_d t1={10,20,5},t2={30,10,40};
  movein(t1);
  moveout(t2,5);
  cout<<t1.x<<","<<t1.y<<","<<t1.z<<endl;
  cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl;  
  movein(t2,10);
  cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl;  
  return 0;
}


Write down the output of the program.

struct three_d{int x,y,z;};
			
		


Output Writing – Pixel structure passed by reference #2987 (24-Jan-2018)
In Topic(s) : Structures passing/returning   

Write down the output of the program and give steps in arriving at such output.

struct Pix {int x,y;};
void show(Pix &p)
{
  cout<<p.x++<<","<<++p.y<<endl;
}
int main()
{
  Pix P={50,60},Q,R;
  R=P;
  show(R);
  P.x+=10;P.y+=30;
  Q=R;
  show(P); show(Q); show(R);
  return 0;
}

 

Write down the output of the program and give steps in arriving at such outpu


Output Writing Structure pass by value/reference #2984 (24-Jan-2018)
In Topic(s) : Structures passing/returning   

Write the output of the following program depicting structure instances being called as value and called as reference to a function.

struct Sale {int ID; float value;};
void sc(Sale a,Sale &b)
{
a.ID=a.ID+1;
a.value=a.value+100;
b=a;
}
int main()
{
  Sale zone1={1,400.50},zone2;
  sc(zone1,zone2);
  cout<<"Zone 1 (ID, value) = "<<zone1.ID<<", "<<zone1.value<<endl;
  cout<<"Zone 2 (ID, value) = "<<zone2.ID<<", "<<zone2.value<<endl;
  return 0;
}

Write the output of the following program depicting structure instances being


Slope of line -using structure Point passed to a function #2973 (24-Jan-2018)
In Topic(s) : Structures passing/returning   

Write a program by declaring a structure Point with two integer values for its position x and y. Now write a function that finds slope of a line drawn out of two points that are passed as structure argument to this function. Show implementation of this function and structure in the main routine assuming suitable values of x and y being initialised for two points.

Write a program by declaring a structure Point with two integer values for i


Counting words in a text input even if it is not well formed #2717 (17-Jan-2018)
In Topic(s) : String Handling (Null Terminated)   

Write a program to count number of words even when there might be extra spaces between words and extra punctuation marks. Any alphabets or numbers written contiguously will be counted as words. For. e.g. “21st Century” are two words and “21    st         century systems ?” are four words. ? is not counted as word while 21 is counted as a word.

Write a program to count number of words even when there might be extra space


Powering a number using a loop #2053 (31-Dec-2017)
In Topic(s) : Simple Loops   

Write a c++ program to power a base number with the given exponent by using a for loop.

Write a c++ program to power a base number with the given exponent by using a


Leap year finding #2008 (29-Dec-2017)
In Topic(s) : Multiple-Nested-Ladder of If Else   

Write a c++ program to take the value of a four digit year from the user and then print whether the given year is a leap year or not.

Write a c++ program to take the value of a four digit year from the user and


Increment, Decrement Composite Operators Problem 1 #1756 (17-Dec-2017)
In Topic(s) : Operators   

Show the output of the following program. Assume that required header files are present.

int main()
{
  int n=10;
  cout<< n << endl ;
  cout<< ++n << endl ;
  cout<< n++ << endl ;
  cout<< n << endl ;
  cout<< - n << endl ;
  cout<< - - n << endl ;
  cout<< -- n << endl ;
  cout<< n << endl ;
  cout<< n-- << endl ;
  cout<< n << endl ;
  cout<< - --n <<endl;
  cout<< (n+=1) <<endl;
  cout<< (n-=1) <<endl;
  cout<< (n%=2) <<endl;
  return 0 ;
}

Show the output of the following program. Assume that required header files a







Back