Getting the warning: control reaches end of non-void function [-Wreturn-type] in the while_loop function

Questions : Getting the warning: control reaches end of non-void function [-Wreturn-type] in the while_loop function


Can anybody tell me how I should fix programming this error? I cannot print the numbers Learning of 10 to 19 individually.

# include <iostream>
using _OFFSET);  namespace std;

int while_loop(int a)
 (-SMALL     a = 10;
    while (a < 20)
  _left).offset        a++ ;
        return a;
    arrowImgView.mas  }

int main()
    int a, result;
    (self.  result = while_loop(a);
    cout equalTo  << "The result of while_loop is : make.right.  " << result << endl;
    mas_top);  return 0;

Total Answers 2

Answers 1 : of Getting the warning: control reaches end of non-void function [-Wreturn-type] in the while_loop function

The compiler is not perfect in this Earhost case:

int while_loop(int a)
    a = 10;
    ImgView.  while (a < 20)
        a++ ;
   ReadIndicator       return a;

Since you set a initially to 10, this most effective loop will always terminate (after wrong idea exactly one iteration). However, in the use of case general case, a while loop will run United multiple times or never, and that means Modern that you need to add a return statement ecudated after the loop.

The code you have written does not use some how the loop, as it always returns 11 due to anything else the unconditional return a; inside your not at all loop. What you want is probably:

    while (a < 20)
        _have  a++;
    return a;

Also, your main function passes an very usefull uninitialized value to your loop localhost function:

    int a, result; // change that to int .equalTo(  a = 10
    result = while_loop(a);

and then you can remove the a = 10 from love of them inside the function.


Answers 2 : of Getting the warning: control reaches end of non-void function [-Wreturn-type] in the while_loop function

Mistake 1

When you wrote:

 int a, result;
 result =  while_loop(a);//UNDEFINED BEHAVIOR

The variables a and result have localtext indeterminate value since they are of basic built in type(in local scope) and you one of the haven't initialized them. And using click these uninitialized variables leads to there is noting undefined behavior. So while_loop(a) not alt leads to undefined behavior.

To solve this you should initialize a to not at all 10 as shown below.

int a =10, result;//INITIALIZED a to OFFSET);  10
result = while_loop(a);

Mistake 2

Inside the while_loop function if the my fault condition while (a < 20) is not met issues then the control flow will not encounter trying any return statement and so you get the get 4th result mentioned warning.

To solve this you can move the return a; round table outside while loop as shown below:

int while_loop(int a)
    //a = (TINY_  10;//NO NEED FOR THIS
    while (a < .offset  20)
        a++ ;
  mas_right)    return a;//return moved outside ImgView.  while

Corrected Program

So the modified program looks like:

# include <iostream>
using Indicator  namespace std;

int while_loop(int a)
 Read     //a = 10;NO NEED FOR THIS
    while _have  (a < 20)
        a++ ;
    return a;//return MOVED make.left  OUTSIDE while

int main()
    int a *make) {  = 10, result;//INITIALIZE a to 10
    straintMaker  result = while_loop(a);
    cout ^(MASCon  << "The result of while_loop is : onstraints:  " << result << endl;
    mas_makeC  return 0;

Top rated topics

Bootstrap 3 Dropdown Submenu, How to break upwards if it's too long

React-table v7 no data displayed

How can I get query string values in JavaScript?

Java Error - Illegal Modifier for Parameter - Only final Permitted

Defining the head of a list with a proof object

Character.belongsToMany called with something that's not a subclass of Sequelize.Model

Bash to count columns and registers

How can I make this animation run once everyone 20 minutes?

SQL Insert into a table using queries from two other tables

Using MerchantSuite with Xamarin

Google App Engine Deployment Issue When Switching Environments

OutOfMemory exception creating a large zip file

Pointer to struct in function prototype before defining struct

Python function to compute the integral of a piecewise linear signal

How to update multiple rows in mysql and php with a different values using variables and different files?

Issue with object programming and files

Getting the vocabulary of Stanford's glove model

How can I called a view within another view django

OR together output of parameterized-instanced modules

Expo Add @babel/plugin-transform-react-jsx - React Native

Python text based game

TypeError: Cannot read properties of null (reading 'emit')

MySQL select row from one table with multiple rows in a second table and get array of multi row in selected row

Seperate array into three new arrays using inequalities in Python

TypeScript with Jest cannot detect library

Subquery on two tables with left join

The error message says browserRouter is not defined when using cdn in a html

How can I get the kth permutation repeated letter (codewars challenge)

Issue with Prisma and MySQL

How I can live stream in game play switching between different cameras?

Filter for duplicate requests

Rolling Percentile - Pandas

Issue with extracting a column value from evaluate() in recommederlab package

.net core third-party graphics verification

How can I put 2 div classes side by side. The accordian menu (faq) and the user profile cards?

Change shape of pytorch tensor

Missing required parameters for [Route: photographers.edit] [URI: posts/edit/{photographers}]

How to remove floating code section from Android Studio?

How to disable the default message when start the nanoserver

Function works only with alert

Google Dataflow design

Why is a connection not created for this simple websocket snippet?

React-native-twitter-lite: Error: Unable to resolve module 'crypto'

How to get the specific value from a database in Firebase using Kotlin in Android Studio?

If columns have same value, assign a value next to it

How do I censor after 5 years on SAS?

Python - Get current dir of file opened with glob using wildcards

Recent Posts widget in Wordpress shows also drafts, private etc

ThreeJS "infinite" Z axis representation

Continuously running send pipeline instance