Array and nested for loop not showing required result | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Array and nested for loop not showing required result

#include<iostream> using namespace std; void f_1(int x){ if(x==0) cout<<"Salary account opened \n"; else if(x==1) cout<<"Savings account opened \n"; else cout<<"Something went wrong, try again \n"; } void f_2(float x,int p){ if(p==0){ if(x>=500){ cout<<"Amount of "<<x<<" only is added to your salary account \n";}} else if(p==1){ cout<<"Amount of "<<x<<" only is added to your savings account \n";} } void f_3(float x){ int fm = x*2/100; cout<<"Money in savings account in next 5 months respectively"<<endl; int arr[5]={4,5,6,7,8}; for(int i=0;i<=4;i++){ for(int j=0;j<=n;j++){ x=x+fm; cout<<x<<endl; cout<<"month "<<arr[j]<<"money"<<x;} }} void f_4(float f){ int arr[5]={4,5,6,7,8}; cout<<"Money in salary account in next 5 months respectively "<<endl; for(int i=0;i<=2;i++){ for(int j=0;j<=i;j++){ int z=0+f; cout<<"month "<<arr[j]<<endl; cout<<"money "<<z<<endl; }} } int main(){ int a,b,c,d; cout<<"Press 0 to open salary account "<<endl; cin>>a; f_1(a); if(a==0){ cout<<"Deposit money atl

11th Dec 2020, 10:37 AM
Anas kayani
Anas kayani - avatar
1 Answer
0
I want the output as: Month number and money in that month
11th Dec 2020, 11:05 AM
Anas kayani
Anas kayani - avatar