Posts

Solutions for even numbered questions in C++ exercises for beginners

  solutions for even numbered questions in C++ exercises for beginners   #Q2)  we can solve this problem by using arrays but for now as a beginner we solve it  by declaring five variables to store the scores of those students. #include<iostream> using namespace std; int main(){ float num1,num2,num3,num4,num5,average; cout<<"Enter the test scores respectively : "<<endl; cin>>num1>>num2>>num3>>num4>>num5; average=(num1+num2+num3+num4+num5)/5.0; cout<<"the average of the given test score is "<<average<<endl; return 0; } #Q4) let us do it by using if..else statments  #include<iostream> using namespace std; int main(){ double  x,y,z;   cout<<"Enter the three numbers respectively "<<endl; cin>>x>>y>>z; // accepting input from user  cout<<"the numer that you entered is "<<x<<" , "<<y<<" , "<&l

C++ programming exercises for beginners

Lists of programming exercise for absoulute beginners 1. Write a program that prompts the user to input a decimal number and outputs the number rounded to the nearest integer. 2. Write a program that prompts the user to enter five test scores and then prints the average test score. (Assume that the test scores are decimal numbers.) 3. (Hard drive storage capacity) If you buy a 40 GB hard drive, then chances are that the actual storage on the hard drive is not 40 GB. This is due to the fact that, typically, a manufacturer uses 1,000 bytes as the value of 1K bytes, 1,000 K bytes as the value of 1 MB, 1,000 MB as the value of 1 GB. Therefore, a 40 GB hard drive contains 40,000,000,000 bytes. However, in computer memory, as you know before 1 KB is equal to 1,024 bytes, and so on. So the actual storage on a 40 GB hard drive is approximately 37.25 GB. (You might like to read the fine print next ti

C++ sample Exams with their answers

Part ፩ : Choose the best answer from the following alternativealternatives.(1.5 each) 1. Evaluate the following !(1 && !(0 || 1)) A. 0 B. 1 C. -1 D. error 2. How many times will the following while loop print "hello"? .... int main() int i=1; while(i<=10){ cout<<"hello world";} return 0;} A. 10 B. 8 C. An infinite number of times D. none 3. Which one is not Mandatory part in function declaration? A. return type B. parameters C. function name D. none 4. the following loops is supposed to print all even numbers from 0 to 20 which option will be replaced for the blank space? ..... k=0; while(k<=20 { cout< _________;} A. k=2*k B. k=k+1 C. k=k+2 D. k=k-2 5. Given program as follows , what would be printed? int myFun(int n) { if(n==0) return 0; else return n+ myFun(n-1);} A. 0 B. 10 C. 5 D. 15 6. Assu

Home Page

Click the following button to see the result: You can contact us by using the links below Send Email | Telegram | Tiktok | Youtube

Full c++ program that convert any string to binary format

 /*C++ program to convert string into binary string*/ #include <bits/stdc++.h> #include<iostream> using namespace std; // user Define function void StringToBinaryNumber(string); int main() { string UserInput; cout<<"Enter your full name:";   getline(cin,UserInput);// to read more than one words( including spaces) StringToBinaryNumber(UserInput); return 0; } void StringToBinaryNumber(string fname) { int lengthofstring,asciivalueOfstring ; string binaryValue; lengthofstring= fname.length(); for (int i = 0; i <= lengthofstring; i++) {   /*convert each char to ASCII value*/   asciivalueOfstring = int(fname[i]);   // Convert ASCII value to binary    binaryValue = "";   while (asciivalueOfstring > 0)   {    (asciivalueOfstring % 2)? binaryValue.push_back('1') :binaryValue.push_back('0');//  ternal operators (?:)   asciivalueOfstring /= 2;   }   reverse(binaryValue.begin(), binaryValue.end());// function that reverse the bina