can someone help me, I need a program like this but it **must not use for loop**. or can someone revise it using **do loop**? I need it badly #here is the code: { int n, i, j; do{ printf("Enter a positive int n: "); scanf("%d",&n); } while (n < 0); do{ for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) printf("*"); printf("\n"); } } while (i <= n); getch(); }

Member Avatar
Member Avatar
-2 forum 1

Someone help me creating a this program. Well, I need a program that makes a triangle out of asterisk but it doesnt use "for" loop it only requires "do-while" loop. Actually I tried making one but it doesn't look like a triangle instead it jsut display a line of asterisk. #include<stdio.h> #include<conio.h> int main() { int integer, counter, counter2; counter = 0; counter2 = 0; printf("Enter a number: "); scanf("%d",&integer); do { printf("*"); integer++; }while(counter<0); do { printf("*"); counter++; }while(counter<integer); getch(); return 0; }

Member Avatar
Member Avatar
-1 forum 3

Hello, I have been messing around and writing more and more intricate calculator programs on MVE C++. The issue I am having right now is my program is not running unless I give my add, sub, etc. a value. When I try to just leave them as int add; or int sub; It will not do the equation. Also, if I try to have my couts of cout<<"Your sum...<<add will not appear unless in the do-while loop. Lastly, if I hit q or Q it causes the program to output alot of random things, even though I made my while …

Member Avatar
Member Avatar
+0 forum 7

the loop runs infinte for the second ittiration //attempt two to make the student data base the other way // this program runs onlu once and does not hav any data base once u exit #include<iostream> #include<conio.h> using std::cout; using std::endl; using std::cin; int count=0; class student { double m_roll[100],m_class[100]; char m_name[100],m_adress[100]; public: void getdata(int count) { cout<<" enter the name"<<endl; cin>>m_name[count]; } void read_data(int count) { if (count==0) { cout<<"no data found"; } for (int i=0;i<count;i++) { cout<<m_name[i]; } } }; int main() { int user_input=0; student student1; do { cout<<"enter a choice"<<endl; cin>> user_input; if(user_input==1) { student1.getdata(count); count=count+1; …

Member Avatar
Member Avatar
+0 forum 4

So basically this is suppose to be a grade calculator and the program works, I now just have to put it into a do-while loop so it can work for more than one student. My professor wants it to say Y for another student and N to quit at the end. I'm having a hard time figuring how to make that work. Also he wants the averages to come out to two decimal places even if its just 88.00 but it isn't working when I use setprecision. Any suggestions would be grealy appreciated. #include <iostream> #include <iomanip> using namespace std; …

Member Avatar
Member Avatar
+0 forum 21

So basically I'm stuck at the do-while statement. Should I use a do while? or a for loop? This program is supposed to test my ability to use loops. [CODE]/*Create an application that reads an integer value and prints the sum of all even integers between 2 * and the input value, inclusive. Print an error message if the input value is less than 2. */ import java.util.Random; public class Project3 { public static void main (String[]args) { int critical,test,count = 2; Random rand = new Random (); critical = rand.nextInt(21); test = critical % 2; System.out.println("The random number is: …

Member Avatar
Member Avatar
+0 forum 2

The End.